arrow
Return

COSTAR: Software Code Smell Detection Through Tree-Based Abstract Representation

delete2026-01-01
delete0
PRE
AI
M
Mahipal Jadeja
S
Satyendra Singh Chouhan
S
Santosh Singh Rathore
DOI:10.1109/TR.2025.3648404delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Code smells are suboptimal code structures that increase software maintenance costs and are challenging to detect manually. Researchers have explored automatic code smell detection using machine learning (ML) methods, which rely heavily on static code metrics or source code representation. Static code metrics often rely on structural attributes, such as lines of code, cyclomatic complexity, or comment density. However, these metrics do not always reflect true code complexity and provide only quantitative insights without inherently detecting poor coding practices. In contrast, representations such as abstract syntax trees (ASTs) focus on the structural and syntactic elements of code, capturing hierarchical and contextual relationships within the source code. This enables precise identification of code structures such as loops, function calls, and conditionals, which are essential for detecting code smells. This article introduces code smell detection through tree-based abstract representation (COSTAR), a source code representation technique using ASTs to uniquely represent each source code instance. COSTAR captures the hierarchical structure of the source code by extracting all paths from the root to individual nodes within the AST. By employing a pretrained sentence bidirectional encoder representations from transformers embedding model, COSTAR generates vectors for each extracted path. The subsequent calculation of the mean of these vectors yields a precise and comprehensive source code representation. Extensive experiments were conducted to validate COSTAR's performance using various ML techniques on four benchmark MLCQ code smell datasets: Data Class, God Class (Blob), Feature Envy, and Long Method. Various performance metrics have been employed to evaluate the model's performance. The experimental results indicate that COSTAR enhances the performance of the code smell detection model compared to existing methods. An improvement in the F1-score ranging from 0.03 (Long Method) to 0.19 (Feature Envy) was observed. Furthermore, a comparison of COSTAR with state-of-the-art methods demonstrated that it outperformed approaches such as Code2Vec and CuBERT in code smell detection.
Keywords:
Code smell prediction
empirical study
imbalance learning
software maintainability
source code representation

Journal

IEEE Transactions on Reliability cover
IEEE Transactions on Reliability
IF:
5.7
Papers:
2.7K
Citations:
8.5K

Organization

A
abv-iiitm gwalior
Scholars:
14
Papers: 7
Citations: 0
M
malaviya national institute of technology
Scholars:
163
Papers: 89
Citations: 0
Cited Papers

Cited Papers

Automatic detection of Long Method and God Class code smells through neural source code embeddings
err2022-10-01
err25
errOAAI
errKovacevic, Aleksandar; Slivka, Jelena; Vidakovic, Dragan; Grujic, Katarina-Glorija; Luburic, Nikola; Prokic, Simona; Sladic, Goran
errShare
errSave
MLCQ
err2020-04-17
err0
PREAI
errLech Madeyski; Tomasz Lewowski
errShare
errSave
errShare
errSave
Comparing and experimenting machine learning techniques for code smell detection
err2015-06-06
err277
PREAI
errFontana, Francesca Arcelli; Mantyla, Mika V.; Zanoni, Marco; Marino, Alessandro
errShare
errSave
errShare
errSave
researcher View more