Understanding metric-based detectable smells in Python software: A comparative study

Abstract Context Code smells are supposed to cause potential comprehension and maintenance problems in software development. Although code smells are studied in many languages, e.g. Java and C#, there is a lack of technique or tool support addressing code smells in Python. Objective Due to the great differences between Python and static languages, the goal of this study is to define and detect code smells in Python programs and to explore the effects of Python smells on software maintainability. Method In this paper, we introduced ten code smells and established a metric-based detection method with three different filtering strategies to specify metric thresholds (Experience-Based Strategy, Statistics-Based Strategy, and Tuning Machine Strategy). Then, we performed a comparative study to investigate how three detection strategies perform in detecting Python smells and how these smells affect software maintainability with different detection strategies. This study utilized a corpus of 106 Python projects with most stars on GitHub. Results The results showed that: (1) the metric-based detection approach performs well in detecting Python smells and Tuning Machine Strategy achieves the best accuracy; (2) the three detection strategies discover some different smell occurrences, and Long Parameter List and Long Method are more prevalent than other smells; (3) several kinds of code smells are more significantly related to changes or faults in Python modules. Conclusion These findings reveal the key features of Python smells and also provide a guideline for the choice of detection strategy in detecting and analyzing Python smells.

[1]  A. Yamashita,et al.  Exploring the impact of inter-smell relations on software maintainability: An empirical study , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[2]  Audris Mockus,et al.  Quantifying the Effect of Code Smells on Maintenance Effort , 2013, IEEE Transactions on Software Engineering.

[3]  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.

[4]  Radu Marinescu,et al.  Towards the optimization of automatic detection of design flaws in object-oriented software systems , 2005, Ninth European Conference on Software Maintenance and Reengineering.

[5]  Mika Mäntylä,et al.  Code Smell Detection: Towards a Machine Learning-Based Approach , 2013, 2013 IEEE International Conference on Software Maintenance.

[6]  Jacob Cohen A Coefficient of Agreement for Nominal Scales , 1960 .

[7]  Yuming Zhou,et al.  Empirical analysis of network measures for predicting high severity software faults , 2016, Science China Information Sciences.

[8]  Aiko Fallas Yamashita,et al.  Do code smells reflect important maintainability aspects? , 2012, 2012 28th IEEE International Conference on Software Maintenance (ICSM).

[9]  Yuming Zhou,et al.  Dynamic Slicing of Python Programs , 2014, 2014 IEEE 38th Annual Computer Software and Applications Conference.

[10]  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.

[11]  Mark Lutz,et al.  Programming Python , 1996 .

[12]  Alexander Chatzigeorgiou,et al.  Identification of Move Method Refactoring Opportunities , 2009, IEEE Transactions on Software Engineering.

[13]  Aiko Fallas Yamashita,et al.  Do developers care about code smells? An exploratory survey , 2013, 2013 20th Working Conference on Reverse Engineering (WCRE).

[14]  Ioannis Stamelos,et al.  A controlled experiment investigation of an object-oriented design heuristic for maintainability , 2004, J. Syst. Softw..

[15]  Yuanfang Cai,et al.  Hotspot Patterns: The Formal Definition and Automatic Detection of Architecture Smells , 2015, 2015 12th Working IEEE/IFIP Conference on Software Architecture.

[16]  Yang Liu,et al.  Dynamic and Automatic Feedback-Based Threshold Adaptation for Code Smell Detection , 2016, IEEE Transactions on Software Engineering.

[17]  Tom Mens,et al.  Does God Class Decomposition Affect Comprehensibility? , 2006, IASTED Conf. on Software Engineering.

[18]  Michele Lanza,et al.  Object-Oriented Metrics in Practice - Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems , 2006 .

