Skip to content

Traversal-Aware Structural Fusion of AST and CFG for Code Representation Learning in Software Fault and Code Smell Detection

2026 · IEEE Transactions on Reliability · Vol 75, pp. 2913-2927 · 0 citations · 35 references

Abstract

The effectiveness of machine learning and deep learning models in software engineering (SE) tasks, such as fault prediction and code smell detection, depends heavily on the quality of source code representation and feature extraction. Previous studies have primarily used abstract syntax trees (ASTs) for source code representation in SE tasks but often fail to capture crucial semantic and control-flow details. To overcome this, control-flow graphs (CFGs) and combined representations (AST+CFG) have been explored for richer code understanding. However, their tradeoffs and benefits on the prediction models for SE tasks remain largely unexplored. This study investigates the impact of different source code representation techniques, including AST, CFG, their combination (AST+CFG), and pretrained code models (CodeBERT and Code2Vec) in software fault prediction and code smell detection. In addition, we investigate different traversal methods, including root-to-leaf and leaf-to-leaf, for both AST and CFG and their combination (AST+CFG) to assess their effectiveness in capturing structural and semantic information for improving prediction model performance. The experimental analysis is performed using the seven projects in the PROMISE dataset for fault prediction and the Multilabel Code Quality dataset for code smell detection. We employ various machine learning techniques for prediction model building and different performance measures for a comprehensive evaluation. The results show that a combined AST+CFG representation outperforms individual representations (AST or CFG) by providing a more comprehensive view of structural and control-flow semantics. In addition, CodeBERT stands out in both domains, demonstrating its ability to capture deeper relationships in the code. However, pretrained models were found to be more computationally expensive.

View source

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.