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

重复日志语句及其与代码克隆关系的研究

Studying Duplicate Logging Statements and Their Relationships with Code Clones

Zhenhao Li, Tse-Hsun, Chen, Jinqiu Yang, Weiyi Shang

摘要:

在本文中,我们专注于研究重复日志语句,这是日志语句具有相同的静态文本消息。我们手动研究了五个大型开源系统中超过4K的重复日志语句及其周围的代码。我们发现了五种重复的日志代码气味模式。对于重复日志代码气味的每个实例,我们进一步手动识别潜在的问题和合理的情况。然后,我们联系开发人员来验证我们的手动研究结果。我们将我们的手动研究结果和开发人员的反馈集成到我们的自动化静态分析工具DLQs中,该工具可以自动检测有问题的重复日志代码气味。我们在五个手动研究的系统和三个额外的系统上评估了DLPERT。总的来说,结合DLQs的结果和我们的手动分析,我们向开发人员报告了91个有问题的重复日志记录代码气味实例,并且所有这些都已得到修复。我们进一步研究了重复日志记录语句之间的关系,包括重复日志记录代码气味和代码克隆的问题实例。我们发现,83%的重复日志记录代码气味实例驻留在克隆代码中,但其中17%驻留在微克隆中,使用自动克隆检测工具难以检测到。我们还发现,超过一半的重复日志语句驻留在克隆的代码片段,其中很大一部分驻留在很短的代码块,可能无法有效地检测到现有的代码克隆检测工具。我们的研究表明,除了实现业务逻辑的一般源代码外,代码克隆也可能导致不良的日志记录实践,从而增加维护难度。

英文摘要:

In this paper, we focus on studying duplicate logging statements, which are logging statements that have the same static text message. We manually studied over 4K duplicate logging statements and their surrounding code in five large-scale open source systems. We uncovered five patterns of duplicate logging code smells. For each instance of the duplicate logging code smell, we further manually identify the potentially problematic and justifiable cases. Then, we contact developers to verify our manual study result. We integrated our manual study result and the feedback of developers into our automated static analysis tool, DLFinder, which automatically detects problematic duplicate logging code smells. We evaluated DLFinder on the five manually studied systems and three additional systems. In total, combining the results of DLFinder and our manual analysis, we reported 91 problematic duplicate logging code smell instances to developers and all of them have been fixed. We further study the relationship between duplicate logging statements, including the problematic instances of duplicate logging code smells, and code clones. We find that 83% of the duplicate logging code smell instances reside in cloned code, but 17% of them reside in micro-clones that are difficult to detect using automated clone detection tools. We also find that more than half of the duplicate logging statements reside in cloned code snippets, and a large portion of them reside in very short code blocks which may not be effectively detected by existing code clone detection tools. Our study shows that, in addition to general source code that implements the business logic, code clones may also result in bad logging practices that could increase maintenance difficulties.

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

↑