arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2607.01867cs.SEcs.AI
收藏

关于LLM生成的代码和注释在代码仓库中的探索性研究

An Exploratory Study on LLM-Generated Code and Comments in Code Repositories

School of Computing and Mathematical Sciences, University of Leicester(利兹大学计算与数学科学学院)

Yongyi Ji, Jiaji Wang, Yi Zhou, Fuxiang Chen, Hongji Yang

AI总结:

本研究通过检测工具分析2021-2025年公司和社区维护的仓库,发现LLM生成的代码随时间减少且多出现在测试用例中,注释则相对稳定;公司仓库中LLM生成内容比例更高,且仅少数人工标记的bug与LLM生成代码相关。

摘要:

LLM在软件开发中的应用日益广泛,特别是在代码生成和摘要等任务上。大型科技公司的报告显示,其约20%至30%的代码由LLM生成。然而,对于LLM生成的代码和注释的实际使用仍存在质疑,例如对调试生成代码需要更多时间以及生成注释不自然的担忧。在本文中,我们研究了被检测为可能由LLM生成的代码和注释及其特征、公司和社区维护仓库之间的差异,以及bug与LLM生成代码的关联可能性。我们使用多种检测LLM生成代码和注释的工具和技术,对2021年至2025年间活跃的公司和社区维护仓库进行了广泛实验。基于检测器的代理分析结果表明,被检测为可能由LLM生成的代码随时间减少,并频繁出现在测试用例中,而注释则保持相对稳定。代理结果进一步表明,被检测为可能由LLM生成的代码在仓库内部存在大量代码克隆,而注释中语法正确的句子比例较低。此外,公司维护的仓库中被检测为可能由LLM生成的代码和注释比例更高,且仅有一小部分人工标记的bug被检测为可能与LLM生成的代码相关。

英文摘要:

The use of LLMs in software development has become increasingly widespread on tasks such as code generation and summarization. Reports from large technology companies showed that around 20% to 30% of their code are generated by LLMs. However, there remains skepticism about the practical usage of LLM-generated code and comments, such as concerns on more time for debugging the generated code and the unnaturalness of the generated comments. In this paper, we study the code and comments detected as likely to be generated by LLMs and their characteristics, the differences between company- and community-maintained repositories, and how likely bugs are associated with LLM-generated code. We conduct extensive experiments on active company- and community-maintained repositories from 2021 to 2025 using various tools and techniques that detect code and comments generated by LLMs. Based on our detector-based proxy analysis, the results suggest that code detected as likely to be generated by LLMs decreased over time and appeared frequently in test cases, while that of comments remains relatively stable. Proxy results further suggest that code detected as likely to be generated by LLMs shows substantial intra-repository code clones, whereas comments exhibit a relatively low proportion of grammatically correct sentences. In addition, the company-maintained repositories show a higher percentage of code and comments detected as likely to be generated by LLMs, and only a small percentage of the human-labelled bugs are detected as being likely associated with LLM-generated code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