Source Code Comments: Overlooked in the Realm of Code Clone Detection

by   Sandeep Kaur Kuttal, et al.

Reusing code can produce duplicate or near-duplicate code clones in code repositories. Current code clone detection techniques, like Program Dependence Graphs, rely on code structure and their dependencies to detect clones. These techniques are expensive, using large amounts of processing power, time, and memory. In practice, programmers often utilize code comments to comprehend and reuse code, as comments carry important domain knowledge. But current code detection techniques ignore code comments, mainly due to the ambiguity of the English language. Recent advances in information retrieval techniques may have the potential to utilize code comments for clone detection. We investigated this by empirically comparing the accuracy of detecting clones with solely comments versus solely source code (without comments) on the JHotDraw package, which contains 315 classes and 27K lines of code. To detect clones at the file level, we used a topic modeling technique, Latent Dirichlet Allocation, to analyze code comments and GRAPLE – utilizing Program Dependency Graph – to analyze code. Our results show 94.86 recall and 84.21 precision with Latent Dirichlet Allocation and 28.7 recall and 55.39 precision using GRAPLE. We found Latent Dirichlet Allocation generated false positives in cases where programs lacked quality comments. But this limitation can be addressed by using a hybrid approach: utilizing code comments at the file level to reduce the clone set and then using Program Dependency Graph-based techniques at the method level to detect precise clones. Our further analysis across Java and Python packages, Java Swing and PyGUI, found a recall of 74.86% and a precision of 84.21%. Our findings call for reexamining the assumptions regarding the use of code comments in current clone detection techniques.


page 1

page 5


Analyzing Code Comments to Boost Program Comprehension

We are trying to find source code comments that help programmers underst...

Recommending Insightful Comments for Source Code using Crowdsourced Knowledge

Recently, automatic code comment generation is proposed to facilitate pr...

PENTACET data – 23 Million Contextual Code Comments and 500,000 SATD comments

Most Self-Admitted Technical Debt (SATD) research utilizes explicit SATD...

Preprocessing Source Code Comments for Linguistic Models

Comments are an important part of the source code and are a primary sour...

Deep Just-In-Time Inconsistency Detection Between Comments and Source Code

Natural language comments convey key aspects of source code such as impl...

Characterising the Knowledge about Primitive Variables in Java Code Comments

Primitive types are fundamental components available in any programming ...

Exploring the Generality of a Java-based Loop Action Model for the Quorum Programming Language

Many algorithmic steps require more than one statement to implement, but...

Please sign up or login with your details

Forgot password? Click here to reset