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

通过大规模预培训自动化代码审查活动

Automating Code Review Activities by Large-Scale Pre-training

Peking University(北京大学);Microsoft Research Asia(微软亚洲研究院);Sun Yat-sen University(中山大学);LinkedIn(领英);Microsoft DevDiv(微软开发者事业部)

Zhiyu Li, Shuai Lu, Daya Guo, Nan Duan, Shailesh Jannu, Grant Jenks, Deep Majumder, Jared Green, Alexey Svyatkovskiy, Shengyu Fu, Neel Sundaresan

摘要:

代码评审是软件开发生命周期的重要组成部分,其目的是保证代码的质量。现代代码审查活动需要开发人员查看,理解甚至运行程序,以评估逻辑,功能,延迟,风格和其他因素。事实证明,开发人员不得不花费太多的时间来审查同行的代码。因此,对代码审查过程自动化的需求很大。在这项研究中,我们专注于利用预训练技术的任务,在代码审查的情况下。我们收集了一个大规模的真实世界的代码更改和代码审查的数据集,这些代码来自九种最流行的程序设计语言的开源项目。为了更好地理解代码差异和审查,我们提出了CodeReviewer,这是一个预先训练的模型,它利用了专门为代码审查场景定制的四个预先训练任务。为了评估我们的模型,我们集中在三个关键任务相关的代码审查活动,包括代码变更质量估计,审查意见的生成和代码细化。此外,我们还针对这三个任务建立了一个高质量的基准数据集,并对其进行了全面的实验,实验结果表明,我们的模型在所有任务中的性能都优于以前最先进的预训练方法。进一步的分析表明,我们提出的预训练任务和多语言预训练数据集有利于模型对代码更改和审查的理解。

英文摘要:

Code review is an essential part to software development lifecycle since it aims at guaranteeing the quality of codes. Modern code review activities necessitate developers viewing, understanding and even running the programs to assess logic, functionality, latency, style and other factors. It turns out that developers have to spend far too much time reviewing the code of their peers. Accordingly, it is in significant demand to automate the code review process. In this research, we focus on utilizing pre-training techniques for the tasks in the code review scenario. We collect a large-scale dataset of real-world code changes and code reviews from open-source projects in nine of the most popular programming languages. To better understand code diffs and reviews, we propose CodeReviewer, a pre-trained model that utilizes four pre-training tasks tailored specifically for the code review scenario. To evaluate our model, we focus on three key tasks related to code review activities, including code change quality estimation, review comment generation and code refinement. Furthermore, we establish a high-quality benchmark dataset based on our collected data for these three tasks and conduct comprehensive experiments on it. The experimental results demonstrate that our model outperforms the previous state-of-the-art pre-training approaches in all tasks. Further analysis show that our proposed pre-training tasks and the multilingual pre-training dataset benefit the model on the understanding of code changes and reviews.

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

↑