Unveiling Code Smells: A Machine Learning-Based Approach for Improved Software Development and Maintenance
摘要
In software development, code smells introduce challenges in program quality, readability, and maintainability. This study explores the integration of machine learning (ML) techniques for automated code smell detection. In this study, a diverse dataset of software metrics is being used. It is implemented thorough preprocessing in order to handle missing values and remove redundant features, outliers, and class imbalances. Three feature selection techniques are evaluated in this study. These techniques are correlation-based, select from model, and recursive feature elimination. Four classifiers are introduced alongside these feature selection techniques, such as random forest, bagging, KNN, and XGBoost. After comparing the performance of these models, specifically random forest and XGBoost, we achieve accuracy rates exceeding 80%, which aligns with previous researches (Dewangan et al. in Appl Sci 12:10,321, 2022; Di Nucci, D., Palomba, F., Tamburri, D. A., Serebrenik, A., & De Lucia, A. (2018). “Detecting Code Smells using Machine Learning Techniques: Are We There Yet?” 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER) https://doi.org/10.1109/SANER.2018.8330266.;Guggulothu and Abdul Moiz in Software Qual J 28:1063–1086, 2020;). The bagging classifier reflects the findings and patters of the existing research trends (Fontana, F. A., Zanoni, M., Marino, A., & Mäntylä, M. V. (2013). “Code Smell Detection: Towards a Machine Learning-based Approach.” 2013 IEEE International Conference on Software Maintenance https://doi.org/10.1109/ICSM.2013.56 ). Strategic feature selection is also pivotal and guided by knowledge from Grujić et al. (Grujić, K.-G., Prokić, S., Kovačević, A., Luburić, N., Vidaković, D., & Slivka, J. (Year). “Machine Learning Techniques for Code Smell Detection: A Systematic Literature Review and Meta-analysis.” Information and Software Technology, Volume 108, April 2019, Pages 115–138. DOI: https://doi.org/10.1016/j.infsof.2018.12.00 ). In spite of some challenges, this study offers practical implications for software developers. This implication helps to emphasize the visible benefits of incorporating smart machine learning tools. This helps to improve the code quality. This study is not only focused about code, rather than it is a complete roadmap for real-world developers who seeks enhanced code quality through the strategic integration of machine learning methodologies.