Return
Building global sample graph for effective code clone detection
DOI:10.1016/j.jss.2026.113117.png)
Abstract
En 中文
Code clone detection aims to identify similar code fragments and is important for software maintenance and evolution. Existing techniques for code clone detection have achieved encouraging results, but most of them analyze code samples individually and do not explicitly exploit the underlying connections among code samples. In this paper, we propose Gitor to capture such connections for clone detection. Specifically, given a code database, we first tokenize code samples to extract individual information (i.e., keywords and code metrics). We then construct a global sample graph in which each node denotes either a code sample or a type of individual information. Based on this graph, we apply node embedding to obtain vector representations of code samples. Subsequently, we either compute cosine similarity to efficiently detect clone pairs or input these vectors into a neural network classifier to identify complex semantic clones. We conduct experiments on a widely used benchmark dataset and compare Gitor against popular clone detectors and deep learning-based methods, including the recently proposed baseline CC2Vec, while also considering LLM-based approaches. Experimental results show that Gitor achieves an F1 score of 0.99 and outperforms the compared deep learning-based detectors. For scalability, Gitor completes clone detection on one million code pairs, achieving a runtime reduction of over 95% compared with the baseline ASTNN. Furthermore, experiments on multiple code metrics show that most metric combinations surpass 0.90 precision at moderate thresholds, indicating that code metrics can effectively contribute to clone detection.
Journal
IF:
4.1
Papers:
5.5K
Citations:
8.4K
Organization
Cited Papers
No cited papers available

