arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.08221cs.SE
收藏

探索ChatGPT在自动化代码精炼中的潜力:一项实证研究

Exploring the Potential of ChatGPT in Automated Code Refinement: An Empirical Study

Qi Guo, Junming Cao, Xiaofei Xie, Shangqing Liu, Xiaohong Li, Bihuan Chen, Xin Peng

AI总结:

本文首次实证研究了ChatGPT在基于代码审查的自动化代码精炼任务中的能力,发现其表现优于基线工具CodeReviewer,并分析了其表现不佳的原因及改进策略。

摘要:

代码审查是确保软件项目质量和可维护性的重要活动。然而,这是一项耗时且容易出错的任务,可能会对开发过程产生重大影响。最近,ChatGPT作为一种前沿的语言模型,在各种自然语言处理任务中表现出色,显示出其在自动化代码审查过程中的潜力。然而,目前尚不清楚ChatGPT在代码审查任务中的表现如何。为了填补这一空白,本文进行了首次实证研究,以了解ChatGPT在代码审查任务中的能力,特别关注基于给定代码审查的自动化代码精炼。为了开展研究,我们选择了现有的基准CodeReview,并构建了一个高质量的全新代码审查数据集。我们使用CodeReviewer(一种最先进的代码审查工具)作为基线与ChatGPT进行比较。结果表明,ChatGPT在代码精炼任务中优于CodeReviewer。具体而言,ChatGPT分别获得了22.78和76.44的更高EM和BLEU分数,而最先进的方法在高质量代码审查数据集上仅获得了15.50和62.88。我们进一步找出了ChatGPT表现不佳的根本原因,并提出了几种缓解这些挑战的策略。我们的研究深入探讨了ChatGPT在自动化代码审查过程中的潜力,并突出了未来的研究方向。

英文摘要:

Code review is an essential activity for ensuring the quality and maintainability of software projects. However, it is a time-consuming and often error-prone task that can significantly impact the development process. Recently, ChatGPT, a cutting-edge language model, has demonstrated impressive performance in various natural language processing tasks, suggesting its potential to automate code review processes. However, it is still unclear how well ChatGPT performs in code review tasks. To fill this gap, in this paper, we conduct the first empirical study to understand the capabilities of ChatGPT in code review tasks, specifically focusing on automated code refinement based on given code reviews. To conduct the study, we select the existing benchmark CodeReview and construct a new code review dataset with high quality. We use CodeReviewer, a state-of-the-art code review tool, as a baseline for comparison with ChatGPT. Our results show that ChatGPT outperforms CodeReviewer in code refinement tasks. Specifically, our results show that ChatGPT achieves higher EM and BLEU scores of 22.78 and 76.44 respectively, while the state-of-the-art method achieves only 15.50 and 62.88 on a high-quality code review dataset. We further identify the root causes for ChatGPT's underperformance and propose several strategies to mitigate these challenges. Our study provides insights into the potential of ChatGPT in automating the code review process, and highlights the potential research directions.

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

↑