Dynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process

dc.contributor.authorKuanyshev, Emir
dc.date.accessioned2025-05-05T10:34:45Z
dc.date.available2025-05-05T10:34:45Z
dc.date.issued2025
dc.description.abstractRefactoring 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.
dc.identifier.citationKuanyshev, E. (2025). Dynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process. Nazarbayev University School of Engineering and Digital Sciences.
dc.identifier.urihttps://nur.nu.edu.kz/handle/123456789/8432
dc.language.isoen
dc.publisherNazarbayev University School of Engineering and Digital Sciences
dc.rightsAttribution-NonCommercial-NoDerivs 3.0 United Statesen
dc.rights.urihttp://creativecommons.org/licenses/by-nc-nd/3.0/us/
dc.subjectCustom Code Smell Detection Tool
dc.subjectChain-of-Thought (CoT) Prompting for Code Refactoring
dc.subjectRefactoring LLM Temperature
dc.subjectLLM-Powered Code Refactoring
dc.subjecttype of access: embargo
dc.titleDynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process
dc.typeMaster`s thesis

Files

Original bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
Dynamic Code Smell Detection and Correction Using Large Language Models for Automated Refactoring Process.pdf
Size:
11.79 MB
Format:
Adobe Portable Document Format
Description:
Master's Thesis
Access status: Embargo until 2027-01-01 , Download