arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2107.04712cs.SE
收藏

论开源Java项目中代码克隆的本质

On the Nature of Code Cloning in Open-Source Java Projects

Yaroslav Golubev, Timofey Bryksin

摘要:

代码克隆在开源软件工程中起着非常重要的作用。项目中存在克隆可能表明需要重构,而项目之间的克隆则更有趣,因为会发生代码迁移,并且可能会发生冲突。但是代码是如何被复制的呢?这个过程有多普遍,在什么水平上发生?在这个一般性的研究中,我们试图通过在文件和方法级别上搜索超过23000个Java项目的大型数据集中的克隆,并通过研究代码片段本身及其克隆对来阐明这些问题。我们研究的大小和年龄的代码片段,其克隆的流行,精确和非精确克隆之间的关系,以及方法级和文件级克隆之间。我们还发现并描述了数据集中检测到的代码克隆中的各种异常。我们的研究表明,在Java代码存在的这些年里,复制一直在发生,方法级复制比文件级复制更普遍,只有35.4%的方法根本没有克隆。此外,发现的一些异常可能对未来的大规模克隆研究有用,因为它们可以用于删除自动生成的代码。

英文摘要:

Code cloning plays a very important role in open-source software engineering. The presence of clones within a project may indicate a need for refactoring, and clones between projects are even more interesting, since code migration takes place and violations are possible. But how is code being copied? How prevalent is the process and on what level does it happen? In this general study, we attempt to shed some light on these questions by searching for clones in a large dataset of over 23 thousand Java projects on the level of both files and methods, and by studying the code fragments themselves and their clone pairs. We study the size and the age of code fragments, the prevalence of their clones, relationships between exact and non-exact clones, as well as between method-level and file-level clones. We also discover and describe various anomalies in the code clones that were detected in the dataset. Our research shows that the copying occurs all through the years of the Java code existence and that method-level copying is much more prevalent than file-level copying, with only 35.4% of methods having no clones at all. Additionally, some of the discovered anomalies can be useful for future large-scale cloning research as they can be used for removing auto-generated code.

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

↑