Jointly Learning to Repair Code and Generate Commit Message

30821

Authors

nan

Abstract

AbstractWe propose a novel task of jointly repairing program codes and generating commit messages. Code repair and commit message generation are two essential and related tasks for software development. However, existing work usually performs the two tasks independently. We construct a multilingual triple dataset including buggy code, fixed code, and commit messages for this novel task. We first introduce a cascaded method with two models, one is to generate the fixed code first, and the other generates the commit message based on the fixed and original codes. We enhance the cascaded method with different training approaches, including the teacher-student method, the multi-task method, and the back-translation method. To deal with the error propagation problem of the cascaded method, we also propose a joint model that can both repair the program code and generate the commit message in a unified framework. Massive experiments on our constructed buggy-fixed-commit dataset reflect the challenge of this task and that the enhanced cascaded model and the proposed joint model significantly outperform baselines in both quality of code and commit messages.

Keywords

nan

Full Content

Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 9784–9795 November 7–11, 2021. c⃝2021 Association for Computational Linguistics 9784 Jointly Learning to Repair Code and Generate Commit Message Jiaqi Bai†‡∗, Long Zhou♦, Ambrosio Blanco♦, Shujie Liu♦, Furu Wei♦, Ming Zhou♦, Zhoujun Li†‡ †School of Cyber Science and Technology, Beihang University, China ‡State Key Lab of Software Development Environment, Beihang University, China ♦Microsoft Research Asia {bjq,lizj}@buaa.edu.cn {lozhou,ambrosio.blanco,shujliu,fuwei,mingzhou}@microsoft.com Abstract We propose a novel task of jointly repairing program codes and generating commit mes- sages. Code repair and commit message gen- eration are two essential and related tasks for software development. However, exist- ing work usually performs the two tasks in- dependently. We construct a multilingual triple dataset including buggy code, fixed code, and commit messages for this novel task. We provide the cascaded models as base- line, which are enhanced with different train- ing approaches, including the teacher-student method, the multi-task method, and the back- translation method. To deal with the error propagation problem of the cascaded method, the joint model is proposed that can both re- pair the code and generate the commit message in a unified framework. Experimental results show that the enhanced cascaded model with teacher-student method and multitask-learning method achieves the best score on different metrics of automated code repair, and the joint model behaves better than the cascaded model on commit message generation. 1 Introduction Deep learning has been demonstrated remarkably adept at numerous natural language processing (NLP) tasks, such as machine translation (Bah- danau et al., 2014), relation extraction (Zhang et al., 2017), grammar error correction (Ge et al., 2018), and so on. The success of deep learning in NLP also promotes the development of which in pro- gramming languages (Clement et al., 2020; Lu et al., 2021). Recently, researchers have exploited deep learning to programming-language related tasks, such as code completion (Svyatkovskiy et al., 2020), automated code repair (Tufano et al., 2018), commit messages generation (Xu et al., 2019), code search (Gu et al., 2018), and so on. Among these tasks, automated code repair and commit message ∗Contribution during internship at Microsoft Research public int multiplication (int a, float b) { return a * b } Buggy Code Buggy Code public int multiplication (int a, float b) { return a * b } Buggy Code public float multiplication (int a, float b) { return a * b } Repaired Code Repaired Code public float multiplication (int a, float b) { return a * b } Repaired Code Fix syntax error by replacing int with float for the return type of the function. Commit Message Commit Message Commit Message Commit Message Figure 1: An illustrative example for our proposed task. Given a buggy code, the task is to generate its corre- sponding repaired version, as well as the commit mes- sage that describes their changes. generation are the two most active and closely re- lated tasks. The former is to repair software bugs automatically without the intervention of a human programmer. The …

Content truncated to 500 words

Labeled Text

AbstractWe propose a novel task of jointly repairing program codes and generating commit messages. Code repair and commit message generation are two essential and related tasks for software development. However, existing work usually performs the two tasks independently. We construct a multilingual triple dataset including buggy code, fixed code, and commit messages for this novel task. We first introduce a cascaded method with two models, one is to generate the fixed code first, and the other generates the commit message based on the fixed and original codes. We enhance the cascaded method with different training approaches, including the teacher-student method, the multi-task method, and the back-translation method. To deal with the error propagation problem of the cascaded method, we also propose a joint model that can both repair the program code and generate the commit message in a unified framework. Massive experiments on our constructed buggy-fixed-commit dataset reflect the challenge of this task and that the enhanced cascaded model and the proposed joint model significantly outperform baselines in both quality of code and commit messages.

Publication Details

Paper ID:
30821
Year:
2021
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan