arXiv:2409.10959cs.SEcs.LG2024-09中稿 · ACM Transactions o…综述被引 12

用开发者经验优化代码评审生成,让资深评审影响更大。

Leveraging Reviewer Experience in Code Review Comment Generation

  • 根据评审者过往贡献和评审记录,动态加权训练损失。
  • 相比现有最佳模型,生成评论更准确、信息量更高。
  • 适合想提升自动化评审质量的开发团队和研究者。

现代代码评审是保障软件质量的关键流程,但耗时费力。为减轻负担,研究者尝试用深度学习模型生成自然语言评审意见,即代码评审评论生成任务。尽管已有工作利用迁移学习和Transformer架构取得进展,但模型生成评论质量仍不理想,主要因训练数据来自开源项目中的公开评审,评审者经验水平参差,影响反馈质量。为此,本文提出一系列经验感知的训练方法,利用评审者在项目中的作者与评审贡献作为质量信号。具体提出经验感知损失函数(ELF),将评审者的项目所有权作为损失权重,使经验丰富的评审意见对模型影响更大。实验表明,相较于SOTA模型,ELF在准确性、信息量及评论类型多样性上均有提升。本工作的核心贡献在于证明了传统软件工程概念(如评审者经验)可有效融入AI驱动的自动化代码评审系统设计中。

原文摘要 · Abstract (English)

Modern code review is a ubiquitous software quality assurance process aimed at identifying potential issues within newly written code. Despite its effectiveness, the process demands large amounts of effort from the human reviewers involved. To help alleviate this workload, researchers have trained deep learning models to imitate human reviewers in providing natural language code reviews. Formally, this task is known as code review comment generation. Prior work has demonstrated improvements in this task by leveraging machine learning techniques and neural models, such as transfer learning and the transformer architecture. However, the quality of the model generated reviews remain sub-optimal due to the quality of the open-source code review data used in model training. This is in part due to the data obtained from open-source projects where code reviews are conducted in a public forum, and reviewers possess varying levels of software development experience, potentially affecting the quality of their feedback. To accommodate for this variation, we propose a suite of experience-aware training methods that utilise the reviewers' past authoring and reviewing experiences as signals for review quality. Specifically, we propose experience-aware loss functions (ELF), which use the reviewers' authoring and reviewing ownership of a project as weights in the model's loss function. Through this method, experienced reviewers' code reviews yield larger influence over the model's behaviour. Compared to the SOTA model, ELF was able to generate higher quality reviews in terms of accuracy, informativeness, and comment types generated. The key contribution of this work is the demonstration of how traditional software engineering concepts such as reviewer experience can be integrated into the design of AI-based automated code review models.

代码评审AI生成经验建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。