Abstract
CompDefect is a novel multi-task deep learning framework designed to manage the entire lifecycle of software defects at the function level. By utilizing a shared GraphCodeBERT encoder, the system simultaneously performs defect identification, categorization, and automated repair. This unified approach addresses critical gaps in current research, such as coarse granularity and task isolation. Experimental results on the new Function-SStuBs4J benchmark show that CompDefect significantly outperforms state-of-the-art models, demonstrating that joint learning of classification and generation tasks enhances overall performance.
Introduction
Just-In-Time (JIT) defect prediction is essential for modern software development, allowing developers to catch bugs at the moment of code check-in. However, existing research faces several significant challenges:
- Coarse Granularity: Most models operate at the commit level, making it difficult to locate specific bugs within large changes.
- Lack of Context: Binary "buggy" or "clean" labels provide little guidance on the nature of the defect.
- Information Underutilization: Structural code properties, particularly data flow, are often ignored.
- Task Silos: Defect prediction and repair are typically treated as independent problems, despite their inherent relationship.
CompDefect addresses these issues by providing fine-grained, hunk-level analysis and integrating identification, categorization, and repair into a single multi-task framework.
Methodology
The core of CompDefect is a multi-task learning architecture built upon a shared knowledge base. The framework processes three versions of a function—clean, buggy, and fixed—to learn the underlying intent of code repairs.
The architecture branches into two primary components:
- Classification Branch: This module handles defect identification and categorization as a multi-class classification problem, identifying specific patterns such as wrong function names or identifier errors.
- Generation Branch: A Transformer-based decoder generates the "fixed" code sequence, leveraging the features learned during the classification phase.
The Encoder: GraphCodeBERT
Unlike standard natural language models that treat code as linear text, CompDefect employs GraphCodeBERT as its encoder. This allows the model to incorporate the Data Flow Graph (DFG), which tracks how variables interact and change throughout the function.
By capturing these structural relationships, the model gains a deeper understanding of logic errors that are often invisible to purely sequence-based models.
Evaluation and Results
To evaluate CompDefect, the authors introduced Function-SStuBs4J, a large-scale benchmark containing 21,047 instances across 16 defect patterns. This dataset improves upon previous benchmarks by providing full function bodies and including negative samples for more realistic training.
CompDefect demonstrated dominant performance across all tasks:
- Defect Identification: Achieved F1-score improvements of 39.0% over DeepJIT and 41.7% over CC2Vec.
- Defect Categorization: Outperformed specialized pre-trained models like BERT and RoBERTa by at least 63.0%.
- Defect Repair: Surpassed the specialized repair tool SequenceR by 23.9% in BLEU score and 29.5% in accuracy.
A key insight from the results is the synergy between tasks: the classification task provides critical features that improve the accuracy of the subsequent repair generation.
Conclusion and Future Work
CompDefect proves that defect identification, categorization, and repair are "better together." By moving to the function level and utilizing structural data flow, the framework provides developers with actionable, fine-grained insights. While currently focused on single-statement Java defects, future work aims to expand the model's capabilities to multi-statement architectural bugs and integrate it directly into IDEs for real-time developer support.
Summary updated