Return
Detecting Inline Code Comment Smells Leveraging CodeBERT Model
DOI:10.1109/ACCESS.2026.3666288.png)
Abstract
En 中文
Inline code comments provide contextual information within source code, potentially enhancing readability and maintainability. However, suboptimal commenting practices, commonly referred to as comment smells, can obscure code intent, reduce maintainability, and increase the likelihood of defects. Automated detection of these smells remains challenging due to their diverse manifestations and the interplay between code and natural language. In this paper, we present a model that leverages CodeBERT embeddings to detect and classify multiple types of inline comment smells. The method incorporates systematic preprocessing of code comment pairs, class balancing to mitigate skewed label distributions, and contextual representation learning to capture semantic and syntactic aspects of the code. The proposed approach is evaluated on a publicly available benchmark dataset comprising 2,189 manually annotated code–comment pairs extracted from open-source Java and Python projects. Evaluation on a benchmark dataset shows that CodeBERT consistently outperforms traditional machine/deep learning classifiers in accuracy and Matthews Correlation Coefficient (MCC), establishing a new state-of-the-art for multi-class comment-smell detection. These results demonstrate the effectiveness of pre-trained, code-aware language models for detecting inline comment smells in a software project. These findings highlight the promise of code-aware transformer models for automated assessment of inline comment quality in real-world software systems.
Keywords:
Inline code comments
comment smells
automated detection
CodeBERT embeddings
Journal
IF:
3.6
Papers:
9.8W
Citations:
29.4W

