人工智能繁荣背后的债务:对真实世界中AI生成代码的大规模实证研究
Debt Behind the AI Boom: A Large-Scale Empirical Study of AI-Generated Code in the Wild
AI总结:
本文研究了AI生成代码在真实软件项目中的技术债务影响,发现代码异味是最常见的问题,且部分问题长期存在,凸显了AI辅助开发中质量保障的必要性。
摘要:
AI编码助手如今广泛应用于软件开发。软件开发者越来越多地将AI生成的代码整合到代码库中以提高生产力。先前研究显示,在受控环境下,AI生成的代码可能包含代码质量问题。然而,我们对AI生成代码在引入生产仓库后对软件质量和维护的真实世界影响了解甚少。换句话说,不清楚这些问题是否被迅速修复或在时间推移中积累成技术债务。在本文中,我们对AI编码助手在真实世界中引入的技术债务进行了大规模实证研究。为此,我们构建了一个包含302.6万次已验证的AI作者提交记录的数据集,涵盖6299个GitHub仓库,覆盖了五种广泛使用的AI编码助手。对于每个提交,我们运行静态分析,以精确归因AI引入的代码异味、正确性问题和安全问题。然后我们跟踪每个引入的问题从提交到最新仓库修订的生命周期。我们的结果表明,我们识别了484,366个不同的问题,其中代码异味是最常见的类型,占所有问题的89.3%。我们还发现,每种AI编码助手的提交中,超过15%的提交至少引入一个问题,尽管不同工具之间存在差异。更重要的是,22.7%的跟踪AI引入的问题在最新版本的仓库中仍然存在。这些发现表明,AI生成的代码可能向真实软件项目引入长期维护成本,并突显了在AI辅助开发中加强质量保证的必要性。
英文摘要:
AI coding assistants are now widely used in software development. Software developers increasingly integrate AI-generated code into their codebases to improve productivity. Prior studies have shown that AI-generated code may contain code quality issues under controlled settings. However, we still know little about the real-world impact of AI-generated code on software quality and maintenance after it is introduced into production repositories. In other words, it remains unclear whether such issues are quickly fixed or persist and accumulate over time as technical debt. In this paper, we conduct a large-scale empirical study on the technical debt introduced by AI coding assistants in the wild. To achieve that, we built a dataset of 302.6k verified AI-authored commits from 6,299 GitHub repositories, covering five widely used AI coding assistants. For each commit, we run static analysis before and after the change to precisely attribute which code smells, correctness issues, and security issues the AI introduced. We then track each introduced issue from the introducing commit to the latest repository revision to study its lifecycle. Our results show that we identified 484,366 distinct issues, and that code smells are by far the most common type, accounting for 89.3% of all issues. Between 7.5% and 14.8% of each assistant's commits introduce at least one issue. More importantly, 22.7% of tracked AI-introduced issues still survive at the latest version of the repository. These findings show that AI-generated code can introduce long-term maintenance costs into real software projects and highlight the need for stronger quality assurance in AI-assisted development.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。