Modern software development has become increasingly complex, leading to larger codebases and longer development cycles. To maintain code quality, developers often detect and address code smells through software refactoring, patterns in code that compromise encapsulation, concentrate excessive responsibilities into single components, and undermine both readability and long-term maintainability. While recent research has explored machine learning techniques for code smell detection, a substantial proportion of existing methods rely on models not specifically designed for NLP, such as gradient-boosted trees trained predominantly on hand-crafted software metrics, a reliance that limits the semantic depth these approaches can capture, leaving the potential of NLP-oriented pretrained models largely underexplored. To address this gap, this paper presents a semantic code smell detection comprehensively evaluated with CodeBERT and CodeT5, transformer-based models that take raw source code directly as input, enabling richer semantic representations than hand-crafted software metrics can provide, with a focus on two key aspects: input chunking strategies and text-level data augmentation techniques. For chunking, we evaluate both static and sliding-window methods to mitigate transformer input length limitations. For augmentation, we investigate the effect of Self-Supervised Manifold-Based Data Augmentation (SSMBA) and Easy Data Augmentation (EDA) on model performance. All experiments are conducted on the MLCQ dataset, encompassing three code smell types, Data Class, God Class, and Long Method, each formulated as a binary classification task. Experimental results demonstrate that CodeT5 paired with EDA using Random Swap augmentation suggesting the promise of NLP oriented pretrained models combined with data augmentation for source-code-level code smell detection. The source code is available at: https: //github. com/arttiwat/CodeSmellDetection/tree/main
Werawatganon et al. (Wed,) studied this question.