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

针对代码克隆中潜在不一致性的Git提交日志实证分析

An Empirical Analysis of Git Commit Logs for Potential Inconsistency in Code Clones

Reishi Yokomori, Katsuro Inoue

AI总结:

本研究针对代码克隆对提交日志分析不足的问题,通过git-log分析Apache基金会45个仓库的克隆提交情况,发现克隆变更频率低、共同变更占比约一半且存在大量潜在不一致克隆对,凸显了克隆全周期一致性管理的必要性。

摘要:

代码克隆是指与同一文件或不同文件中其他代码片段相同或相似的代码片段,通常由复制粘贴操作产生,并在开发与维护过程中被修改。由于一对代码克隆(即克隆对)之间可能存在逻辑耦合关系,因此理论上两个片段的修改应同步(共同变更)且保持一致。目前已有大量关于代码克隆的研究,包括克隆共同变更相关的研究,但针对克隆对提交日志的详细分析仍较为有限。\n本文研究克隆对中代码片段的提交日志,使用git-log命令提取克隆代码片段的变更记录。我们分析了GitHub上Apache软件基金会旗下的45个代码仓库,围绕提交频率、共同变更率和提交模式三个研究问题展开分析。研究结果表明:(1)平均而言,克隆片段的变更频率较低,在其生命周期内通常仅被修改2到3次;(2)共同变更占所有克隆变更的比例约为一半,其中10-20%的共同变更提交存在隐患(即潜在不一致);(3)35-65%的克隆对被归类为隐患克隆对(即潜在不一致克隆对)。这些结果表明,有必要建立一套覆盖克隆全提交周期的一致性管理系统。

英文摘要:

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 and modified during development and maintenance activities. Since a pair of code clones, known as a clone pair, has a possible logical coupling between them, it is expected that changes to each snippet are made simultaneously (co-changed) and consistently. There is extensive research on code clones, including studies related to the co-change of clones; however, detailed analysis of commit logs for code clone pairs has been limited. In this paper, we investigate the commit logs of code snippets from clone pairs, using the git-log command to extract changes to cloned code snippets. We analyzed 45 repositories owned by the Apache Software Foundation on GitHub and addressed three research questions regarding commit frequency, co-change ratio, and commit patterns. Our findings indicate that (1) on average, clone snippets are changed infrequently, typically only two or three times throughout their lifetime, (2) the ratio of co-changes is about half of all clone changes, with 10-20\% of co-changed commits being concerning (potentially inconsistent), and (3) 35-65\% of all clone pairs being classified as concerning clone pairs (potentially inconsistent clone pairs). These results suggest the need for a consistent management system through the commit timeline of clones.

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

↑