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

12/30/2021
by   Anton Ivanov, et al.
0

We have developed a plugin for IntelliJ IDEA called AntiCopyPaster that tracks the pasting of code inside the IDE and suggests appropriate Extract Method refactorings to combat the propagation of duplicates. To implement the plugin, we gathered a dataset of code fragments that should and should not be extracted, compiled a list of metrics of code that can influence the decision, and trained several popular classifying machine learning models, of which a gradient boosting classifier showed the best results. When a developer pastes a code fragment, the plugin searches for duplicates in the currently opened file. If there are any, it waits for a short period of time to allow the developer to edit the code. If the code duplicates are still present after a delay, AntiCopyPaster calculates the metrics for the fragment and inferences the decision: if the fragment should be extracted, the plugin suggests to refactor it. This can help the developers to keep their code clean and save them future maintenance time by providing the possibility to refactor code timely and without losing the context. You can find the plugin and its source code on GitHub at https://github.com/JetBrains-Research/anti-copy-paster.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
11/22/2017

EMFET: E-mail Features Extraction Tool

EMFET is an open source and flexible tool that can be used to extract a ...
research
12/16/2018

The Adverse Effects of Code Duplication in Machine Learning Models of Code

The field of big code relies on mining large corpora of code to perform ...
research
04/03/2020

Visualization of Methods Changeability Based on VCS Data

Software engineers have a wide variety of tools and techniques that can ...
research
02/07/2023

Just-in-Time Code Duplicates Extraction

Refactoring is a critical task in software maintenance, and is usually p...
research
08/15/2021

On Multi-Modal Learning of Editing Source Code

In recent years, Neural Machine Translator (NMT) has shown promise in au...
research
03/26/2020

On-the-Fly Adaptation of Source Code Models using Meta-Learning

The ability to adapt to unseen, local contexts is an important challenge...
research
12/07/2021

IntelliTC: Automating Type Changes in IntelliJ IDEA

Developers often change the types of program elements. Such a refactorin...

Please sign up or login with your details

Forgot password? Click here to reset