Enhancing LLM‐Based Code Smell Prediction Using Empirical Detection Strategies
Abstract
Code smells are indicators of poor design that hinder software maintainability. While existing detection methods range from rule‐based to machine‐learning approaches, they often struggle with generalizability and feature engineering issues. Recent attempts using large language models (LLMs) with simple prompts have shown limited success. This study proposes a novel framework that systematically integrates classic, empirically validated code smell detection strategies with LLMs through strategy‐level and ensemble prompt engineering. Evaluated on a refined version of the MLCQ data set, our framework demonstrates superior performance compared to state‐of‐the‐art classical machine learning, deep learning, and basic LLM approaches across key code smells including God Class, Feature Envy, Data Class, and Long Method. The results highlight the significant advantage of leveraging structured software engineering knowledge to guide LLM reasoning for more accurate and reliable code smell detection.