Automatic detection of Long Method and God Class code smells through neural source code embeddings

•We compare machine learning approaches against heuristics for code smell detection.•We use metrics and code embeddings as code representations for machine learning.•We test the performance of smell detectors on the large manually labeled dataset.•CuBERT code embeddings outperform all code smell det...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:Expert systems with applications 2022-10, Vol.204, p.117607, Article 117607
Hauptverfasser: Kovačević, Aleksandar, Slivka, Jelena, Vidaković, Dragan, Grujić, Katarina-Glorija, Luburić, Nikola, Prokić, Simona, Sladić, Goran
Format: Artikel
Sprache:eng
Schlagworte:
Online-Zugang:Volltext
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Beschreibung
Zusammenfassung:•We compare machine learning approaches against heuristics for code smell detection.•We use metrics and code embeddings as code representations for machine learning.•We test the performance of smell detectors on the large manually labeled dataset.•CuBERT code embeddings outperform all code smell detection alternatives.•We perform an error analysis to discuss the advantages of the CuBERT approach. Code smells are structures in code that often harm its quality. Manually detecting code smells is challenging, so researchers proposed many automatic detectors. Traditional code smell detectors employ metric-based heuristics, but researchers have recently adopted a Machine-Learning (ML) based approach. This paper compares the performance of multiple ML-based code smell detection models against multiple metric-based heuristics for detection of God Class and Long Method code smells. We assess the effectiveness of different source code representations for ML: we evaluate the effectiveness of traditionally used code metrics against code embeddings (code2vec, code2seq, and CuBERT). This study is the first to evaluate the effectiveness of pre-trained neural source code embeddings for code smell detection to the best of our knowledge. This approach helped us leverage the power of transfer learning – our study is the first to explore whether the knowledge mined from code understanding models can be transferred to code smell detection. A secondary contribution of our research is the systematic evaluation of the effectiveness of code smell detection approaches on the same large-scale, manually labeled MLCQ dataset. Almost every study that proposes a detection approach tests this approach on the dataset unique for the study. Consequently, we cannot directly compare the reported performances to derive the best-performing approach.
ISSN:0957-4174
1873-6793
DOI:10.1016/j.eswa.2022.117607