paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Do bugs lead to unnaturalness of source code?

缺陷会导致源代码的不自然性吗?
FSE Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2022匹配度 2/10 · 该论文研究代码自然性与缺陷修复的关系,属于经验软件工程/缺陷检测方向,与用户关注的静态分析、LLM/Agent 程序分析、浮点程序分析和贝叶斯程序分析均无直接关联。虽然涉及基于自然性的缺陷行检测,但并非形式化验证、Agentic 程序或 LLM 改进静态分析等核心方向。引用 8 inbox
Yanjie Jiang, Hui Liu, Yuxia Zhang, Weixing Ji, Hao Zhong, Lu Zhang
crossref: 2026-09-12

AI 速览

一句话:重新审视缺陷代码的自然性,发现修复缺陷并不能显著提升代码自然性,基于自然性的缺陷行检测精度极低。

该文重新考察“缺陷代码是否更不自然”以及缺陷修复对源代码自然性的影响。与既有工作不同,作者使用两个大规模、高质量缺陷仓库,并显式排除修复提交中与缺陷无关的改动,从而更准确地比较缺陷行与无缺陷行。评估确认缺陷行通常比无缺陷行更不自然;但修复缺陷后,相关代码行的自然性并未显著提高,修复后的行平均仍与缺陷行同样不自然。因此,缺陷并非源代码不自然性的根本原因,仅依据自然性识别缺陷代码行可能不准确。实验还表明,基于自然性的缺陷行检测精度极低,不足 1%。

问题
研究缺陷代码是否比无缺陷代码更不自然,以及缺陷修复能否提升相关代码的自然性,并检验基于自然性的缺陷行检测是否有效。
方法
使用两个大规模高质量缺陷仓库,排除修复提交中与缺陷无关的改动,比较缺陷行与无缺陷行、修复前后代码行的自然性。
评估
评估发现缺陷行通常更不自然,但修复后相关代码行自然性未显著提升,基于自然性的缺陷行检测精度不足 1%。
原文摘要(Abstract)

Texts in natural languages are highly repetitive and predictable because of the naturalness of natural languages. Recent research validated that source code in programming languages is also repetitive and predictable, and naturalness is an inherent property of source code. It was also reported that buggy code is significantly less natural than bug-free one, and bug fixing substantially improves the naturalness of the involved source code. In this paper, we revisit the naturalness of buggy code and investigate the effect of bug-fixing on the naturalness of source code. Different from the existing investigation, we leverage two large-scale and high-quality bug repositories where bug-irrelevant changes in bug-fixing commits have been explicitly excluded. Our evaluation results confirm that buggy lines are often less natural than bug-free ones. However, fixing bugs could not significantly improve the naturalness of involved code lines. Fixed lines on average are as unnatural as buggy ones. Consequently, bugs are not the root cause of the unnaturalness of source code, and it could be inaccurate to identify buggy code lines solely by the naturalness of source code. Our evaluation results suggest that the naturalness-based buggy line detection results in extremely low precision (less than one percentage).

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6991,
  title = {Do bugs lead to unnaturalness of source code?},
  author = {Yanjie Jiang and Hui Liu and Yuxia Zhang and Weixing Ji and Hao Zhong and Lu Zhang},
  booktitle = {FSE},
  year = {2022},
  doi = {10.1145/3540250.3549149}
}