paperbot · PL 论文追踪

全部论文 待读 收藏

P2 iSMELL: Assembling LLMs with Expert Toolsets for Code Smell Detection and Refactoring

iSMELL:结合专家工具集与大语言模型进行代码异味检测与重构
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 3/10 · 论文属于 LLM+软件工程中的代码异味检测与重构,虽涉及“静态分析工具与 LLM 结合”,但落点是“用专家工具增强 LLM 的重构能力”,与用户三条主线(面向 ML/Agentic 程序的静态分析、用 LLM/Agent 改进静态分析与形式化验证、浮点/贝叶斯程序分析)均不重合,且缺乏形式化理论支撑。引用 61 inbox
Di Wu, Fangwen Mu, Lin Shi, Zhaoqiang Guo, Kui Liu, Weiguang Zhuang, Yuqi Zhong, Li Zhang
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 iSMELL,用专家混合(MoE)为代码异味选择合适专家工具,并用检测结果增强 LLM 重构能力。

代码异味检测与重构耗时且需持续维护。LLM 能识别部分异味,但受限于 token 长度、难以访问仓库级知识及动态分析;现有专家工具虽能深入分析项目,却仅针对固定异味,缺乏灵活性。为此,提出 iSMELL:基于专家混合(MoE)的集成方法,训练 MoE 模型根据代码向量为每类异味选择最合适的专家工具,再用检测结果增强 LLM 提示以指导重构。在 Refused Bequest、God Class 和 Feature Envy 三类复杂异味上,使用七种专家工具,iSMELL 检测平均 F1 达 75.17%,较 LLM 基线提升 35.05%。定量与人工评估表明,增强后的 LLM 可提升代码质量指标并完成令人满意的重构。

问题
LLM 在代码异味检测上受 token 限制、缺乏仓库级知识与动态分析能力;现有专家工具虽能处理复杂异味但仅支持固定类型,缺乏灵活性与可扩展性。
方法
提出 iSMELL,用 MoE 架构集成多种代码异味检测专家工具:训练 MoE 模型根据代码向量为每类异味选择最合适的专家工具,获取检测结果后将其加入提示以增强 LLM 的重构能力。
评估
在 Refused Bequest、God Class、Feature Envy 三类经典复杂异味上,使用七种专家工具进行评估;检测平均 F1 为 75.17%,较 LLM 基线提升 35.05%,并通过定量指标与人工评估验证重构效果。
原文摘要(Abstract)

Detecting and refactoring code smells is challenging, laborious, and sustaining. Although large language models have demonstrated potential in identifying various types of code smells, they also have limitations such as input-output token restrictions, difficulty in accessing repository-level knowledge, and performing dynamic source code analysis. Existing learning-based methods or commercial expert toolsets have advantages in handling complex smells. They can analyze project structures and contextual information in-depth, access global code repositories, and utilize advanced code analysis techniques. However, these toolsets are often designed for specific types and patterns of code smells and can only address fixed smells, lacking flexibility and scalability. To resolve that problem, we propose iSMELL, an ensemble approach that employs various code smell detection toolsets via Mixture of Experts (MoE) architecture for comprehensive code smell detection, and enhances the LLMs with the detection results from expert toolsets for refactoring those identified code smells. First, we train a MoE model that, based on input code vectors, outputs the most suitable expert tool for identifying each type of smell. Then, we select the recommended toolsets for code smell detection and obtain their results. Finally, we equip the prompts with the detection results from the expert toolsets, thereby enhancing the refactoring capability of LLMs for code with existing smells, enabling them to provide different solutions based on the type of smell. We evaluate our approach on detecting and refactoring three classical and complex code smells, i.e., Refused Bequest, God Class, and Feature Envy. The results show that, by adopting seven expert code smell toolsets, iSMELL achieved an average F1 score of 75.17% on code smell detection, outperforming LLMs baselines by an increase of 35.05% in F1 score. We further evaluate the code refactored by the enhanced LLM. The quantitative and human evaluation results show that iSMELL could improve code quality metrics and conduct satisfactory refactoring toward the identified code smells. We believe that our proposed solution could provide new insights into better leveraging LLMs and existing approaches to resolving complex software tasks.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{WuM0G0ZZ024,
  title = {iSMELL: Assembling LLMs with Expert Toolsets for Code Smell Detection and Refactoring},
  author = {Di Wu and Fangwen Mu and Lin Shi and Zhaoqiang Guo and Kui Liu and Weiguang Zhuang and Yuqi Zhong and Li Zhang},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695508}
}