通过问题列表生成和上下文增强改进基于LLM的Go代码审查
Improving LLM-Based Go Code Review through Issue-List Generation and Context Augmentation
AI总结:
提出问题列表审查范式,结合三种上下文增强方法,并通过候选集成和精炼引导剪枝提升LLM代码审查效果,在Go代码审查中显著优于基线方法。
摘要:
LLMs在自动化代码审查方面展现出强大潜力,但其实际效用很大程度上取决于生成和上下文策略的设计。本文研究如何通过生成策略和上下文增强来改进基于LLM的代码审查。我们首先提出一种问题列表审查范式,其中LLMs枚举所有潜在问题,而不仅仅是报告最重要的一个(即主要问题审查)。然后,我们系统比较了三种代码上下文增强——相邻上下文、基于LSP的语义上下文和基于IR的相似共变上下文——并研究它们如何影响问题发现。最后,我们整合无上下文和上下文增强生成的候选结果以提高审查覆盖率,并引入精炼引导剪枝以保持候选列表的实用规模。我们在1,438个Go审查实例上评估了我们的方法,使用下游代码精炼作为主要指标,即候选列表包含至少一条与最终人工修订产生相同代码变更的评论的频率。作为比较,我们评估了专门为审查评论生成训练的模型CodeReviewer以及真实人工审查评论(作为实际上限)在相同精炼评估下的表现。结果表明,我们最佳配置(结合问题列表审查、相邻和相似共变上下文以及候选集成)达到了28.00%的精炼精确匹配,比无任何额外上下文的主要问题审查(17.15%)显著提高了10.85个百分点,大幅优于CodeReviewer(15.02%),并接近人类上限36.09%。我们的精炼引导剪枝将平均候选数量从7.2减少到前5个中的3.1,同时几乎保留了全部收益,使候选列表更易于检查。
英文摘要:
LLMs have shown strong potential for automating code review, yet their practical utility depends heavily on the design of generation and context strategies. In this paper, we investigate how to improve LLM-based code review through generation strategy and contextual augmentation. We first propose an issue-list review paradigm, in which LLMs enumerate all potential issues rather than reporting only the single most important one (i.e., primary-issue review). We then systematically compare three types of code context augmentation -- neighboring, LSP-based semantics, and IR-based similar co-change context -- and study how they influence issue discovery. Finally, we integrate candidates from no-context and context-enhanced generation to improve review coverage, and introduce refinement-guided pruning to keep the candidate list at a practical size. We evaluate our approach on 1,438 Go review instances using downstream code refinement as the main metric, i.e., how often the candidate list contains at least one comment inducing the same code change as the final human revision. For comparison, we evaluate comments by CodeReviewer, a model trained specifically for review comment generation, as well as ground-truth human review comments (as a practical upper bound), under the same refinement-based evaluation. The results show that our best configuration, combining issue-list review, neighboring and similar co-change context, and candidate integration, reaches 28.00% refinement exact match, a statistically significant gain of +10.85 percentage points over primary-issue review without any additional context (17.15%), substantially outperforming CodeReviewer (15.02%) and approaching the human-oracle ceiling of 36.09%. Our refinement-guided pruning reduces the average candidate count from 7.2 to 3.1 at top-5 while retaining nearly the full benefit, making the candidate list easier to inspect.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。