Automatic Identification of Machine Learning-Specific Code Smells

  • Peter Hamfelt Roxtec Group
  • Ricardo Britto Ericsson / Blekinge Institute of Technology
  • Lincoln Rocha UFC
  • Camilo Almendra UFC

Resumo


Machine learning (ML) has rapidly grown in popularity, becoming vital to many industries. Currently, the research on code smells in ML applications lacks tools and studies that address the identification and validity of ML-specific code smells. This work investigates suitable methods and tools to design and develop a static code analysis tool (MLpylint) based on code smell criteria. This research employed the Design Science Methodology. In the problem identification phase, a literature review was conducted to identify ML-specific code smells. In solution design, a secondary literature review and consultations with experts were performed to select methods and tools for implementing the tool.We evaluated the tool on data from 160 open-source ML applications sourced from GitHub. We also conducted a static validation through an expert survey involving 15 ML professionals. The results indicate the effectiveness and usefulness of the MLpylint. We aim to extend our current approach by investigating ways to introduce MLpylint seamlessly into development workflows, fostering a more productive and innovative developer environment.

Palavras-chave: Code Smells, Machine Learning, Static Code Analysis, Software Quality, Technical Debt

Referências

Mohannad Alahdab and Gul Calikli. 2019. Empirical Analysis of Hidden Technical Debt Patterns in Machine Learning Software. Lecture Notes in Computer Science (11 2019), 195–202. DOI: 10.1007/978-3-030-35333-94

Farhan Alebeisat, Zaid Alhalhouli, Tamara Alshabatat, and T.I. Alrawashdeh. 2018. Review of Literature on Software Quality. 8 8 (2018), 32–42.

Nicolás Cardozo. 2023. Prevalence of code smells in reinforcement learning projects. [link]

Martin Fowler. 2002. Refactoring: improving the design of existing code. 256 pages. 31 DOI: 10.1007/3-540-45672-4\{_

J. Gesi, S. Liu, J. Li, I. Ahmed, N. Nagappan, D. Lo, E. S. De Almeida, P. S. Kochhar, and L. Bao. 2022. Code Smells in Machine Learning Systems. ArXiv (2022). [link]

Hristina Gulabovska and Zoltán Porkoláb. 2019. Towards More Sophisticated Static Analysis Methods of Python Programs. In 2019 IEEE 15th International Scientific Conference on Informatics. 000225–000230. DOI: 10.1109/Informatics47936.2019.9119307

Peter Hamfelt. 2023. MLpylint 0.0.3 – a static analysis tool for identifying MLspecific code smells. [link]

Peter Hamfelt. 2023. MLpylint: Automating the Identification of Machine Learning-Specific Code Smells. Master’s thesis. Blekinge Institute of Technology.

Peter Hamfelt. 2024. MLpylint – A static code analyzer tool for identifying ml-specific code smells. [link]

Peter Hamfelt. 2024. Pylint plugin enhancing code analysis for machine learning and data science. [link]

Peter Hamfelt, Ricardo Britto, Lincoln Rocha, and Camilo Almendra. 2025. Artifacts for “Automatic Identification of Machine Learning-Specific Code Smells”. DOI: 10.5281/zenodo.17054569.

Peter Kokol. 2022. Software Quality: How Much Does It Matter? Electronics 11, 16 (2022), 2485. DOI: 10.3390/electronics11162485

Guilherme Lacerda, Fabio Petrillo, Marcelo Soares Pimenta, and Yann Gaël Guéhéneuc. 2020. Code smells and refactoring: A tertiary systematic review of challenges and observations. Journal of Systems and Software 167 (9 2020), 110610. DOI: 10.1016/j.jss.2020.110610

Sharon L. Lohr. 2021. Sampling. DOI: 10.1201/9780429298899

Silverio Martínez-Fernández, Alberto Garcia-Perez, Xabier Larrucea, Miguel del Calvo-Flores, Pablo Garcia-Bringas, and Javier Tuya. 2022. Software Engineering for AI-Based Systems: A Survey. ACM Transactions on Software Engineering and Methodology 31, 2 (2022), 1–59. DOI: 10.1145/3487043

Rana S. Menshawy, Ahmed H. Yousef, and Ashraf Salem. 2021. Code Smells and Detection Techniques: A Survey. In 2021 International Mobile, Intelligent, and Ubiquitous Computing Conference (MIUCC). 78–83. DOI: 10.1109/MIUCC52538.2021.9447669

Edson Nascimento. 2020. Software engineering for artificial intelligence and machine learning software: A systematic literature review. arXiv preprint arXiv:2011.03751 (2020). DOI: 10.48550/arXiv.2011.03751

Philipp Offermann, Olga Levina, Marten Schönherr, and Udo Bub. 2009. Outline of a design science research process. In Proceedings of the 4th International Conference on Design Science Research in Information Systems and Technology (DESRIST ’09). ACM, New York, NY, USA, 1–11.

Thanis Paiva, Amanda Damasceno, Eduardo Figueiredo, and Cláudio Sant’Anna. 2017. On the evaluation of code smells and detection tools. Journal of Software Engineering Research and Development 5, 1 (10 2017). DOI: 10.1186/s40411-017-0041-1

Per Runeson and Martin Höst. 2009. Guidelines for Conducting and Reporting Case Study Research in Software Engineering. Empirical Softw. Engg. 14, 2 (apr 2009), 131–164. DOI: 10.1007/s10664-008-9102-8

D. Sculley, Gary David Holt, Daniel Golovin, Eugene Davydov, Todd Phillips, Dietmar Ebner, Vinay Chaudhary, Michael Young, Jean-Francois Crespo, and D.H. Dennison. 2015. Hidden technical debt in Machine learning systems. Neural Information Processing Systems 28 (12 2015), 2503–2511. [link]

Andrew J. Simmons, Scott Barnett, Jessica Rivera-Villicana, Akshat Bajaj, and Rajesh Vasa. 2020. A large-scale comparative analysis of Coding Standard conformance in Open-Source Data Science projects. In Proceedings of the 14th ACM / IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM) (ESEM ’20). Association for Computing Machinery, New York, NY, USA, 1–11. DOI: 10.1145/3382494.3410680

