FINDGATE: Fine-grained Defect Prediction Based on a Heterogeneous Discrete Code Graph-guided Attention Transformer
Jiaxi Xu, Ping Chen, Banghu Yin, Zhichang Huang, Qiaochun Qiu · 2023
Recognizing defects in source code through deep learning methods has become an important research subject for improving software quality. Although Transformer-based models such as CodeBERT have demonstrated impressive performance improvement in defect prediction tasks, models relying on single-structured input data, such as sequences, have limited ability to capture the code's structural features. Treating code simply as text overlooks essential information such as control dependencies, data dependencies, and syntactic structures inherent in the code. This paper proposes the Heterogeneous Discrete Code Graph (HDCG), which assigns structural information to code tokens from multiple perspectives. We also introduce an improved transformer model FINEGATE that leverages HDCG to guide self-attention. The experiments demonstrate that FINEGATE can effectively predict source code defects and perform fine-grained defect localization.