Skip to main content
QUICK REVIEW

[Paper Review] Defect Identification, Categorization, and Repair: Better Together

Chao Ni, Kaiwen Yang|arXiv (Cornell University)|Apr 11, 2022
Software Engineering ResearchComputer Science5 citations
TL;DR

This paper proposes CompDefect, a unified framework that identifies function-level defects, categorizes their types, and automatically repairs them using a multiclass classification and sequence generation approach. It achieves state-of-the-art performance on a new large-scale function-level dataset, improving F1-score by up to 41.7% and repair accuracy by 29.5% over prior methods.

ABSTRACT

Just-In-Time defect prediction (JIT-DP) models can identify defect-inducing commits at check-in time. Even though previous studies have achieved a great progress, these studies still have the following limitations: 1) useful information (e.g., semantic information and structure information) are not fully used; 2) existing work can only predict a commit as buggy one or clean one without more information about what type of defect it is; 3) a commit may involve changes in many files, which cause difficulty in locating the defect; 4) prior studies treat defect identification and defect repair as separate tasks, none aims to handle both tasks simultaneously. In this paper, to handle aforementioned limitations, we propose a comprehensive defect prediction and repair framework named CompDefect, which can identify whether a changed function (a more fine-grained level) is defect-prone, categorize the type of defect, and repair such a defect automatically if it falls into several scenarios, e.g., defects with single statement fixes, or those that match a small set of defect templates. Generally, the first two tasks in CompDefect are treated as a multiclass classification task, while the last one is treated as a sequence generation task. The whole input of CompDefect consists of three parts (exampled with positive functions): the clean version of a function (i.e., the version before defect introduced), the buggy version of a function and the fixed version of a function. In multiclass classification task, CompDefect categorizes the type of defect via multiclass classification with the information in both the clean version and the buggy version. In code sequence generation task, CompDefect repairs the defect once identified or keeps it unchanged.

Motivation & Objective

  • Address the limitations of existing Just-In-Time defect prediction (JIT-DP) methods that fail to utilize full semantic and structural code information.
  • Overcome the coarse-grained prediction of commit-level bugs by enabling fine-grained, function-level defect identification and type categorization.
  • Improve defect localization by focusing on individual functions rather than entire commits with multiple file changes.
  • Integrate defect prediction and automated repair into a single unified framework, enabling end-to-end defect handling at check-in time.
  • Develop a large-scale, function-level dataset with clean, buggy, and fixed code versions to support comprehensive evaluation of defect prediction and repair.

Proposed method

  • CompDefect processes three inputs per function: the clean version, the buggy version, and the fixed version, enabling joint learning of defect prediction and repair.
  • Defect identification and categorization are modeled as a multiclass classification task using GraphCodeBERT to encode code semantics and structure.
  • Defect repair is modeled as a sequence-to-sequence generation task, where the model generates the fixed code from the buggy version.
  • The framework leverages pre-trained models (e.g., GraphCodeBERT) to capture deep semantic and structural information from code, improving representation learning.
  • A novel function-level dataset, Function-SStuBs4J, is constructed with 21,047 instances, each containing three code versions (clean, buggy, fixed), to train and evaluate the model.
  • The model is trained end-to-end with cross-entropy loss for classification and sequence generation, enabling joint optimization of defect detection and repair.

Experimental results

Research questions

  • RQ1Can a unified framework jointly improve function-level defect identification, categorization, and automatic repair beyond isolated prediction or repair systems?
  • RQ2To what extent can pre-trained code models like GraphCodeBERT enhance defect detection and repair when combined with multi-version code inputs?
  • RQ3How does CompDefect perform compared to state-of-the-art baselines in terms of F1-score, AUC, BLEU, and accuracy across defect identification, categorization, and repair tasks?
  • RQ4Can the framework effectively localize defects at the function level and repair them with high accuracy, especially for one-line fixes?
  • RQ5How does the inclusion of clean and fixed code versions improve the model’s ability to detect and repair defects compared to using only buggy code?

Key findings

  • CompDefect improves F1-score by 39.0% and AUC by 34.7% over DeepJIT and CC2Vec in the defect identification task.
  • For defect categorization, CompDefect improves pre-trained models (BERT, RoBERTa, CodeBERT) by at least 63.0% in F1-score on average.
  • In defect repair, CompDefect achieves a 23.9% improvement in BLEU score and a 29.5% improvement in accuracy over SequenceR.
  • The proposed Function-SStuBs4J dataset is the largest publicly available function-level dataset with three code versions and multiple defect types.
  • CompDefect demonstrates strong generalization across diverse benchmarks and settings, outperforming SOTA models in all evaluated tasks.
  • The integration of clean and fixed code versions significantly enhances the model’s ability to detect and repair defects compared to models using only buggy code.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.