Bart van Oort, Leonardo Cruz, Maurício Aniche, and Arie van Deursen. 2021. The Prevalence of Code Smells in Machine Learning projects. In 2021 IEEE/ACM 1st Workshop on AI Engineering - Software Engineering for AI (WAIN) (Madrid, Spain). 1–8. DOI: 10.1109/WAIN52551.2021.00011

Zhi Wan, Xin Xia, David Lo, and Gail C Murphy. 2021. How does Machine Learning Change Software Development Practices? IEEE Transactions on Software Engineering 47, 9 (Sept 2021), 1857–1871. DOI: 10.1109/TSE.2019.2937083

JingWang, Raffi Khatchadourian, Mehdi Bagherzadeh, Rhia Singh, Ajani Stewart, and Anita Raja. 2021. An Empirical Study of Refactorings and Technical Debt in Machine Learning Systems. International Conference on Software Engineering (5 2021). DOI: 10.1109/icse43902.2021.00033

Claes Wohlin, Per Runeson, Martin Höst, Magnus C. Ohlsson, Björn Regnell, and Anders Wesslén. 2012. Experimentation in software engineering. DOI: 10.1007/978-3-642-29044-2

Hui Zhang, Luiz Angelo Da Silva Cruz, and Arie Van Deursen. 2022. Code Smells for Machine Learning Applications. DOI: 10.48550/arxiv.2203.13746 arXiv:2203.13746 [cs.SE]
Publicado
22/09/2025
HAMFELT, Peter; BRITTO, Ricardo; ROCHA, Lincoln; ALMENDRA, Camilo. Automatic Identification of Machine Learning-Specific Code Smells. In: SIMPÓSIO BRASILEIRO DE ENGENHARIA DE SOFTWARE (SBES), 39. , 2025, Recife/PE. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2025 . p. 337-347. ISSN 2833-0633. DOI: https://doi.org/10.5753/sbes.2025.9949.