一句话:在 IDE 中追踪代码粘贴,实时检测重复并主动建议 Extract Method 重构,并用分类模型决定是否推荐。
代码重复的传播会加重维护负担,而现有重构推荐方法往往脱离开发者工作流,无法在重复刚引入时及时干预。本文提出 AntiCopyPaster,一个 IntelliJ IDEA 插件。它跟踪 IDE 内的代码复制粘贴操作,在开发者粘贴片段后搜索当前打开文件中的重复,并等待短暂时间让开发者继续编辑,最后基于一组特征用分类模型判断是否需要提取。与已有方法不同,该工具主动、即时地推荐 Extract Method 重构,而非事后或离线分析。摘要未报告具体的用户实验或量化评估结果。
We developed a plugin for IntelliJ IDEA called AntiCopyPaster, which tracks the pasting of code fragments inside the IDE and suggests the appropriate Extract Method refactoring to combat the propagation of duplicates. Unlike the existing approaches, our tool is integrated with the developer’s workflow, and pro-actively recommends refactorings. Since not all code fragments need to be extracted, we develop a classification model to make this decision. When a developer copies and pastes a code fragment, the plugin searches for duplicates in the currently opened file, waits for a short period of time to allow the developer to edit the code, and finally inferences the refactoring decision based on a number of features.
@inproceedings{paperbot7205,
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},
booktitle = {ASE},
year = {2022},
doi = {10.1145/3551349.3559537}
}