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

对软件重设计中代码复用的调查:一个案例研究

Bidirectional Code Reuse in Software Redesign: An Action Research Study of Static Analyzers

Concordia University(康科迪亚大学);The University of Hong Kong(香港大学)

Xiaowen Zhang, Huaien Zhang, Shin Hwei Tan

AI总结:

本文通过案例研究探讨软件重设计中代码复用的挑战,提出语义对齐启发式方法和分层检测策略,提升克隆检测精度并减少冗余代码。

摘要:

软件重设计在保持功能的同时提高质量属性,但手动复用代码和测试成本高且易出错,特别是在跨仓库重设计中。本文通过行动研究方法,结合实证研究和验证的开源贡献,对Soot/SootUp重设计案例进行双向研究。研究揭示了非线性迁移、TODO延迟复用、测试移植被忽视和迁移中残留bug传播等问题。通过克隆检测改进获取原始与重设计项目间的代码映射,提出语义对齐启发式方法和可扩展的分层检测策略。在Soot/SootUp和FindBugs/SpotBugs两个重设计项目对上,方法在SAS阈值0.5下平均减少33-99%的无关克隆,精度提升至86%。此外,通过提交五个问题和十个pull request,其中八个已合并。

英文摘要:

Software redesign preserves functionality while improving quality attributes, but manual reuse of code and tests is costly and error-prone, especially in cross-repository redesigns. Focusing on static analyzers where cross-repository redesign needs often arise, we conduct a bidirectional study of the ongoing Soot/SootUp redesign using an action research methodology that combines empirical investigation with validated open-source contributions. Our study reveals: (1) non-linear migration that necessitates bidirectional reuse, (2) deferred reuse via TODOs, (3) neglected test porting, and (4) residual bug propagation during migrations. We identify tracking corresponding code and tests as the key challenge and address it by retrofitting clone detection to derive code mappings between original and redesigned projects. Guided by semantic reuse patterns derived from our study, we propose the Semantic Alignment Score (SAS), which incorporates semantic cues from preserved identifiers, API documentation, and comments. Evaluations on three redesigned project pairs (Soot/SootUp, FindBugs/SpotBugs, and ANTLR3/ANTLR4) show that SAS improves average F1 for code mapping detection by up to 0.34 on our manually labeled benchmark of 1,805 method pairs, while strong traditional detectors approach or surpass LLM detectors. The code mapping analysis also uncovered ongoing maintenance needs, leading to five issues and 10 pull requests, of which eight have been merged.

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

↑