When and Why Your Code Starts to Smell Bad (and Whether the Smells Go Away)

  • ,
  • Fabio Palomba ,
  • Gabriele Bavota ,
  • Rocco Oliveto ,
  • Massimiliano Di Penta ,
  • Andrea De Lucia ,
  • Denys Poshyvanyk

IEEE Transactions on Software Engineering | , Vol 43(11): pp. 1063-1088

Publication | Publication | Publication | Publication | Publication

Technical debt is a metaphor introduced by Cunningham to indicate “not quite right code which we postpone making it right”. One noticeable symptom of technical debt is represented by code smells, defined as symptoms of poor design and implementation choices. Previous studies showed the negative impact of code smells on the comprehensibility and maintainability of code. While the repercussions of smells on code quality have been empirically assessed, there is still only anecdotal evidence on when and why bad smells are introduced, what is their survivability , and how they are removed by developers. To empirically corroborate such anecdotal evidence, we conducted a large empirical study over the change history of 200 open source projects. This study required the development of a strategy to identify smell-introducing commits, the mining of over half a million of commits, and the manual analysis and classification of over 10K of them. Our findings mostly contradict common wisdom, showing that most of the smell instances are introduced when an artifact is created and not as a result of its evolution. At the same time, 80 percent of smells survive in the system. Also, among the 20 percent of removed instances, only 9 percent are removed as a direct consequence of refactoring operations.