Code smell detection is essential for maintaining and evolving software systems, yet effectively capturing the nuanced structure and semantics of code remains a significant challenge. This study investigates the use of Natural Language Processing (NLP) techniques for code smell detection, comparing traditional Deep Learning (DL) approaches and modern pretrained models. We evaluate various architectures, including Long Short-Term Memory (LSTM), Bidirectional Long Short Term Memory (BiLSTM) and Attention, focusing on detecting specific smells: feature envy, data class, blob and long methods. Additionally, we explore the potential of fine-tuning pretrained language models like CodeBERT on the Machine Learning Code Quality (MLCQ) dataset to enhance detection accuracy. Our experiments analyze the contributions of different model components like LSTM, BiLSTM and Attention Mechanisms to determine the optimal configurations for code smell detection. Results demonstrate that BiLSTM with Attention Mechanism significantly outperforms simple LSTM and previous baselines, particularly for certain code smells. While pretrained models like CodeBERT achieve comparable performance with less tuning and training time, BiLSTMs exhibit superior results in specific cases, highlighting trade-offs between efficiency and adaptability.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Exploring NLP Techniques for Code Smell Detection: A Comparative Study

  • Djamel Mesbah,
  • Nour El Madhoun,
  • Khaldoun Al Agha,
  • Hani Chalouati

摘要

Code smell detection is essential for maintaining and evolving software systems, yet effectively capturing the nuanced structure and semantics of code remains a significant challenge. This study investigates the use of Natural Language Processing (NLP) techniques for code smell detection, comparing traditional Deep Learning (DL) approaches and modern pretrained models. We evaluate various architectures, including Long Short-Term Memory (LSTM), Bidirectional Long Short Term Memory (BiLSTM) and Attention, focusing on detecting specific smells: feature envy, data class, blob and long methods. Additionally, we explore the potential of fine-tuning pretrained language models like CodeBERT on the Machine Learning Code Quality (MLCQ) dataset to enhance detection accuracy. Our experiments analyze the contributions of different model components like LSTM, BiLSTM and Attention Mechanisms to determine the optimal configurations for code smell detection. Results demonstrate that BiLSTM with Attention Mechanism significantly outperforms simple LSTM and previous baselines, particularly for certain code smells. While pretrained models like CodeBERT achieve comparable performance with less tuning and training time, BiLSTMs exhibit superior results in specific cases, highlighting trade-offs between efficiency and adaptability.