arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2311.08778cs.SE
收藏

Gitor:通过构建全局样本图实现可扩展的代码克隆检测

Gitor: Scalable Code Clone Detection by Building Global Sample Graph

Junjie Shan, Shihan Dou, Yueming Wu, Hairu Wu, Yang Liu

AI总结:

提出Gitor方法,通过构建全局样本图并应用节点嵌入技术提取代码向量,结合代码特征进行相似性比较,有效提升了代码克隆检测的准确率和效率。

摘要:

代码克隆检测旨在找出相似的代码片段,由于其对软件维护和演化非常重要,因此在软件工程中备受关注。研究人员已经提出了许多用于源代码克隆检测的技术和工具,但当前的检测方法集中于单独分析或处理代码样本,而没有探索代码样本之间的潜在联系。在本文中,我们提出 Gitor 来捕获不同代码样本之间的潜在联系。具体而言,给定一个源代码数据库,我们首先对所有代码样本进行标记化以提取预定义的个体信息。在获得所有样本的个体信息后,我们利用它们构建一个大型全局样本图,其中每个节点是一个代码样本或一种类型的个体信息。然后,我们在全局样本图上应用节点嵌入技术来提取所有样本的向量表示。在收集所有代码样本向量后,我们可以简单地比较任意两个样本之间的相似性来检测可能的克隆对。更重要的是,由于获得的样本向量来自全局样本图,我们可以将其与自身的代码特征相结合以提高代码克隆检测性能。为了证明 Gitor 的有效性,我们在一个广泛使用的数据集即 BigCloneBench 上对其进行了评估。我们的实验结果表明,与现有的最先进工具相比,Gitor 在代码克隆检测方面具有更高的准确率,并且对于各种规模的输入具有出色的执行时间。此外,我们还评估了 Gitor 与其他传统的基于向量的克隆检测方法的结合,结果表明使用 Gitor 使它们能够检测出更多的代码克隆并具有更高的 F1。

英文摘要:

Code clone detection is about finding out similar code fragments, which has drawn much attention in software engineering since it is important for software maintenance and evolution. Researchers have proposed many techniques and tools for source code clone detection, but current detection methods concentrate on analyzing or processing code samples individually without exploring the underlying connections among code samples. In this paper, we propose Gitor to capture the underlying connections among different code samples. Specifically, given a source code database, we first tokenize all code samples to extract the pre-defined individual information. After obtaining all samples individual information, we leverage them to build a large global sample graph where each node is a code sample or a type of individual information. Then we apply a node embedding technique on the global sample graph to extract all the samples vector representations. After collecting all code samples vectors, we can simply compare the similarity between any two samples to detect possible clone pairs. More importantly, since the obtained vector of a sample is from a global sample graph, we can combine it with its own code features to improve the code clone detection performance. To demonstrate the effectiveness of Gitor, we evaluate it on a widely used dataset namely BigCloneBench. Our experimental results show that Gitor has higher accuracy in terms of code clone detection and excellent execution time for inputs of various sizes compared to existing state-of-the-art tools. Moreover, we also evaluate the combination of Gitor with other traditional vector-based clone detection methods, the results show that the use of Gitor enables them detect more code clones with higher F1.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