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 706
INC 4,804 440
ICE 3,994 964
IDE 65 29
IMA 22,976 1,383
IIA 7,80,265 3,064
IPV 14,360 729
IIT 11,071 1,467
IDS 6,466 674
IQU 4,28,951 2,463
ILS 5,27,637 4,115
IIC 4,797 1,217
IUV 71,339 1,405
DCS #I(V) #I(E)
DMF 64,266 4,339
DUA 4,319 1,427
DIA 4,354 1,575
DMA 1,913 813
DIM 96,033 4,422
DUM 4,653 3,337
DDB 17,601 1,016
DBH 83 37
DDS 1,760 1,760
DDE 1,075 424
DWM 13,944 2,890
1. What is the distribution of maintainability
smells in configuration code?
ICS #I(V) #I(E)
IMD 4,604 706
INC 4,804 440
ICE 3,994 964
IDE 65 29
IMA 22,976 1,383
IIA 7,80,265 3,064
IPV 14,360 729
IIT 11,071 1,467
IDS 6,466 674
IQU 4,28,951 2,463
ILS 5,27,637 4,115
IIC 4,797 1,217
IUV 71,339 1,405
DCS #I(V) #I(E)
DMF 64,266 4,339
DUA 4,319 1,427
DIA 4,354 1,575
DMA 1,913 813
DIM 96,033 4,422
DUM 4,653 3,337
DDB 17,601 1,016
DBH 83 37
DDS 1,760 1,760
DDE 1,075 424
DWM 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-16
Analysis 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.00980
Design 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
Thank you!!
Courtesy: spikedmath.com
Tushar Sharma
tushar@aueb.gr
@Sharma__Tushar

Does Your Configuration Code Smell?

  • 1.
    Does Your Configuration CodeSmell? Tushar Sharma, Marios Fragkoulis, Diomidis Spinellis {tushar, mfg, dds}@aueb.gr MSR 2016
  • 2.
    “Smells” Code Smell …certain structuresin the code that suggest (sometimes they scream for) the possibility of refactoring.
  • 4.
    “Smells” Design Smells “Design smellsare certain structures in the design that indicate violation of fundamental design principles and negatively impact design quality.”
  • 5.
  • 6.
  • 7.
    Software System IaC andTraditional SE Production code Infrastructure, configuration code, tools and services Apply traditional software engineering practices
  • 8.
    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
  • 9.
    Overview of thestudy Taxonomy of configuration smells Research questions Configuration code (Puppet - 4621 repositories) Results Tools to detect configuration smells
  • 10.
  • 11.
  • 12.
    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.
  • 13.
    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
  • 14.
    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
  • 15.
    Mining GitHub Repositories Repositories4,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
  • 16.
    Detecting configuration smells Implementationconfiguration smells • Additional custom rules to an existing tool Design configuration smells • Puppeteer [1] 1. https://github.com/tushartushar/Puppeteer
  • 17.
    1. What isthe distribution of maintainability smells in configuration code? ICS #I(V) #I(E) IMD 4,604 706 INC 4,804 440 ICE 3,994 964 IDE 65 29 IMA 22,976 1,383 IIA 7,80,265 3,064 IPV 14,360 729 IIT 11,071 1,467 IDS 6,466 674 IQU 4,28,951 2,463 ILS 5,27,637 4,115 IIC 4,797 1,217 IUV 71,339 1,405 DCS #I(V) #I(E) DMF 64,266 4,339 DUA 4,319 1,427 DIA 4,354 1,575 DMA 1,913 813 DIM 96,033 4,422 DUM 4,653 3,337 DDB 17,601 1,016 DBH 83 37 DDS 1,760 1,760 DDE 1,075 424 DWM 13,944 2,890
  • 18.
    1. What isthe distribution of maintainability smells in configuration code? ICS #I(V) #I(E) IMD 4,604 706 INC 4,804 440 ICE 3,994 964 IDE 65 29 IMA 22,976 1,383 IIA 7,80,265 3,064 IPV 14,360 729 IIT 11,071 1,467 IDS 6,466 674 IQU 4,28,951 2,463 ILS 5,27,637 4,115 IIC 4,797 1,217 IUV 71,339 1,405 DCS #I(V) #I(E) DMF 64,266 4,339 DUA 4,319 1,427 DIA 4,354 1,575 DMA 1,913 813 DIM 96,033 4,422 DUM 4,653 3,337 DDB 17,601 1,016 DBH 83 37 DDS 1,760 1,760 DDE 1,075 424 DWM 13,944 2,890 Tools and IDEs are still maturing. Either developers do not duplicate code at all or do it massively
  • 19.
    2. What isthe relationship between the occurrence of design configuration smells and implementation configuration smells? CORRELATION P-VALUE Analysis by volume 0.6641 <2.2e-16 Analysis by existance 0.4452 <2.2e-16
  • 20.
    3. Is theprinciple 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.
  • 21.
    4. Does smelldensity depend on the size of the configuration project? CORRELATION P-VALUE Implementation smells 0.0383 0.00980 Design smells -0.3285 <2.2e-16
  • 22.
    Contributions Research • Taxonomy forconfiguration smells • A method for investigating system configuration smells by mining repositories Practice • Best practices to write maintainable configuration code • Tools to identify configuration smells
  • 23.
    Thank you!! Courtesy: spikedmath.com TusharSharma tushar@aueb.gr @Sharma__Tushar