arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2506.04464cs.SEcs.LG
收藏

利用奖励模型指导代码审查评论生成

Leveraging Reward Models for Guiding Code Review Comment Generation

Université de Montréal(蒙特利尔大学);Università della Svizzera italiana(瑞士联邦理工学院)

Oussama Ben Sghaier, Rosalia Tufano, Gabriele Bavota, Houari Sahraoui

AI总结:

本文提出 CoRAL 框架,利用兼顾评论语义及其对代码精化模型可用性的强化学习奖励机制,自动生成代码审查评论,并通过定量与定性比较验证其优于最新基线。

摘要:

代码审查是现代软件开发的关键组成部分,涉及评估代码质量、就潜在问题提供反馈,以及改进代码以解决已发现的问题。尽管具有这些益处,代码审查可能相当耗时,并受到主观性和人为因素的影响。由于这些原因,文献中已经提出了(部分)自动化代码审查过程的技术。其中,利用深度学习(DL)的技术能够处理代码审查的生成层面,即像人类审查者那样对给定代码发表评论(即评论生成任务),或者自动实施为回应审查者评论所需的代码变更(即代码精化任务)。在本文中,我们介绍了 CoRAL,这是一个通过利用强化学习来自动化审查评论生成的深度学习框架,其奖励机制同时考虑所生成评论的语义,以及这些评论作为其他自动化代码精化任务模型输入的有用性。其核心思想是,如果深度学习模型生成的评论在语义上与预期评论相似,或者能够由专门从事代码精化的第二个模型成功实施,那么这些评论很可能是有意义且有用的,因此在强化学习框架中值得获得高奖励。我们展示了 CoRAL 生成的评论与最新基线技术生成的评论之间的定量和定性比较,突出了我们方法的有效性和优越性。

英文摘要:

Code review is a crucial component of modern software development, involving the evaluation of code quality, providing feedback on potential issues, and refining the code to address identified problems. Despite these benefits, code review can be rather time consuming, and influenced by subjectivity and human factors. For these reasons, techniques to (partially) automate the code review process have been proposed in the literature. Among those, the ones exploiting deep learning (DL) are able to tackle the generative aspect of code review, by commenting on a given code as a human reviewer would do (i.e., comment generation task) or by automatically implementing code changes required to address a reviewer's comment (i.e., code refinement task). In this paper, we introduce CoRAL, a deep learning framework automating review comment generation by exploiting reinforcement learning with a reward mechanism considering both the semantics of the generated comments as well as their usefulness as input for other models automating the code refinement task. The core idea is that if the DL model generates comments that are semantically similar to the expected ones or can be successfully implemented by a second model specialized in code refinement, these comments are likely to be meaningful and useful, thus deserving a high reward in the reinforcement learning framework. We present both quantitative and qualitative comparisons between the comments generated by CoRAL and those produced by the latest baseline techniques, highlighting the effectiveness and superiority of our approach.

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

↑