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

自动化检测与修补遗漏 TODO 的方法

Automating TODO-missed Methods Detection and Patching

Zhipeng Gao, Yanqi Su, Xing Hu, Xin Xia

AI总结:

提出遗漏 TODO 方法的检测与修补任务,并构建结合 GraphCodeBERT 与对比学习的 TDPatcher,在大规模 Python 仓库数据及真实项目中验证有效。

摘要:

TODO 注释被开发者广泛用于提醒自己或他人有关未完成的任务。换言之,TODO 注释通常与临时的或次优的解决方案相关联。在实践中,所有等价的次优实现都应当被同时更新(例如,添加 TODO)。然而,由于各种原因(例如时间紧张或粗心),开发者可能会忘记、甚至没有意识到要在所有必要位置添加 TODO 注释,从而产生遗漏 TODO 的方法。这些遗漏 TODO 的方法中“隐藏”的次优实现,长期来看可能损害软件质量和可维护性。因此,本文提出了遗漏 TODO 方法检测与修补这一新任务,并开发了一个名为 TDPatcher(TODO-comment Patcher)的新型模型,用于在软件项目中自动向遗漏 TODO 的方法修补 TODO 注释。该模型包含两个主要阶段:离线学习和在线推理。在离线学习阶段,TDPatcher 采用 GraphCodeBERT 和对比学习,将 TODO 注释(自然语言)及其次优实现(代码片段)编码为向量表示。在在线推理阶段,我们利用离线训练好的模型识别遗漏 TODO 的方法,并进一步确定其修补位置。我们通过从 GitHub 上排名前 10,000 的 Python 仓库中收集引入 TODO 的方法构建数据集,并在其上评估 TDPatcher。大量实验结果表明,该模型在一系列基准上表现出良好性能。我们还进一步进行了真实环境评估,从 50 个 GitHub 仓库中成功检测出 26 个遗漏 TODO 的方法。

英文摘要:

TODO comments are widely used by developers to remind themselves or others about incomplete tasks. In other words, TODO comments are usually associated with temporary or suboptimal solutions. In practice, all the equivalent suboptimal implementations should be updated (e.g., adding TODOs) simultaneously. However, due to various reasons (e.g., time constraints or carelessness), developers may forget or even are unaware of adding TODO comments to all necessary places, which results in the TODO-missed methods. These "hidden" suboptimal implementations in TODO-missed methods may hurt the software quality and maintainability in the long-term. Therefore, in this paper, we propose the novel task of TODO-missed methods detection and patching, and develop a novel model, namely TDPatcher (TODO-comment Patcher), to automatically patch TODO comments to the TODO-missed methods in software projects. Our model has two main stages: offline learning and online inference. During the offline learning stage, TDPatcher employs GraphCodeBERT and contrastive learning for encoding the TODO comment (natural language) and its suboptimal implementation (code fragment) into vector representations. For the online inference stage, we can identify the TODO-missed methods and further determine their patching position by leveraging the offline trained model. We built our dataset by collecting TODO-introduced methods from the top-10,000 Python GitHub repositories and evaluated TDPatcher on them. Extensive experimental results show the promising performance of our model over a set of benchmarks. We further conduct an in-the-wild evaluation which successfully detects 26 \textit{\major{TODO-missed} methods} from 50 GitHub repositories.

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

↑