[19]  M.J. Munro,et al.  Product Metrics for Automatic Identification of "Bad Smell" Design Problems in Java Source-Code , 2005, 11th IEEE International Software Metrics Symposium (METRICS'05).

[20]  Manu Sridharan,et al.  DLint: dynamically checking bad coding practices in JavaScript , 2015, ISSTA.

[21]  J. R. Landis,et al.  The measurement of observer agreement for categorical data. , 1977, Biometrics.

[22]  Baowen Xu,et al.  Static Slicing for Python First-Class Objects , 2013, 2013 13th International Conference on Quality Software.

[23]  Tracy Hall,et al.  Prioritising Refactoring Using Code Bad Smells , 2011, 2011 IEEE Fourth International Conference on Software Testing, Verification and Validation Workshops.

[24]  Tobias Wrigstad,et al.  Tracing dynamic features in python programs , 2014, MSR 2014.

[25]  Baowen Xu,et al.  A Constraint Based Bug Checking Approach for Python , 2009, 2009 33rd Annual IEEE International Computer Software and Applications Conference.

[26]  Raed Shatnawi,et al.  An empirical study of the bad smells and class error probability in the post-release object-oriented system evolution , 2007, J. Syst. Softw..

[27]  Stéphane Ducasse,et al.  Using history information to improve design flaws detection , 2004, Eighth European Conference on Software Maintenance and Reengineering, 2004. CSMR 2004. Proceedings..

[28]  Gabriele Bavota,et al.  Detecting bad smells in source code using change history information , 2013, 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[29]  Daniela Cruzes,et al.  Are all code smells harmful? A study of God Classes and Brain Classes in the evolution of three open source systems , 2010, 2010 IEEE International Conference on Software Maintenance.

[30]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[31]  Andreas Zeller,et al.  When do changes induce fixes? , 2005, ACM SIGSOFT Softw. Eng. Notes.

[32]  J. Fleiss Measuring nominal scale agreement among many raters. , 1971 .

[33]  Gabriele Bavota,et al.  When and Why Your Code Starts to Smell Bad (and Whether the Smells Go Away) , 2015, IEEE Transactions on Software Engineering.

[34]  Yi Sun,et al.  Some Code Smells Have a Significant but Small Effect on Faults , 2014, TSEM.

[35]  R. Grissom,et al.  Effect sizes for research: A broad practical approach. , 2005 .

[36]  Premkumar T. Devanbu,et al.  Clones: what is that smell? , 2010, 2010 7th IEEE Working Conference on Mining Software Repositories (MSR 2010).

[37]  Radu Marinescu,et al.  Detection strategies: metrics-based rules for detecting design flaws , 2004, 20th IEEE International Conference on Software Maintenance, 2004. Proceedings..

[38]  David M. Beazley,et al.  Python Essential Reference , 1999 .

[39]  Kathryn T. Stolee,et al.  Identification, Impact, and Refactoring of Smells in Pipe-Like Web Mashups , 2013, IEEE Transactions on Software Engineering.

[40]  A. Ananda Rao,et al.  Detecting Bad Smells in Object Oriented Design Using Design Change Propagation Probability Matrix , 2008 .

[41]  Michel Wermelinger,et al.  Assessing the effect of clones on changeability , 2008, 2008 IEEE International Conference on Software Maintenance.

[42]  S. West,et al.  The Analysis of Count Data: A Gentle Introduction to Poisson Regression and Its Alternatives , 2009, Journal of personality assessment.

[43]  Thomas J. Mowbray,et al.  AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis , 1998 .

[44]  Yanhong A. Liu,et al.  Alias analysis for optimization of dynamic languages , 2010, DLS '10.

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

[46]  Alexander Chatzigeorgiou,et al.  Investigating the Evolution of Bad Smells in Object-Oriented Code , 2010, 2010 Seventh International Conference on the Quality of Information and Communications Technology.

[47]  Alberto Bacchelli,et al.  On the Impact of Design Flaws on Software Defects , 2010, 2010 10th International Conference on Quality Software.

[48]  Radu Marinescu,et al.  Measurement and Quality in Object-Oriented Design , 2005, ICSM.

[49]  Andrea De Lucia,et al.  A textual-based technique for Smell Detection , 2016, 2016 IEEE 24th International Conference on Program Comprehension (ICPC).

[50]  Gabriele Bavota,et al.  Do They Really Smell Bad? A Study on Developers' Perception of Bad Code Smells , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[51]  Bashar Nuseibeh,et al.  Assessing the impact of bad smells using historical information , 2007, IWPSE '07.

[52]  Nenad Medvidovic,et al.  On the Impact of Aspect-Oriented Code Smells on Architecture Modularity: An Exploratory Study , 2011, 2011 Fifth Brazilian Symposium on Software Components, Architectures and Reuse.

[53]  Foutse Khomh,et al.  Numerical Signatures of Antipatterns: An Approach Based on B-Splines , 2010, 2010 14th European Conference on Software Maintenance and Reengineering.

[54]  Francesca Arcelli Fontana,et al.  Automatic Metric Thresholds Derivation for Code Smell Detection , 2015, 2015 IEEE/ACM 6th International Workshop on Emerging Trends in Software Metrics.

[55]  Gabriele Bavota,et al.  Mining Version Histories for Detecting Code Smells , 2015, IEEE Transactions on Software Engineering.

[56]  Eduardo Figueiredo,et al.  Understanding the longevity of code smells: preliminary results of an explanatory survey , 2011, WRT '11.

[57]  M F Sanner,et al.  Python: a programming language for software integration and development. , 1999, Journal of molecular graphics & modelling.

[58]  Foutse Khomh,et al.  An exploratory study of the impact of antipatterns on class change- and fault-proneness , 2011, Empirical Software Engineering.

[59]  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.

[60]  Amin Milani Fard,et al.  JSNOSE: Detecting JavaScript Code Smells , 2013, 2013 IEEE 13th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[61]  Gabriele Bavota,et al.  An empirical investigation into the nature of test smells , 2016, 2016 31st IEEE/ACM International Conference on Automated Software Engineering (ASE).

[62]  Houari A. Sahraoui,et al.  A Cooperative Parallel Search-Based Software Engineering Approach for Code-Smells Detection , 2014, IEEE Transactions on Software Engineering.

[63]  Shari Lawrence Pfleeger,et al.  Software Metrics : A Rigorous and Practical Approach , 1998 .