Are your comments outdated? Towards automatically detecting code-comment
consistency
- URL: http://arxiv.org/abs/2403.00251v1
- Date: Fri, 1 Mar 2024 03:30:13 GMT
- Title: Are your comments outdated? Towards automatically detecting code-comment
consistency
- Authors: Yuan Huang, Yinan Chen, Xiangping Chen, Xiaocong Zhou
- Abstract summary: Outdated comments are dangerous and harmful and may mislead subsequent developers.
We propose a learning-based method, called CoCC, to detect the consistency between code and comment.
Experiment results show that CoCC can effectively detect outdated comments with precision over 90%.
- Score: 3.204922482708544
- License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
- Abstract: In software development and maintenance, code comments can help developers
understand source code, and improve communication among developers. However,
developers sometimes neglect to update the corresponding comment when changing
the code, resulting in outdated comments (i.e., inconsistent codes and
comments). Outdated comments are dangerous and harmful and may mislead
subsequent developers. More seriously, the outdated comments may lead to a
fatal flaw sometime in the future. To automatically identify the outdated
comments in source code, we proposed a learning-based method, called CoCC, to
detect the consistency between code and comment. To efficiently identify
outdated comments, we extract multiple features from both codes and comments
before and after they change. Besides, we also consider the relation between
code and comment in our model. Experiment results show that CoCC can
effectively detect outdated comments with precision over 90%. In addition, we
have identified the 15 most important factors that cause outdated comments, and
verified the applicability of CoCC in different programming languages. We also
used CoCC to find outdated comments in the latest commits of open source
projects, which further proves the effectiveness of the proposed method.
Related papers
- Understanding Code Understandability Improvements in Code Reviews [79.16476505761582]
We analyzed 2,401 code review comments from Java open-source projects on GitHub.
83.9% of suggestions for improvement were accepted and integrated, with fewer than 1% later reverted.
arXiv Detail & Related papers (2024-10-29T12:21:23Z) - Codev-Bench: How Do LLMs Understand Developer-Centric Code Completion? [60.84912551069379]
We present the Code-Development Benchmark (Codev-Bench), a fine-grained, real-world, repository-level, and developer-centric evaluation framework.
Codev-Agent is an agent-based system that automates repository crawling, constructs execution environments, extracts dynamic calling chains from existing unit tests, and generates new test samples to avoid data leakage.
arXiv Detail & Related papers (2024-10-02T09:11:10Z) - Code Documentation and Analysis to Secure Software Development [0.0]
CoDAT is a tool designed to maintain consistency between the various levels of code documentation.
It is implemented in the Intellij IDEA.
We use a large language model to check the semantic consistency between a fragment of code and the comments that describe it.
arXiv Detail & Related papers (2024-07-16T17:25:44Z) - Comments as Natural Logic Pivots: Improve Code Generation via Comment Perspective [85.48043537327258]
We propose MANGO (comMents As Natural loGic pivOts), including a comment contrastive training strategy and a corresponding logical comment decoding strategy.
Results indicate that MANGO significantly improves the code pass rate based on the strong baselines.
The robustness of the logical comment decoding strategy is notably higher than the Chain-of-thoughts prompting.
arXiv Detail & Related papers (2024-04-11T08:30:46Z) - Exploring the Advances in Identifying Useful Code Review Comments [0.0]
This paper reflects the evolution of research on the usefulness of code review comments.
It examines papers that define the usefulness of code review comments, mine and annotate datasets, study developers' perceptions, analyze factors from different aspects, and use machine learning classifiers to automatically predict the usefulness of code review comments.
arXiv Detail & Related papers (2023-07-03T00:41:20Z) - CONCORD: Clone-aware Contrastive Learning for Source Code [64.51161487524436]
Self-supervised pre-training has gained traction for learning generic code representations valuable for many downstream SE tasks.
We argue that it is also essential to factor in how developers code day-to-day for general-purpose representation learning.
In particular, we propose CONCORD, a self-supervised, contrastive learning strategy to place benign clones closer in the representation space while moving deviants further apart.
arXiv Detail & Related papers (2023-06-05T20:39:08Z) - Code Comment Inconsistency Detection with BERT and Longformer [9.378041196272878]
Comments, or natural language descriptions of source code, are standard practice among software developers.
When the code is modified without an accompanying correction to the comment, an inconsistency between the comment and code can arise.
We propose two models to detect such inconsistencies in a natural language inference (NLI) context.
arXiv Detail & Related papers (2022-07-29T02:43:51Z) - ReACC: A Retrieval-Augmented Code Completion Framework [53.49707123661763]
We propose a retrieval-augmented code completion framework, leveraging both lexical copying and referring to code with similar semantics by retrieval.
We evaluate our approach in the code completion task in Python and Java programming languages, achieving a state-of-the-art performance on CodeXGLUE benchmark.
arXiv Detail & Related papers (2022-03-15T08:25:08Z) - Deep Just-In-Time Inconsistency Detection Between Comments and Source
Code [51.00904399653609]
In this paper, we aim to detect whether a comment becomes inconsistent as a result of changes to the corresponding body of code.
We develop a deep-learning approach that learns to correlate a comment with code changes.
We show the usefulness of our approach by combining it with a comment update model to build a more comprehensive automatic comment maintenance system.
arXiv Detail & Related papers (2020-10-04T16:49:28Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.