When code smells twice as much: Metric-based detection of variability-aware code smells

Code smells are established, widely used characterizations of shortcomings in design and implementation of software systems. As such, they have been subject to intensive research regarding their detection and impact on understandability and changeability of source code. However, current methods do not support highly configurable software systems, that is, systems that can be customized to fit a wide range of requirements or platforms. Such systems commonly owe their configurability to conditional compilation based on C preprocessor annotations (a. k. a. #ifdefs). Since annotations directly interact with the host language (e. g., C), they may have adverse effects on understandability and changeability of source code, referred to as variability-aware code smells. In this paper, we propose a metric-based method that integrates source code and C preprocessor annotations to detect such smells. We evaluate our method for one specific smell on five open-source systems of medium size, thus, demonstrating its general applicability. Moreover, we manually reviewed 100 instances of the smell and provide a qualitative analysis of its potential impact as well as common causes for the occurrence.

[1]  Gunter Saake,et al.  Variant-preserving refactoring in feature-oriented software product lines , 2012, VaMoS.

[2]  Brian W. Kernighan,et al.  The C Programming Language , 1978 .

[3]  Carlos José Pereira de Lucena,et al.  Applying and Evaluating Concern-Sensitive Design Heuristics , 2009, 2009 XXIII Brazilian Symposium on Software Engineering.

[4]  Sven Apel,et al.  Virtual Separation of Concerns - A Second Chance for Preprocessors , 2009, J. Object Technol..

[5]  Márcio Ribeiro,et al.  The Love/Hate Relationship with the C Preprocessor: An Interview Study , 2015, ECOOP.

[6]  Aiko Yamashita How Good Are Code Smells for Evaluating Software Maintainability? Results from a Comparative Case Study , 2013, 2013 IEEE International Conference on Software Maintenance.

[7]  Elmar Jürgens,et al.  Analyzing the Effect of Preprocessor Annotations on Code Clones , 2011, 2011 IEEE 11th International Working Conference on Source Code Analysis and Manipulation.

[8]  Gunter Saake,et al.  Feature-Oriented Software Product Lines , 2013, Springer Berlin Heidelberg.

[9]  Eduardo Figueiredo,et al.  Detecting Code Smells in Software Product Lines -- An Exploratory Study , 2015, 2015 12th International Conference on Information Technology - New Generations.

[10]  Sven Apel,et al.  An analysis of the variability in forty preprocessor-based software product lines , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[11]  Andrew P. Black,et al.  An interactive ambient visualization for code smells , 2010, SOFTVIS '10.

[12]  Arthur J. Riel,et al.  Object-Oriented Design Heuristics , 1996 .

[13]  Stéphane Ducasse,et al.  Object-Oriented Metrics in Practice , 2005 .

[14]  Henry Spencer,et al.  #ifdef Considered Harmful, or Portability Experience with C News , 1992, USENIX Summer.

[15]  Sven Apel,et al.  Analyzing the discipline of preprocessor annotations in 30 million lines of C code , 2011, AOSD '11.

[16]  Yann-Gaël Guéhéneuc,et al.  DECOR: A Method for the Specification and Detection of Code and Design Smells , 2010, IEEE Transactions on Software Engineering.

[17]  Ira D. Baxter,et al.  Preprocessor conditional removal by simple partial evaluation , 2001, Proceedings Eighth Working Conference on Reverse Engineering.

[18]  Foutse Khomh,et al.  An Empirical Study of the Impact of Two Antipatterns, Blob and Spaghetti Code, on Program Comprehension , 2011, 2011 15th European Conference on Software Maintenance and Reengineering.

[19]  Leon Moonen,et al.  Java quality assurance by detecting code smells , 2002, Ninth Working Conference on Reverse Engineering, 2002. Proceedings..

[20]  Sven Apel,et al.  Morpheus: Variability-Aware Refactoring in the Wild , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[21]  Christian Prehofer,et al.  Feature-Oriented Programming: A Fresh Look at Objects , 1997, ECOOP.

[22]  Sven Apel,et al.  Granularity in software product lines , 2008, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[23]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[24]  Michael W. Godfrey,et al.  “Cloning considered harmful” considered harmful: patterns of cloning in software , 2008, Empirical Software Engineering.

[25]  Wolfram Fenske,et al.  Code Smells Revisited: A Variability Perspective , 2015, VaMoS.

[26]  Sven Apel,et al.  Preprocessor-based variability in open-source and industrial software systems: An empirical study , 2016, Empirical Software Engineering.

[27]  Krzysztof Czarnecki,et al.  Generative Programming , 2001, ECOOP Workshops.

[28]  Foutse Khomh,et al.  An Exploratory Study of the Impact of Code Smells on Software Change-proneness , 2009, 2009 16th Working Conference on Reverse Engineering.

[29]  Márcio Ribeiro,et al.  Investigating preprocessor-based syntax errors , 2014, GPCE '13.

[30]  Foutse Khomh,et al.  A Bayesian Approach for the Detection of Code and Design Smells , 2009, 2009 Ninth International Conference on Quality Software.

[31]  Mauricio A. Saca Refactoring improving the design of existing code , 2017, 2017 IEEE 37th Central America and Panama Convention (CONCAPAN XXXVII).

[32]  Jonathan I. Maletic,et al.  An XML-Based Lightweight C++ Fact Extractor , 2003, IWPC.