一句话:训练两个深度学习模型分别自动化代码评审的贡献者端与评审者端:提交前自动施加评审式代码变换,并按自然语言评论改写代码。
代码评审在工业界与开源项目中广泛使用,能提升代码质量、降低引入缺陷的概率,但作为一种人工活动,它需要开发者花费大量时间审阅同伴的代码。本文迈出部分自动化代码评审的第一步,从贡献者与评审者两个角度分别训练深度学习模型:第一个模型学习开发者在真实评审活动中所做的代码修改,从而在代码提交评审之前就向贡献者给出融入评审常见变换的修订版本;第二个模型接收评审者用自然语言写下的评论,自动生成实现该评论的修订代码。实证评估显示,贡献者端模型最多在 16% 的情况下能复现评审中实际应用的代码变换,评审者端模型最多在 31% 的情况下能正确实现自然语言评论。作者认为这些结果令人鼓舞,但要让模型真正为开发者所用仍需更多研究。
Code reviews are popular in both industrial and open source projects. The benefits of code reviews are widely recognized and include better code quality and lower likelihood of introducing bugs. However, since code review is a manual activity it comes at the cost of spending developers' time on reviewing their teammates' code. Our goal is to make the first step towards partially automating the code review process, thus, possibly reducing the manual costs associated with it. We focus on both the contributor and the reviewer sides of the process, by training two different Deep Learning architectures. The first one learns code changes performed by developers during real code review activities, thus providing the contributor with a revised version of her code implementing code transformations usually recommended during code review before the code is even submitted for review. The second one automatically provides the reviewer commenting on a submitted code with the revised code implementing her comments expressed in natural language. The empirical evaluation of the two models shows that, on the contributor side, the trained model succeeds in replicating the code transformations applied during code reviews in up to 16% of cases. On the reviewer side, the model can correctly implement a comment provided in natural language in up to 31% of cases. While these results are encouraging, more research is needed to make these models usable by developers.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2101-02518,
title = {Towards Automating Code Review Activities},
author = {Rosalia Tufano and Luca Pascarella and Michele Tufano and Denys Poshyvanyk and Gabriele Bavota},
booktitle = {ICSE},
year = {2021},
doi = {10.1109/icse43902.2021.00027}
}