AntiCopyPaster:在 IDE 中代码重复一经引入即提取
软件工程
2022-09-05 v2
摘要
我们为 IntelliJ IDEA 开发了一款名为 AntiCopyPaster 的插件,它跟踪 IDE 内代码段的粘贴行为,并建议适当的 Extract Method(提取方法)重构以抑制重复的扩散。与现有方法不同,我们的工具集成于开发者的工作流中,并主动推荐重构。由于并非所有代码段都需要被提取,我们构建了一个分类模型来做出该决策。当开发者复制并粘贴一段代码时,插件会在当前打开的文件中搜索重复项,等待一小段时间以允许开发者编辑代码,并最终基于若干特征推断重构决策。我们在从 13 个 Apache 项目中挖掘出的包含 18,942 个代码段的大型数据集上的实验研究表明,AntiCopyPaster 以 0.82 的 F-score 正确推荐 Extract Method 重构。此外,我们对 59 名开发者的调查反映了他们对所开发插件运行的满意度。该插件及其源代码已在 GitHub 上公开:https://github.com/JetBrains-Research/anti-copy-paster。演示视频可在 YouTube 上找到:https://youtu.be/_wwHg-qFjJY。
引用
@article{arxiv.2112.15230,
title = {AntiCopyPaster: Extracting Code Duplicates As Soon As They Are Introduced in the IDE},
author = {Eman Abdullah AlOmar and Anton Ivanov and Zarina Kurbatova and Yaroslav Golubev and Mohamed Wiem Mkaouer and Ali Ouni and Timofey Bryksin and Le Nguyen and Amit Kini and Aditya Thakur},
journal= {arXiv preprint arXiv:2112.15230},
year = {2022}
}
备注
4 pages, 3 figures