[论文解读] Defect Identification, Categorization, and Repair: Better Together
该论文提出 CompDefect,一种统一框架,通过多类别分类与序列生成方法,实现函数级缺陷的识别、类型分类及自动修复。该框架在新构建的大规模函数级数据集上达到最先进性能,缺陷识别 F1 分数最高提升 41.7%,修复准确率提升 29.5%。
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.
研究动机与目标
- 解决现有即时缺陷预测(JIT-DP)方法未能充分利用完整语义与代码结构信息的局限性。
- 克服现有方法在提交级别进行缺陷预测的粗粒度问题,实现细粒度的函数级缺陷识别与类型分类。
- 通过聚焦单个函数而非包含多文件变更的完整提交,提升缺陷定位的精确性。
- 将缺陷预测与自动修复整合为单一统一框架,实现在代码提交时的端到端缺陷处理。
- 构建一个大规模的函数级数据集,包含干净代码、含缺陷代码与修复后代码版本,以支持缺陷预测与修复的全面评估。
提出的方法
- CompDefect 每个函数处理三种输入:干净版本、含缺陷版本与修复后版本,实现缺陷预测与修复的联合学习。
- 缺陷识别与分类建模为多类别分类任务,利用 GraphCodeBERT 编码代码语义与结构信息。
- 缺陷修复建模为序列到序列生成任务,模型从含缺陷版本生成修复后的代码。
- 框架利用预训练模型(如 GraphCodeBERT)捕获代码的深层语义与结构信息,提升表征学习能力。
- 构建了一个新颖的函数级数据集 Function-SStuBs4J,包含 21,047 个实例,每个实例包含三个代码版本(干净、含缺陷、修复),用于模型训练与评估。
- 模型采用交叉熵损失对分类与序列生成任务进行端到端训练,实现缺陷检测与修复的联合优化。
实验结果
研究问题
- RQ1统一框架是否能够联合提升函数级缺陷识别、分类与自动修复性能,超越孤立的预测或修复系统?
- RQ2当结合多版本代码输入时,预训练代码模型(如 GraphCodeBERT)在缺陷检测与修复中的增强效果有多大?
- RQ3在缺陷识别、分类与修复任务中,CompDefect 相较于最先进基线方法,在 F1 分数、AUC、BLEU 与准确率方面的表现如何?
- RQ4该框架是否能有效实现函数级缺陷定位并以高准确率完成修复,尤其针对单行修复?
- RQ5与仅使用含缺陷代码的模型相比,引入干净代码与修复后代码版本在多大程度上提升了模型检测与修复缺陷的能力?
主要发现
- 在缺陷识别任务中,CompDefect 相较 DeepJIT 与 CC2Vec,F1 分数提升 39.0%,AUC 提升 34.7%。
- 在缺陷分类任务中,CompDefect 平均提升预训练模型(BERT、RoBERTa、CodeBERT)的 F1 分数至少 63.0%。
- 在缺陷修复任务中,CompDefect 相较 SequenceR,BLEU 分数提升 23.9%,准确率提升 29.5%。
- 所提出的 Function-SStuBs4J 数据集是目前公开可用的最大规模函数级数据集,包含三版代码与多种缺陷类型。
- CompDefect 在多种基准与设置下展现出强大的泛化能力,在所有评估任务中均超越最先进模型。
- 引入干净代码与修复后代码版本显著增强了模型检测与修复缺陷的能力,相较于仅使用含缺陷代码的模型表现更优。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。