Quantitative analysis reveals GNN excels in identifying code smells like long method and duplicated code, indicating its potential in enhancing code quality.
This study aims to develop and evaluate a GNN-based model for automatically detecting code smells in Python by leveraging the structural information derived from Abstract Syntax Trees (ASTs). The study employed a quantitative approach by training a Graph Neural Network (GNN) model on code represented as Abstract Syntax Trees (ASTs). The proposed GNN model demonstrated high effectiveness in detecting specific types of code smells using a processed dataset, achieving 96.3% accuracy for Long Method detection and 95.2% for Large Class detection. Furthermore, the model effectively identified Long Method, Large Class, and Duplicated Code when tested on real-world datasets. On the ERPNext dataset, it reached 95.95% accuracy, 99.84% precision, 95.95% recall, and 97.78% F1-score. On the Odoo dataset, it attained 93.29% accuracy, 99.74% precision, 93.29% recall, and 96.29% F1-score. These results show that the proposed GNN model outperformed traditional machine learning algorithms such as Decision Tree, Random Forest, Support Vector Machine (SVM), Stochastic Gradient Descent (SGD), Multi-Layer Perceptron (MLP), and Linear Regression. The results confirm that the GNN-based approach effectively detects code smells in Python programs, surpassing classical machine learning techniques. This model provides a practical tool for enhancing code quality and maintainability. Future work could explore real-time integration of this model into development environments and expand detection to other code smell types.
No takes yet. Share an insight, caveat, or question.
Slamet et al. (2025) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: