23
Does Your Configuration Code Smell? Tushar Sharma, Marios Fragkoulis, Diomidis Spinellis {tushar, mfg, dds}@aueb.gr MSR 2016

Does Your Configuration Code Smell?

Embed Size (px)

Citation preview

Page 1: Does Your Configuration Code Smell?

Does Your Configuration Code Smell?

Tushar Sharma, Marios Fragkoulis, Diomidis Spinellis

{tushar, mfg, dds}@aueb.gr

MSR 2016

Page 2: Does Your Configuration Code Smell?

“Smells”

Code Smell

…certain structures in the code that suggest (sometimes they scream for) the possibility of refactoring.

Page 3: Does Your Configuration Code Smell?
Page 4: Does Your Configuration Code Smell?

“Smells”

Design Smells

“Design smells are certain structures in the design that indicate violation of fundamental design principles and negatively impact design quality.”

Page 5: Does Your Configuration Code Smell?

“Smells”

Configuration Smells

Page 6: Does Your Configuration Code Smell?

“Infrastructure as Code” (IaC)

Page 7: Does Your Configuration Code Smell?

Software System

IaC and Traditional SE

Production code

Infrastructure, configuration code, tools and services

Apply traditional software

engineering practices

Page 8: Does Your Configuration Code Smell?

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

Page 9: Does Your Configuration Code Smell?

Overview of the study

Taxonomy of configuration smells

Research questions

Configuration code (Puppet - 4621 repositories)

Results

Tools to detect configuration smells

Page 10: Does Your Configuration Code Smell?

Configuration smells: A taxonomy

Page 11: Does Your Configuration Code Smell?

Implementation configuration smells

Page 12: Does Your Configuration Code Smell?

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.

Page 13: Does Your Configuration Code Smell?

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

Page 14: Does Your Configuration Code Smell?

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

Page 15: Does Your Configuration Code Smell?

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

Page 16: Does Your Configuration Code Smell?

Detecting configuration smells

Implementation configuration smells • Additional custom rules to an existing tool

Design configuration smells • Puppeteer [1]

1. https://github.com/tushartushar/Puppeteer

Page 17: Does Your Configuration Code Smell?

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

Page 18: Does Your Configuration Code Smell?

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

Page 19: Does Your Configuration Code Smell?

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

Page 20: Does Your Configuration Code Smell?

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.

Page 21: Does Your Configuration Code Smell?

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

Page 22: Does Your Configuration Code Smell?

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

Page 23: Does Your Configuration Code Smell?

Thank you!!

Courtesy: spikedmath.com

Tushar Sharma [email protected]

@Sharma__Tushar