Code review is a common process that is used by developers, in which a reviewer provides useful comments or points out defects in the submitted source code changes via pull request. Code review has been widely used for both industry and open-source projects due to its capacity in early defect identification, project maintenance, and code improvement. With rapid updates on project developments, code review becomes a non-trivial and labor-intensive task for reviewers. Thus, an automated code review engine can be beneficial and useful for project development in practice. Although there exist prior studies on automating the code review process by adopting static analysis tools or deep learning techniques, they often require external sources such as partial or full source code for accurate review suggestion. In this paper, we aim at automating the code review process only based on code changes and the corresponding reviews but with better performance. The hinge of accurate code review suggestion is to learn good representations for both code changes and reviews. To achieve this with limited source, we design a multi-level embedding (i.e., word embedding and character embedding) approach to represent the semantics provided by code changes and reviews. The embeddings are then well trained through a proposed attentional deep learning model, as a whole named CORE. We evaluate the effectiveness of CORE on code changes and reviews collected from 19 popular Java projects hosted on Github. Experimental results show that our model CORE can achieve significantly better performance than the state-of-the-art model (DeepMem), with an increase of 131.03% in terms of Recall@10 and 150.69% in terms of Mean Reciprocal Rank. Qualitative general word analysis among project developers also demonstrates the performance of CORE in automating code review.
Modeling Review History for Reviewer Recommendation:A Hypergraph Approach
现代代码审查是开源软件(OSS)开发中流行的拉请求开发范式中的一个关键和不可或缺的实践。因此,在有大量参与者的项目中找到合适的评审员成为一项越来越具有挑战性的任务。已经开发了许多评论者推荐方法(评论者)来支持这一任务,其应用类似的策略,即首先对评论历史建模,然后基于模型预测/推荐评论者。显然,模型越能反映评论历史的真实情况,我们期望的推荐器性能就越高。然而,拉取请求开发范例中的一个典型场景,即一个拉取请求(PR)(例如由贡献者提交的修订或添加)可能有多个审阅者,并且他们可能通过公开发布的评论相互影响,在现有的开发者中没有很好地建模。我们采用超图技术来建模这种高阶关系(即本文中的一个PR与多个评论者),并开发了一种新的推荐器,即HGRec,它被12个OSS项目评估,超过87 K PR,680 K评论在准确性和推荐分布方面。结果表明,HGRec在推荐准确性方面优于最先进的推荐器。此外,在前三名准确的评论者中,HGRec更有可能推荐多样性的评论者,这有助于缓解核心评论者的工作量拥挤问题。此外,由于HGRec基于超图,超图是对模型审查历史的自然和可解释的表示,因此很容易在现代代码审查场景中容纳更多类型的实体和现实关系。作为第一次尝试,本研究揭示了超图在推进代码评审推荐的实用解决方案方面的潜力。