一句话:提出基于 token N-gram 与倒排索引的可扩展克隆检测工具 NIL,能高效检测大规模代码库中的大差异克隆。
代码克隆检测中,大差异克隆(修改分散)和大间隔克隆(修改集中)难以被通用技术发现,且现有方法无法在大规模代码库上快速检测。本文提出可扩展的克隆检测技术 NIL,其核心是基于 token 的检测器:先用 token 序列的 N-gram 表示和倒排索引高效筛选候选克隆,再通过最长公共子序列(LCS)度量相似度来验证候选。作者在 1–250 MLOC 的不同规模输入上评估 NIL 的大差异克隆检测精度、通用 Type-1/2/3 克隆检测精度和可扩展性。实验表明,与现有最优工具相比,NIL 在大差异克隆检测上精度更高,在通用克隆检测上精度相当,并在各种输入规模下执行时间最短。
A code clone (in short, clone) is a code fragment that is identical or similar to other code fragments in source code. Clones generated by a large number of changes to copy-and-pasted code fragments are called large-variance (modifications are scattered) or large-gap (modifications are in one place) clones. It is difficult for general clone detection techniques to detect such clones and thus specialized techniques are necessary. In addition, with the rapid growth of software development, scalable clone detectors that can detect clones in large codebases are required. However, there are no existing techniques for quickly detecting large-variance or large-gap clones in large codebases. In this paper, we propose a scalable clone detection technique that can detect large-variance clones from large codebases and describe its implementation, called NIL. NIL is a token-based clone detector that efficiently identifies clone candidates using an N-gram representation of token sequences and an inverted index. Then, NIL verifies the clone candidates by measuring their similarity based on the longest common subsequence between their token sequences. We evaluate NIL in terms of large- variance clone detection accuracy, general Type-1, Type-2, and Type- 3 clone detection accuracy, and scalability. Our experimental results show that NIL has higher accuracy in terms of large-variance clone detection, equivalent accuracy in terms of general clone detection, and the shortest execution time for inputs of various sizes (1–250 MLOC) compared to existing state-of-the-art tools.
DOI 原文 ·
@inproceedings{paperbot6375,
title = {NIL: large-scale detection of large-variance clones},
author = {Tasuku Nakagawa and Yoshiki Higo and Shinji Kusumoto},
booktitle = {FSE},
year = {2021},
doi = {10.1145/3468264.3468564}
}