Code smells are indicators of suboptimal design that negatively impact software quality. However, automated code smell detection remains a persistent challenge: heuristics-based tools suffer from high sensitivity to threshold selection and inherent subjectivity, while Machine Learning (ML) and Deep Learning (DL) models yield unsatisfactory performance. Although Large Language Models (LLMs) offer a promising solution to these limitations, their adaptation is impeded by the prohibitive cost of full fine-tuning and the lack of “LM-ready” benchmarks, as existing code smell datasets largely rely on software metrics or contain noisy, unverified labels. To address these gaps and enable a rigorous assessment of efficient LLM adaptation for code smell detection, we present a comprehensive study comprising two synergistic contributions. First, we constructed a high-quality, source-code-centric benchmark covering four non-trivial code smells—Complex Conditional, Complex Method, Feature Envy, and Data Class—and ensured its reliability through a meticulous two-stage manual review. Second, leveraging this benchmark, we systematically evaluated the effectiveness of four Parameter-Efficient Fine-Tuning (PEFT) methods (i.e., prompt tuning, prefix tuning, LoRA, and \((IA)^{3}\) ) across four Small LMs (SLMs) and five LLMs. We benchmarked these PEFT-tuned LMs against a broad suite of baselines, including traditional heuristics-based detectors (DesigniteJava and PMD), DL-based approaches (DeepSmells and AE-Dense), and cutting-edge general-purpose LLMs (GPT-4o-mini and DeepSeek-v3) with In-Context Learning. Our results demonstrate that PEFT methods match or exceed full fine-tuning performance while significantly reducing peak GPU memory usage, and outperform all baselines with MCC improvements ranging from 0.33% to 13.69%, particularly for some code smells. Furthermore, we provide actionable insights into the choice of PEFT method for code smell detection, which should be guided by the model used, data availability, and computational resources. Our replication package is available at [1] to support reproducibility and future extensions.
Paper
References (100)
Scroll for more · 38 remaining