一句话:提出 VS Code 扩展 SmellCC,结合 SonarQube 与 LLM 流水线,一键检测并重构 Python 代码坏味道。
代码坏味道会累积技术债、威胁软件可维护性,但开发者在紧张的发布周期下往往无力手工重构;SonarQube 等静态分析工具虽能精确检测,却只是被动告警,重构负担仍落在开发者身上。为弥补这一缺口,本文提出 SmellCC——一个 Visual Studio Code 扩展,在 SonarQube 之上叠加基于 LLM 的流水线,自动检测并重构 Python 代码坏味道。该方法采用思维链(CoT)与少样本学习,针对最高频的 10 类坏味道提供就地、一键式修复,力图在开发过程中阻止技术债积累。定量评估表明其清理率达 96.8%、准确率 91.3%,重构后的代码保持语法正确且行为等价,从而显著提升长期可维护性。本文重点在于将此前发表于 TOSEM 的离线大规模语料清理流水线,重新实现为把 IDE 内 SonarQube 诊断转化为交互式就地重构动作的 IDE 原生工具。
Code smells significantly threaten software maintainability by accumulating technical debt, yet developers often lack the resources to manually address these flaws under tight release schedules. While static analysis tools like SonarQube provide precise detection, they function largely as passive alert systems, leaving the burden of refactoring on developers. To bridge this gap, we present a novel cleaning tool, namely SmellCC, a Visual Studio Code extension that augments SonarQube with an LLM-based pipeline to automatically detect and refactor Python code smells. By employing Chain-of-Thought (CoT) and few-shot learning, SmellCC provides in-place, one-click remediation for the top-10 most frequent smells, effectively preventing the accumulation of technical debt during development. Our quantitative evaluation demonstrates that our is promising in helping developers effectively eliminate code smells (96.8% cleaning rate) with high accuracy (i.e., 91.3%), ensuring that the refactored code remains syntactically correct and behavior-preserving, thereby significantly improving long-term software maintainability. The full paper underlying this tool has been published in ACM Transactions on Software Engineering and Methodology, where SmellCC was introduced and evaluated as an offline pipeline for large-scale code corpus cleaning. Extending this prior work, the present paper focuses on an IDE-native implementation of SmellCC that translates SonarQube for IDE diagnostics into interactive, in-place refactoring actions within Visual Studio Code.