Abstract
Maintaining alignment between source code and its documentation is a critical challenge in software engineering. This paper introduces a manually curated dataset of 3,636 Java methods from four open-source projects, specifically designed to evaluate "comment coherence"—the alignment between a method's lead comment and its implementation. Through a rigorous annotation process requiring over 800 man-hours, the study reveals that nearly 40% of methods exhibit "comment drift," where the lead comment no longer accurately reflects the implementation logic. This dataset provides a high-quality benchmark for training and testing automated tools to detect misleading documentation.
Introduction
In software development, natural language documentation—particularly "lead comments" preceding methods—is essential for understanding developer intent. However, as codebases evolve through refactoring and bug fixes, comments often become outdated, a phenomenon known as "comment drift." Incoherent comments are more than a minor annoyance; they can lead to architectural misunderstandings and introduce bugs. Despite the proliferation of Natural Language Processing (NLP) and Information Retrieval (IR) tools in software engineering, most assume comment accuracy. This work addresses the lack of large-scale, manually verified datasets needed to build tools that can automatically identify these discrepancies.
Methodology
The researchers employed a human-in-the-loop approach to ensure the highest data quality. Three annotators with Computer Science backgrounds evaluated methods using a structured checklist, categorizing them as Coherent, Non-Coherent, or Don’t Know.
To validate the reliability of these subjective assessments, the study utilized the Cohen’s Kappa index. Specifically, a "Weighted Kappa" was applied to account for the fact that a disagreement between "Coherent" and "Non-Coherent" is more significant than a disagreement involving a "Don't Know" response. Any remaining conflicts were resolved by two senior software engineering experts; methods without consensus were excluded.
Dataset Characteristics
The study analyzed 3,636 methods from four Java projects: CoffeeMaker, JFreeChart (v0.6.0 and v0.7.1), and JHotDraw (v7.4.1). After filtering for ambiguity and unresolved conflicts, the final "gold standard" dataset comprises 2,883 methods.
As shown in the data, the distribution reveals a significant presence of non-coherent comments across all systems. JHotDraw, in particular, presented unique challenges, exhibiting the lowest percentage of commented methods and the lowest agreement scores, likely due to the technical complexity and adherence to strict design patterns within that framework.
Key Insights and Results
The most significant finding is the prevalence of incoherence: approximately 40% of the methods in the final dataset were labeled as non-coherent. This confirms that comment drift is a pervasive issue even in established, open-source codebases.
The high Kappa scores (exceeding 0.80 for three of the four projects) demonstrate that "comment coherence" is a property that can be reliably identified by humans. The inclusion of a "Don't Know" option served as a critical safety valve, ensuring that the final benchmark consists only of clear, unambiguous examples of coherence or drift.
Conclusion and Future Work
This new dataset fills a vital gap in software engineering research, providing the community with a reliable benchmark for automated coherence-checking. Future research directions include expanding the scope to other programming languages and inline comments, as well as longitudinal studies to track how coherence degrades over successive software versions. Ultimately, this data paves the way for integrating real-time coherence checks into developer environments using modern Large Language Models (LLMs).
Summary updated