一句话:提出面向代码审查的预训练模型 CodeReviewer 与四个预训练任务,在变更质量估计、评论生成和代码精化上取得最优结果。
代码审查是保障软件质量的关键环节,但开发者需要查看、理解甚至运行代码来评估逻辑、功能、延迟和风格等,耗时巨大,因此自动化需求迫切。本文收集九种最流行编程语言开源项目中的大规模真实代码变更与审查数据,提出 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.
DOI 原文 ·
@inproceedings{paperbot7144,
title = {Automating code review activities by large-scale pre-training},
author = {Zhiyu Li and Shuai Lu and Daya Guo and Nan Duan and Shailesh Jannu and Grant Jenks and Deep Majumder and Jared Green and Alexey Svyatkovskiy and Shengyu Fu and Neel Sundaresan},
booktitle = {FSE},
year = {2022},
doi = {10.1145/3540250.3549081}
}