Code smells are indicators of potential design problems in software systems and are commonly used to guide refactoring activities. Recent advances in representation learning have enabled the use of embedding-based models for analyzing source code, offering an alternative to traditional approaches based on manually engineered metrics. However, the effectiveness of different embedding representations for multiclass code smell detection remains insufficiently explored. This study presents an empirical comparison of embedding models for the automatic detection of three widely studied code smells: Long Method, God Class, and Feature Envy. Using the Crowdsmelling dataset as an empirical basis, source code fragments were extracted from the original projects and transformed into vector representations using two embedding approaches: a general-purpose embedding model and the code-specialized CodeBERT model. The resulting representations were evaluated using several machine learning classifiers under a stratified group-based validation protocol. The results show that CodeBERT consistently outperforms the general-purpose embeddings across multiple evaluation metrics, including balanced accuracy, macro F1-score, and Matthews correlation coefficient. Dimensionality reduction analyses using PCA and t-SNE further indicate that CodeBERT organizes code smell instances in a more structured latent representation space, which facilitates the separation of smell categories. In particular, CodeBERT achieved a macro F1-score of 0.8619, outperforming general-purpose embeddings (0.7622) and substantially surpassing a classical TF-IDF baseline (0.4555). These findings highlight the value of this study as a controlled multiclass evaluation of embedding representations and demonstrate the practical value of domain-specific representations for improving automated code smell detection and class separability in real-world software engineering scenarios.
Building similarity graph...
Analyzing shared references across papers
Loading...
Marcela Mosquera
Rodolfo Bojorque
Applied Sciences
National Polytechnic School
Politecnica Salesiana University
Building similarity graph...
Analyzing shared references across papers
Loading...
Mosquera et al. (Wed,) studied this question.
www.synapsesocial.com/papers/69d8962d6c1944d70ce077e3 — DOI: https://doi.org/10.3390/app16083622