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. Our experimental study on a large dataset of 18,942 code fragments mined from 13 Apache projects shows that AntiCopyPaster correctly recommends Extract Method refactorings with an F-score of 0.82. Furthermore, our survey of 59 developers reflects their satisfaction with the developed plugin's operation. The plugin and its source code are publicly available on GitHub at https://github.com/JetBrains-Research/anti-copy-paster. The demonstration video can be found on YouTube: https://youtu.be/_wwHg-qFjJY.
翻译:我们为IntelliJIDA开发了一个名为 AntiCopyPaster 的插件, 这个插件追踪了代码碎片在 IDE 内部的粘贴, 并推荐了适当的抽取方法, 以对抗复制品的传播。 与现有方法不同, 我们的工具与开发者的工作流程融合在一起, 并主动建议重新设置。 由于并非所有代码碎片都需要提取, 我们开发了一个分类模型来做出这一决定。 当开发者复制并粘贴了一个代码碎片时, 插件搜索了当前打开的文件中的复制件, 等待了一段短暂的时间让开发者编辑代码, 最后根据一些特性推断了重新设置决定。 我们对13个Apache项目中开采的18, 942个代码碎片的实验研究表明, AntiCopyPaster 正确推荐了使用 F- coest 0. 82 。 此外, 我们对59 开发者的调查反映了他们对于开发插件操作的满意度, 等待一个短时间, 等待开发者来编辑代码, 并最后根据一些特性推断了重新设置决定。 我们的插件及其源代码在 GiHubbbs/ gis- gismabrusmabs/ repusmusmusmusmusy_subrmabrusmusmusmusmusmusmusy/ ab.