Skip to main content

Automatic Human-Like Detection of Code Smells

  • Conference paper
  • First Online:
Discovery Science (DS 2021)

Abstract

Many code smell detection techniques and tools have been proposed, mainly aiming to eliminate design flaws and improve software quality. Most of them are based on heuristics which rely on a set of software metrics and corresponding threshold values. Those techniques and tools suffer from subjectivity issues, discordant results among the tools, and the reliability of the thresholds. To mitigate these problems, we used machine learning to automate developers’ perception in code smells detection. Different from other existing machine learning used in code smell detection we trained our models with an extensive dataset based on more than 3000 professional reviews on 518 open source projects. We conclude by an empirical evaluation of the performance of the machine learning approach against PMD, a widely used metric-based code smell detection tool for Java. The experimental results show that the machine learning approach outperforms the PMD classifier in all evaluations.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Amorim, L., Costa, E., Antunes, N., et al.: Experience report: evaluating the effectiveness of decision trees for detecting code smells. In: 2015 IEEE 26th International Symposium on ISSRE, pp. 261–269. IEEE (2015)

    Google Scholar 

  2. Azeem, M.I., Palomba, F., Shi, L., et al.: Machine learning techniques for code smell detection: a systematic literature review and meta-analysis. Inf. Softw. Technol. 108, 115–138 (2019)

    Article  Google Scholar 

  3. Breiman, L.: Random forests. Mach. Learn. 45(1), 5–32 (2001)

    Article  Google Scholar 

  4. Chidamber, S.R., Kemerer, C.F.: Towards a metrics suite for object oriented design. In: Conference Proceedings on Object-Oriented Programming Systems, Languages, and Applications, pp. 197–211 (1991)

    Google Scholar 

  5. Di Nucci, D., Palomba, F., Tamburri, D.A., et al.: Detecting code smells using machine learning techniques: are we there yet? In: 2018 IEEE 25th International Conference on SANER, pp. 612–621. IEEE (2018)

    Google Scholar 

  6. Elkhail, A.A., Cerny, T.: On relating code smells to security vulnerabilities. In: 2019 IEEE 5th International Conference on BigDataSecurity, IEEE International Conference on HPSC, and IEEE International Conference on IDS, pp. 7–12. IEEE (2019)

    Google Scholar 

  7. Fernandes, E., Oliveira, J., Vale, G., et al.: A review-based comparative study of bad smell detection tools. In: Proceedings of the 20th International Conference on Evaluation and Assessment in Software Engineering, pp. 1–12 (2016)

    Google Scholar 

  8. Arcelli Fontana, F., Mäntylä, M.V., Zanoni, M., et al.: Comparing and experimenting machine learning techniques for code smell detection. Empir. Softw. Eng. 21, 1143–1191 (2016). https://doi.org/10.1007/s10664-015-9378-4

  9. Fontana, F.A., Zanoni, M.: Code smell severity classification using machine learning techniques. Knowl. Based Syst. 128, 43–58 (2017)

    Article  Google Scholar 

  10. Fowler, M., Beck, K., Brant, W., et al.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co. Inc., Boston, USA (1999)

    Google Scholar 

  11. Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional (2018)

    Google Scholar 

  12. Kamaraj, N., Ramani, A.: Search-based software engineering approach for detecting code-smells with development of unified model for test prioritization strategies. Int. J. Appl. Eng. Res. 14(7), 1599–1603 (2019)

    Google Scholar 

  13. Kaur, A., Jain, S., Goel, S., et al.: A review on machine-learning based code smell detection techniques in object-oriented software system(s). Recent Adv. Electr. Electron. Eng. 2021(14), 290–303 (2021)

    Google Scholar 

  14. Kreimer, J.: Adaptive detection of design flaws. Electron. Notes Theoret. Comput. Sci. 141(4), 117–136 (2005)

    Article  Google Scholar 

  15. Lanza, M., Marinescu, R.: Object-Oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems. Springer, Heidelberg (2006). https://doi.org/10.1007/3-540-39538-5

    Book  MATH  Google Scholar 

  16. Liu, H., Jin, J., Xu, Z., et al.: Deep learning based code smell detection. IEEE Trans. Softw. Eng. 47, 1811–1837 (2019)

    Google Scholar 

  17. Madeyski, L., Lewowski, T.: MLCQ: industry-relevant code smell data set. In: Proceedings of the Evaluation and Assessment in Software Engineering, pp. 342–347 (2020)

    Google Scholar 

  18. Martin, R.C.: Clean Code: A Handbook of Agile Software Craftsmanship, 1st edn. Prentice Hall, USA (2008)

    Google Scholar 

  19. Paiva, T., Damasceno, A., Figueiredo, E., Sant’Anna, C.: On the evaluation of code smells and detection tools. J. Softw. Eng. Res. Develop. 5(1), 1–28 (2017). https://doi.org/10.1186/s40411-017-0041-1

    Article  Google Scholar 

  20. Pecorelli, F., Palomba, F., Khomh, F., et al.: Developer-driven code smell prioritization. In: Proceedings of the the 17th International Conference on MSR, pp. 220–231 (2020)

    Google Scholar 

  21. Pedregosa, F., Varoquaux, G., Gramfort, A., et al.: Scikit-learn: machine learning in Python. J. Mach. Learn. Res. 12, 2825–2830 (2011)

    MathSciNet  MATH  Google Scholar 

  22. PMD: an extensible cross-language static code analyzer. https://pmd.github.io. Accessed 31 May 2021

  23. Quinlan, J.R.: Learning decision tree classifiers. ACM Comput. Surv. (CSUR) 28(1), 71–72 (1996)

    Article  Google Scholar 

  24. Rasool, G., Arshad, Z.: A review of code smell mining techniques. J. Softw. Evol. Process 27(11), 867–895 (2015)

    Article  Google Scholar 

  25. Santos, J.A.M., Rocha-Junior, J.B., Prates, L.C.L., et al.: A systematic review on the code smell effect. J. Syst. Softw. 144, 450–477 (2018)

    Article  Google Scholar 

  26. Understand by SciTools. https://www.scitools.com/. Accessed 31 May 2021

  27. Sharma, T., Efstathiou, V., Louridas, P., et al.: Code smell detection by deep direct-learning and transfer-learning. J. Syst. Softw. 176, 110936 (2021)

    Article  Google Scholar 

  28. Sirikul, K., Soomlek, C.: Automated detection of code smells caused by null checking conditions in Java programs. In: 2016 13th International Joint Conference on Computer Science and Software Engineering (JCSSE), pp. 1–7. IEEE (2016)

    Google Scholar 

  29. Vanschoren, J., Van Rijn, J.N., Bischl, B., Torgo, L.: OpenML: networked science in machine learning. ACM SIGKDD Expl. Newsl. 15(2), 49–60 (2014)

    Article  Google Scholar 

  30. Yamashita, A., Moonen, L.: To what extent can maintenance problems be predicted by code smell detection? An empirical study. Inf. Softw. Technol. 55(12), 2223–2242 (2013)

    Article  Google Scholar 

Download references

Acknowledgements

We would like to thank Khon Kaen University for awarding KKU Outbound Visiting Scholarship to the first author.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Chitsutha Soomlek .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Soomlek, C., van Rijn, J.N., Bonsangue, M.M. (2021). Automatic Human-Like Detection of Code Smells. In: Soares, C., Torgo, L. (eds) Discovery Science. DS 2021. Lecture Notes in Computer Science(), vol 12986. Springer, Cham. https://doi.org/10.1007/978-3-030-88942-5_2

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-88942-5_2

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-88941-8

  • Online ISBN: 978-3-030-88942-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics