Detecting Inline Code Comment Smells Leveraging CodeBERT Model

Read full text
Authors: Sajjad Mahmood
Cited by: 1
References: 25

Abstract

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 thatCodeBERTconsistently 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.

Fields of Study & Subjects

Software Engineering Research Hate Speech and Cyberbullying Detection Topic Modeling

Publication details

Journal / source
IEEE Access
Publisher
Institute of Electrical and Electronics Engineers (IEEE)
Volume
14
Pages
28367–28382
Publication date
1 January 2026