Download - Does Your Configuration Code Smell?
Does Your Configuration Code Smell?
Tushar Sharma, Marios Fragkoulis, Diomidis Spinellis
{tushar, mfg, dds}@aueb.gr
MSR 2016
“Smells”
Code Smell
…certain structures in the code that suggest (sometimes they scream for) the possibility of refactoring.
“Smells”
Design Smells
“Design smells are certain structures in the design that indicate violation of fundamental design principles and negatively impact design quality.”
“Smells”
Configuration Smells
“Infrastructure as Code” (IaC)
Software System
IaC and Traditional SE
Production code
Infrastructure, configuration code, tools and services
Apply traditional software
engineering practices
Puppet example
package { 'apache2': require => Exec['apt-update'],
ensure => installed, }
service { 'apache2':
ensure => running, }
user { 'tushar':
ensure => present, uid => '1000', gid => '1000',
shell => '/bin/bash', home => '/home/tushar' }
Configuration management tools: Ansible, Chef, CFEngine, Puppet
Overview of the study
Taxonomy of configuration smells
Research questions
Configuration code (Puppet - 4621 repositories)
Results
Tools to detect configuration smells
Configuration smells: A taxonomy
Implementation configuration smells
Design configuration smells
• Multifaceted Abstraction • elements of an abstraction are not cohesive.
• Unnecessary Abstraction • an empty class, ‘define’, or module
• Imperative Abstraction • imperative statements
• Missing Abstraction • resources and language elements are not encapsulated in an
abstraction.
Design configuration smells
• Duplicate Block • a duplicate block of statements
• Deficient Encapsulation • global variables in a node declaration or ENC
• Insufficient Modularization • large and complex abstraction
• Unstructured Module • obscure module and repository structure
Design configuration smells
• Dense Structure • repository has excessive and dense dependencies
• Weakened Modularity • a module with high coupling and low cohesion
• Broken Hierarchy • inter-namespace inheritance
Mining GitHub Repositories
Repositories 4,621
Puppet files 142,662
Class declarations 132,323
Define declarations 39,263
File resources 117,286
Package resources 49,841
Service resources 18,737
Exec declarations 43,468
Lines of code (Puppet only) 8,948,611
GHTorrent
Detecting configuration smells
Implementation configuration smells • Additional custom rules to an existing tool
Design configuration smells • Puppeteer [1]
1. https://github.com/tushartushar/Puppeteer
1. What is the distribution of maintainability smells in configuration code?
ICS #I(V) #I(E)IMD 4,604 706INC 4,804 440ICE 3,994 964IDE 65 29IMA 22,976 1,383IIA 7,80,265 3,064IPV 14,360 729IIT 11,071 1,467IDS 6,466 674IQU 4,28,951 2,463ILS 5,27,637 4,115IIC 4,797 1,217IUV 71,339 1,405
DCS #I(V) #I(E)DMF 64,266 4,339DUA 4,319 1,427DIA 4,354 1,575
DMA 1,913 813DIM 96,033 4,422DUM 4,653 3,337DDB 17,601 1,016DBH 83 37DDS 1,760 1,760DDE 1,075 424DWM 13,944 2,890
1. What is the distribution of maintainability smells in configuration code?
ICS #I(V) #I(E)IMD 4,604 706INC 4,804 440ICE 3,994 964IDE 65 29IMA 22,976 1,383IIA 7,80,265 3,064IPV 14,360 729IIT 11,071 1,467IDS 6,466 674IQU 4,28,951 2,463ILS 5,27,637 4,115IIC 4,797 1,217IUV 71,339 1,405
DCS #I(V) #I(E)DMF 64,266 4,339DUA 4,319 1,427DIA 4,354 1,575
DMA 1,913 813DIM 96,033 4,422DUM 4,653 3,337DDB 17,601 1,016DBH 83 37DDS 1,760 1,760DDE 1,075 424DWM 13,944 2,890
Tools and IDEs are still maturing.
Either developers do not
duplicate code at all or do it massively
2. What is the relationship between the occurrence of design configuration smells and implementation configuration smells?
CORRELATION P-VALUE
Analysis by volume 0.6641 <2.2e-16Analysis by existance 0.4452 <2.2e-16
3. Is the principle of coexistence applicable to smells in configuration projects?
Whenever duplicate entity or broken hierarchy smells are found, it is very
likely to find other smells from the same category in the project.
Design configuration smells show 9.3% higher co-occurrence
among themselves than the implementation configuration smells.
4. Does smell density depend on the size of the configuration project?
CORRELATION P-VALUE
Implementation smells 0.0383 0.00980Design smells -0.3285 <2.2e-16
Contributions
Research • Taxonomy for configuration smells • A method for investigating system configuration smells
by mining repositories
Practice • Best practices to write maintainable configuration code • Tools to identify configuration smells