Generation-based Code Review Automation: How Far Are We?

Xin Zhou, Kisub Kim, Bowen Xu, DongGyun Han, Junda He, David Lo · DOI

Introduction

Code review is a cornerstone of modern software engineering, ensuring code quality, security, and knowledge sharing within teams. However, it is also one of the most time-consuming aspects of the development lifecycle. Recent advancements in deep learning have led to the emergence of Automatic Code Review (ACR) tools designed to alleviate this burden. Despite the proliferation of these tools, the field has lacked a unified evaluation framework to determine which approaches are truly effective. This paper presents the first comprehensive "head-to-head" evaluation of ACR models, comparing specialized tools against general-purpose pre-trained models.

The Challenges in ACR Evaluation

The researchers identify three primary gaps in the current state of ACR research:

  1. Lack of Comparative Benchmarking: Most ACR tools are evaluated in isolation or against weak baselines, making it difficult to identify the state-of-the-art.
  2. General-Purpose vs. Specialized Models: While models like CodeT5 have transformed general software engineering tasks, their performance in the specific, nuanced domain of code review—which requires understanding both code logic and natural language feedback—remained unproven.
  3. The Limitations of Exact Match (EM): Traditional evaluation relies heavily on Exact Match (EM) scores. If a model's suggestion differs from a human's by even a single character, it is marked as a failure. This "all-or-nothing" approach fails to capture "partial credit" where a model might significantly improve the code without reaching the exact human-authored version.

Experimental Setup

The study benchmarks three specialized ACR tools (Trans-Review, AutoTransform, T5-Review) against three general-purpose pre-trained models (CodeBERT, GraphCodeBERT, CodeT5). These models were evaluated across three critical tasks:

  • Code Revision Before Review (CRB): Proactively improving code quality to reduce the reviewer's workload.
  • Code Revision After Review (CRA): Automatically implementing changes based on a reviewer’s written comments.
  • Review Comment Generation (RCG): Acting as a reviewer by generating natural language comments on code snippets.

To address the limitations of EM, the authors introduced Edit Progress (EP). This metric uses token-level edit distance to measure how much closer an AI's prediction brings the original code to the final "gold standard" version.

Data and Representation

The evaluation utilized three large-scale datasets from Gerrit and GitHub (Trans-Review, AutoTransform, and T5-Review datasets), ranging from 13.7k to 134k training pairs. A key technical focus was the method of code representation. Older models often used "abstraction" (replacing specific variable names with generic placeholders), while newer models utilize Byte-Pair Encoding (BPE) to handle complex sub-tokens more effectively.

Key Findings

1. The Rise of General-Purpose Models

The results indicate a shift in the state-of-the-art. CodeT5, a general-purpose encoder-decoder model, significantly outperformed specialized ACR tools in code revision tasks (CRB and CRA). Its architecture allows it to effectively "translate" problematic code into improved versions, achieving EM improvements of 13.4% to 38.9% over previous specialized leaders.

2. The Importance of Natural Language Context

While CodeT5 dominated code changes, T5-Review remained the superior model for generating review comments (RCG). The researchers attribute this to T5-Review's pre-training on Stack Overflow data. Exposure to developer discussions and natural language explanations of code issues appears crucial for generating meaningful feedback.

3. Conservative vs. Noisy Improvements

The Edit Progress (EP) metric provided deeper insights into model behavior. Some models, such as AutoTransform, were found to be "conservative"—they rarely achieved an Exact Match but consistently made small, positive edits. Conversely, other models achieved higher EM scores but also produced "noisy" failures that could potentially degrade code quality. This suggests that EM alone is an insufficient metric for assessing the practical utility of an ACR tool.

4. BPE vs. Abstraction

The study confirmed that BPE is superior to abstraction-based methods. Abstraction struggles when a reviewer introduces new variables or logic that the model hasn't seen in its simplified vocabulary. BPE's ability to handle sub-tokens allows it to adapt to "out-of-vocabulary" scenarios much more gracefully.

Conclusion and Future Directions

While the study highlights significant progress, it also underscores how far the field is from full autonomy. Even the best models often achieve EM scores below 30%, particularly struggling with complex logic or interrogative comments (e.g., "Why was this approach chosen?").

The authors suggest that future ACR development should move away from seeking "perfect" replacements for humans and instead focus on creating "helpful assistants." By optimizing for Edit Progress and combining natural language pre-training with code-specific objectives, the next generation of ACR tools can more effectively reduce the manual effort required in the code review process.

Summary updated

BibTeX
@inproceedings{zhou2023generation,
  author = {Xin Zhou and Kisub Kim and Bowen Xu and DongGyun Han and Junda He and David Lo},
  title = {{Generation-based Code Review Automation: How Far Are We?}},
  booktitle = {ICPC},
  year = {2023},
  doi = {10.1109/icpc58990.2023.00036},
}
Figure