Code smells are symptoms of potential code quality problems that may affect software maintainability, thus increasing development costs and impacting software reliability. Large language models (LLMs) have shown remarkable capabilities for supporting various software engineering activities, but their use for detecting code smells remains underexplored. However, unlike the rigid rules of static analysis tools, LLMs can support flexible and adaptable detection strategies tailored to the unique properties of code smells. This paper evaluates the effectiveness of four LLMs -- DeepSeek-R1, GPT-5 mini, Llama-3.3, and Qwen2.5-Code -- for detecting nine code smells across 30 Java projects. For the empirical evaluation, we created a ground-truth dataset by asking 76 developers to manually inspect 268 code-smell candidates. Our results indicate that LLMs perform strongly for structurally straightforward smells, such as Large Class and Long Method. However, we also observed that different LLMs and tools fare better for distinct code smells. We then propose and evaluate a detection strategy that combines LLMs and static analysis tools. The proposed strategy outperforms LLMs and tools in five out of nine code smells in terms of F1-Score. However, it also generates more false positives for complex smells. Therefore, we conclude that the optimal strategy depends on whether Recall or Precision is the main priority for code smell detection.


翻译:代码坏味是影响软件可维护性、增加开发成本并降低软件可靠性的潜在代码质量问题征兆。大型语言模型已在支持多种软件工程活动中展现出卓越能力,但其在代码坏味检测中的应用仍未得到充分探索。与静态分析工具的刚性规则不同,LLM能够根据代码坏味的独特属性支持灵活且自适应的检测策略。本文评估了四种LLM——DeepSeek-R1、GPT-5 mini、Llama-3.3和Qwen2.5-Code——在30个Java项目中检测九种代码坏味的效果。为进行实证评估,我们邀请了76名开发者手动检查268个候选代码坏味,构建了基准真相数据集。结果表明,LLM在结构简单的坏味(如过大类与过长方法)检测中表现优异。但我们也观察到不同LLM和工具对不同代码坏味的检测效果存在差异。基于此,我们提出并评估了一种结合LLM与静态分析工具的混合检测策略。在九种代码坏味中,该策略在F1分数上于五种坏味上优于单独使用LLM或工具的效果。然而,对于复杂坏味,该策略也会产生更多误报。因此,我们得出结论:最佳策略的选择取决于代码坏味检测的首要目标是召回率还是精确率。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
大型语言模型的规模效应局限
专知会员服务
14+阅读 · 2025年11月18日
大型语言模型系统中提示缺陷的分类学
专知会员服务
8+阅读 · 2025年9月19日
探索大型语言模型在网络安全中的作用:一项系统综述
专知会员服务
22+阅读 · 2025年4月27日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型在预测和异常检测中的应用综述
专知会员服务
70+阅读 · 2024年2月19日
大型语言模型公平性
专知会员服务
41+阅读 · 2023年8月31日
异常检测(Anomaly Detection)综述
极市平台
20+阅读 · 2020年10月24日
异常检测论文大列表:方法、应用、综述
专知
126+阅读 · 2019年7月15日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
1+阅读 · 今天14:45
定向能反无人机系统最新发展动态
专知会员服务
5+阅读 · 今天13:50
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
3+阅读 · 今天13:33
相关VIP内容
大型语言模型的规模效应局限
专知会员服务
14+阅读 · 2025年11月18日
大型语言模型系统中提示缺陷的分类学
专知会员服务
8+阅读 · 2025年9月19日
探索大型语言模型在网络安全中的作用:一项系统综述
专知会员服务
22+阅读 · 2025年4月27日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型在预测和异常检测中的应用综述
专知会员服务
70+阅读 · 2024年2月19日
大型语言模型公平性
专知会员服务
41+阅读 · 2023年8月31日
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员