arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2101.02518cs.SE
收藏

实现代码评审活动的自动化

Towards Automating Code Review Activities

Rosalia Tufano, Luca Pascarella, Michele Tufano, Denys Poshyvanyk, Gabriele Bavota

摘要:

代码审查在工业和开源项目中都很流行。代码审查的好处被广泛认可,包括更好的代码质量和更低的引入bug的可能性。然而,由于代码审查是一项手动活动,因此开发人员需要花费时间审查其团队成员的代码。我们的目标是朝着部分自动化代码审查流程迈出第一步,从而可能减少与之相关的手动成本。我们通过训练两种不同的深度学习架构,关注流程的贡献者和审查者。第一个学习开发人员在实际代码评审活动中执行的代码更改,从而在代码提交评审之前,为贡献者提供其代码的修订版本,实现通常在代码评审期间推荐的代码转换。第二种方法自动为审阅者提供对提交的代码的评论,并将其修改后的代码实现为以自然语言表达的评论。对这两个模型的实证评估表明,在贡献者方面,训练好的模型在高达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.

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

↑