CloneBAS: A Code Clone Detection Method Based on Abstract Syntax Tree and Simhash
Hongkui He, Liannan Lin, Tianchen Yu, Xinlei Zhong · 2023
Code clone, which is one of the common “code smells”, is the duplicate code that exists in the source code. In this paper, we present CloneBAS, a code clone detection method based on Abstract Syntax Tree (AST) and Simhash. First, code block is considered as the detection granularity. Second, a fixed-length fingerprint with the AST of each code block is generated. As a result, multi-type clone detection capabilities are achieved. Third, based on the Hamming distance restriction, clone fingerprint groups and their corresponding clone code block groups are attained. Source codes from four projects are selected as subjects and the clone detectors of CCFinderSW and Deckard are compared with CloneBAS in our experiments. In terms of clone quality, the lowest accuracy of over 86% is achieved, which is better than the highest accuracy of 74% of the two comparators. In terms of clone quantity, Deckard is outperformed by CloneBAS in three projects.