Enhancing Software Quality with AI: A Transformer-Based Approach for Code Smell Detection
Source abstract
Abstract
Software quality assurance is a critical aspect of software engineering, directly impacting maintainability, extensibility, and overall system performance. Traditional machine-learning techniques, such as gradient boosting and support vector machines (SVM), have demonstrated effectiveness in code smell detection but require extensive feature engineering and struggle to capture intricate semantic dependencies in software structures. In this study, we introduce Relation-Aware BERT (RABERT), a novel transformer-based model that integrates relational embeddings to enhance automated code smell detection. By modeling interdependencies among software complexity metrics, RABERT surpasses classical machine-learning methods, achieving an accuracy of 90.0% and a precision of 91.0%. However, challenges such as low recall (53.0%) and computational overhead indicate the need for further optimization. We present a comprehensive comparative analysis between classical machine-learning models and transformer-based architectures, evaluating their computational efficiency and predictive capabilities. Our findings contribute to the advancement of AI-driven software quality assurance, offering insights into optimizing transformer-based models for practical deployment in software development workflows. Future research will focus on lightweight transformer variants, cost-sensitive learning techniques, and cross-language generalizability to enhance real-world applicability.
Source: crossref · Quality: baseline
Research context
OpenAlex topics: Software Engineering Research · Software Reliability and Analysis Research · Software Testing and Debugging Techniques
SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.
Affiliations
Department of Software Engineering, Iqra University, Karachi 75500, Pakistan
Department of Computer Science, SZABIST University, Karachi 75600, Pakistan
Department of Robotics and Artificial Intelligence, SZABIST University, Karachi 75600, Pakistan
AI Solution Development Department, Saudi Electricity Company (SEC), Riyadh 22955, Saudi Arabia
References (45)
Show source-provided references
1. Comparing and experimenting machine learning techniques for code smell detection10.1007/s10664-015-9378-4 ↗
2. Attention is all you need
3. Feng, Z., Guo, D., Tang, D., and Li, D.-A. (2020, January 16–20). CodeBERT: A pre-trained model for programming and natural languages. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), Online.10.18653/v1/2020.findings-emnlp.139 ↗
4. Guo, D., Li, S., Xue, X., and Li, D. (2021, January 2–9). GraphCodeBERT: Pre-training code representations with data flow. Proceedings of the AAAI Conference on Artificial Intelligence, Online.
5. CoRT: A transformer-based model for semantic and structural code analysis
6. SCSmell: Stacking pre-trained transformers for code smell detection
7. Detecting and analyzing design smells in object-oriented software
8. Olbrich, S., Cruzes, D.S., and Sjøberg, D.I.K. (2010, January 12–18). Are all code smells harmful? A study of God Classes and Brain Classes in the evolution of three open-source systems. Proceedings of the 2010 IEEE International Conference on Software Maintenance, Timișoara, Romania.10.1109/ICSM.2010.5609564 ↗
9. Code quality improvement using convolutional neural networks
10. Learning semantic representations for code analysis with Graph Neural Networks
11. Kim, S., Lee, J., and Yoo, S. (2021, January 20–30). Code representation with pre-trained transformers. Proceedings of the 43rd International Conference on Software Engineering (ICSE), Madrid, Spain.
12. Deep learning for code representation: Challenges and progress
13. Code analysis using deep learning: A survey
14. Integrating code and documentation for code smell detection: A multimodal approach
15. Graph embeddings for software smell detection
16. CodeBERT: Pre-trained models for programming language understanding
17. Johnson, D., Singh, A., and Kim, E. (2022, January 19–20). Transformer-based approaches to code semantics. Proceedings of the 50th ACM Symposium on Software Engineering, New York, NY, USA.
18. Deep semantic models for detecting code smells
19. Attention-based deep learning for code defect prediction
20. Mishra, A., Gupta, R., and Nandi, S. (2022, January 18–22). Hierarchical BERT models for code structure analysis. Proceedings of the ACM SIGSOFT Symposium, Online.
21. Extending BERT models for software engineering: A systematic review
22. Exploring transformer-based architectures for software analysis
23. Structural embeddings for code quality assessment
24. Optimizing code embeddings for defect prediction
25. Lee, S., Johnson, R., and Park, M. (2022, January 10–14). Pre-trained code embeddings for software defect detection. Proceedings of the IEEE/ACM ASE Conference, Rochester, MI, USA.
26. Hashimoto, K., Yoshida, Y., and Tanaka, H. (2023, January 17–21). Code smells in the age of machine learning. Proceedings of the 2023 ACM SIGSOFT International Symposium, Seattle, WA, USA.
27. Deep learning strategies for hierarchical code modeling
28. Leveraging pre-trained transformers for software bug prediction
29. Brown, J., White, T., and Green, S. (2022, January 3–7). Hybrid approaches to software smell detection using deep learning. Proceedings of the 2022 IEEE International Conference on Software Maintenance and Evolution, Limassol, Cyprus.
30. Analyzing code metrics with graph-based models
31. Relation-aware deep learning models for defect prediction
32. A systematic review of transformer applications in software engineering
33. Kim, H., Liu, Z., and Sun, Y. (2022, January 10–14). Pre-trained models for bug severity classification. Proceedings of the IEEE/ACM ASE Conference, Rochester, MI, USA.
34. Multimodal embeddings for software smell detection
35. Transforming software metrics into embeddings for defect prediction
36. Explainable AI approaches for code smell detection
37. BERT-inspired models for code review assistance
38. Deep learning for analyzing inter-file relationships in code smells
39. Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Springer. [2nd ed.].10.1007/978-0-387-84858-7 ↗
40. Smola, A.J., Bartlett, P.L., Schölkopf, B., and Schuurmans, D. (1999). Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods. Advances in Large Margin Classifiers, MIT Press.10.7551/mitpress/1113.001.0001 ↗
41. Breiman, L., Friedman, J., Olshen, R., and Stone, C. (1984). Classification and Regression Trees, Chapman & Hall/CRC.
42. (2025, April 18). Available online: https://github.com/IsrarAli-IU/Code-Smell-Detection.
43. Devlin, J., Chang, M.W., Lee, K., and Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv.
44. Loshchilov, I., and Hutter, F. (2019, January 6–9). Decoupled Weight Decay Regularization. Proceedings of the International Conference on Learning Representations, New Orleans, LA, USA.
45. Greedy function approximation: A gradient boosting machine10.1214/aos/1013203451 ↗