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

通过信息论分析检测本质代码克隆

Detecting Essence Code Clones via Information Theoretic Analysis

Lida Zhao, Shihan Dou, Yutao Hu, Yueming Wu, Jiahui Wu, Chengwei Liu, Lyuye Zhang, Yi Liu, Jun Sun, Xuanjing Huang, Yang Liu

AI总结:

本文提出ECScan工具,利用信息论评估代码行语义重要性,以检测传统方法难以发现的本质克隆,平均F1分数达85%,优于现有工具。

摘要:

代码克隆是软件开发中普遍存在的做法,涉及复制代码片段以节省时间,但往往以牺牲软件可维护性和质量为代价。在本文中,我们解决了检测“本质克隆”这一具体挑战,它是类型3克隆的一个复杂子类型,其特征是在外围代码不同的情况下共享关键逻辑。传统技术由于侧重于语法,常常无法检测到本质克隆。为了克服这一局限性,我们引入了ECScan,一种新颖的检测工具,它利用信息论来评估代码行的语义重要性。通过根据每行的信息内容为其分配权重,ECScan强调核心逻辑而非外围代码差异。我们在各种真实世界项目上的全面评估表明,ECScan在检测本质克隆方面显著优于现有工具,平均F1分数达到85%。它在所有克隆类型中表现出稳健的性能,并具有卓越的可扩展性。这项研究通过为开发者提供一个实用工具来增强代码质量和减轻维护负担,推进了克隆检测,通过创新的信息论方法强调代码的语义方面。

英文摘要:

Code cloning, a widespread practice in software development, involves replicating code fragments to save time but often at the expense of software maintainability and quality. In this paper, we address the specific challenge of detecting "essence clones", a complex subtype of Type-3 clones characterized by sharing critical logic despite different peripheral codes. Traditional techniques often fail to detect essence clones due to their syntactic focus. To overcome this limitation, we introduce ECScan, a novel detection tool that leverages information theory to assess the semantic importance of code lines. By assigning weights to each line based on its information content, ECScan emphasizes core logic over peripheral code differences. Our comprehensive evaluation across various real-world projects shows that ECScan significantly outperforms existing tools in detecting essence clones, achieving an average F1-score of 85%. It demonstrates robust performance across all clone types and offers exceptional scalability. This study advances clone detection by providing a practical tool for developers to enhance code quality and reduce maintenance burdens, emphasizing the semantic aspects of code through an innovative information-theoretic approach.

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

↑