ReDef:代码语言模型真的能理解代码变更用于即时软件缺陷预测吗?
ReDef: Do Code Language Models Truly Understand Code Changes for Just-in-Time Software Defect Prediction?
AI总结:
ReDef通过高置信度的函数级修改数据集评估代码语言模型对代码变更的理解,发现紧凑的diff编码在所有模型中表现最佳,但反事实测试显示性能稳定,表明模型依赖于表面线索而非真实语义理解。
摘要:
即时软件缺陷预测(JIT-SDP)在代码审查和持续集成中优先处理高风险代码变更至关重要。然而,现有数据集常存在标签噪声和低精度识别引发缺陷提交的问题。为此,我们提出了ReDef(基于回退的缺陷数据集),从22个大规模C/C++项目中精心挑选出高置信度的函数级修改。缺陷案例通过回退提交锚定,清洁案例通过事后历史检查验证。模糊实例通过GPT辅助的三审流程保守过滤。该流程产生3,164个缺陷和10,268个清洁修改,比现有资源更可靠。除了数据集构建,我们系统评估了代码语言模型(如CodeBERT、CodeT5+、UniXcoder和Qwen2.5)对代码修改的理解。我们首先研究了五种不同策略下哪种输入编码最能暴露变更信息。然后设计了四种反事实扰动策略(如交换添加/删除块,反转diff极性)作为诊断探针。我们认为,如果模型真正捕捉到变更语义,此类扰动应导致预测性能明显下降。结果表明,紧凑的diff风格编码在所有CLM中均优于完整函数格式,支持严格统计验证。然而,在反事实测试中,性能保持稳定,揭示出看似稳健的性能实际上反映了对表面线索的依赖,而非真正的语义理解。
英文摘要:
Just-in-Time software defect prediction (JIT-SDP) plays a critical role in prioritizing risky code changes during code review and continuous integration. However, existing datasets often suffer from noisy labels and low precision in identifying bug-inducing commits. To address this, we present ReDef (Revert-based Defect dataset), a high-confidence benchmark of function-level modifications curated from 22 large-scale C/C++ projects. Defective cases are anchored by revert commits, while clean cases are validated through post-hoc history checks. Ambiguous instances are conservatively filtered out via a GPT-assisted triage process involving multiple votes and audits. This pipeline yields 3,164 defective and 10,268 clean modifications, offering substantially more reliable labels than prior resources. Beyond dataset construction, we provide a systematic evaluation of how Code Language Models (CLMs)-specifically CodeBERT, CodeT5+, UniXcoder, and Qwen2.5-reason about code modifications. We first investigate which input encodings most effectively expose change information under five different strategies. We then design four counterfactual perturbation strategies (e.g., swapping added/deleted blocks, inverting diff polarity) to serve as diagnostic probes. We posit that if models genuinely capture change semantics, such distortions should lead to a clear decline in predictive performance. Our results show that compact diff-style encodings consistently outperform whole-function formats across all CLMs, supported by rigorous statistical confirmation. However, under counterfactual tests, performance remains effectively stable, revealing that what appears to be robustness in fact reflects a reliance on superficial cues rather than true semantic understanding.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。