AntiCopyPaster: Extracting Code Duplicates As Soon As They Are Introduced in the IDE

Eman Abdullah AlOmar, Anton Ivanov, Zarina Kurbatova, Yaroslav Golubev, Mohamed Wiem Mkaouer +5 more
12/30/2021
12 citations
cs.SE

Official code: JetBrains-Research/anti-copy-paster (101 stars, Java, Apache-2.0, last commit 2023-03-30). Most starred: tsantalis/RefactoringMiner, a community implementation (516 stars, Java, MIT, last commit 2026-11-13, 5.1× the official stars). 1 more implementation below.

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
JetBrains-Research/anti-copy-pasterOfficial101JavaApache-2.02023-03-30
tsantalis/RefactoringMinerCommunity516JavaMIT2026-11-13
Apache-2.0

A plugin for IntelliJ IDEA for extracting code duplicates into a new method as soon as they are introduced.

10111Java, PureBasicOct 21, 20193 years agoApache-2.0
MIT
516168Java, PythonSep 29, 20152 weeks agoMIT
refactoring

Similar Papers

Cite this paper

@article{alomar2021anticopypaster,
  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},
  year   = {2021},
  eprint = {2112.15230},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2112.15230}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2112.15230.svg)](https://codeofpaper.com/paper/2112.15230)

Discussion