Code clones are code snippets that are identical or similar to other snippets within the same or different files. They are often created through copy-and-paste practices during development and maintenance activities. Since code clones may require consistent updates and coherent management, they present a challenging issue in software maintenance. Therefore, many studies have been conducted to find various types of clones with accuracy, scalability, or performance. However, the exploration of the nature of code clones has been limited. Even the fundamental question of whether code snippets in the same clone set were written by the same author or different authors has not been thoroughly investigated. In this paper, we investigate the characteristics of code clones with a focus on authorship. We analyzed the authorship of code clones at the line-level granularity for Java files in 153 Apache projects stored on GitHub and addressed three research questions. Based on these research questions, we found that there are a substantial number of clone lines across all projects (an average of 18.5\% for all projects). Furthermore, authors who contribute to many non-clone lines also contribute to many clone lines. Additionally, we found that one-third of clone sets are primarily contributed to by multiple leading authors. These results confirm our intuitive understanding of clone characteristics, although no previous publications have provided empirical validation data from multiple projects. As the results could assist in designing better clone management techniques, we will explore the implications of developing an effective clone management tool.
翻译:代码克隆是指在同一或不同文件中与其他代码片段相同或相似的代码片段。它们通常通过开发和维护过程中的复制粘贴行为产生。由于代码克隆可能需要一致更新和协调管理,这给软件维护带来了挑战性问题。因此,已有大量研究致力于以准确性、可扩展性或性能为目标来发现各类克隆。然而,对代码克隆本质的探索仍十分有限。即便是同一克隆集合中的代码片段是否由同一作者或不同作者编写这一基本问题,也未得到深入研究。本文聚焦作者身份,探究代码克隆的特征。我们以行为粒度分析了存储在GitHub上的153个Apache项目中Java文件的代码克隆作者身份,并回答了三个研究问题。基于这些研究问题,我们发现所有项目中存在大量克隆行(各项目平均克隆行占比为18.5%)。此外,贡献大量非克隆行的作者也贡献了大量克隆行。同时,我们发现三分之一的克隆集合主要由多位主要作者共同贡献。这些结果印证了我们对克隆特征的直观理解,尽管此前尚无出版物提供来自多个项目的实证验证数据。由于这些结果有助于设计更好的克隆管理技术,我们将探索开发有效克隆管理工具的相关启示。