Dynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process
Loading...
Files
Date
Authors
Journal Title
Journal ISSN
Volume Title
Publisher
Nazarbayev University School of Engineering and Digital Sciences
Abstract
Refactoring is essential for maintaining code base quality, readability, and scalability but poses challenges, especially for inexperienced developers. Recent advancements using Large Language Models (LLMs) offer promising automated refactoring solu- tions; however, current approaches often face limitations, such as restricted code smell coverage, manual intervention, lack of explainability, and language-specific con- straints. This study introduces a novel automated refactoring system utilizing a custom code smell detection tool capable of identifying and addressing 14 distinct code smells with extensibility for additional smells and languages. Through effective prompt engineering, the proposed LLM-based system reliably generates refactoring suggestions without unintended changes, and provides detailed explanations to en- hance developer trust. Empirical evaluations demonstrated the system’s practical effectiveness, achieving an average acceptance rate of 95%, an 83.96% reduction in code smells, and an average maintainability index improvement of 5.37 points.
This study addresses critical gaps in existing approaches by developing: (1) code smell detection service that can now cover 14 different code smells and can be easily extended. In addition, this research proposes that any programming language and code smell can be supported by such a system in the future. (2) LLM-based refactor- ing services can efficiently generate code refactoring without unexpected or unknown changes. Therefore, the system can easily explain any type of change without rely- ing on LLM knowledge; (3) detailed explanations of processed refactoring steps to increase developer trust; and (4) empirical evaluation of optimal LLM temperature to balance the deterministic and art areas of refactoring.
This research represents a significant advancement toward fully automating soft- ware refactoring with the potential to significantly improve code quality and developer productivity.
Description
Citation
Kuanyshev, E. (2025). Dynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process. Nazarbayev University School of Engineering and Digital Sciences.
Collections
Endorsement
Review
Supplemented By
Referenced By
Creative Commons license
Except where otherwised noted, this item's license is described as Attribution-NonCommercial-NoDerivs 3.0 United States
