Skip to content

A tool to compare different versions of Java source code to find refactoring changes between them

License

Notifications You must be signed in to change notification settings

matrixxun/RefDiff

 
 

Repository files navigation

RefDiff

RefDiff is a tool to detect refactorings applied to Java code in git repositories.

The following types of refactoring are supported:

  • Rename Type
  • Move Type
  • Move and Rename Type
  • Extract Supertype
  • Rename Method
  • Change Method Signature
  • Pull Up Method
  • Push Down Method
  • Move Method
  • Extract Method
  • Inline Method
  • Pull Up Field
  • Push Down Field
  • Move Field

Usage

The easiest way to get RefDiff is from the Mavel Central. Declare it as a dependency in your build system (Maven, Gradle, etc). For example:

<dependency>
  <groupId>com.github.aserg-ufmg</groupId>
  <artifactId>refdiff-core</artifactId>
  <version>0.1.1</version>
</dependency>

Then, you can detect refactoring in a certain repository/commit using the following code:

RefDiff refDiff = new RefDiff();
GitService gitService = new GitServiceImpl(); 
try (Repository repository = gitService.cloneIfNotExists("C:/tmp/clojure", "https://github.com/refdiff-data/clojure.git")) {
    List<SDRefactoring> refactorings = refDiff.detectAtCommit(repository, "17217a1");
    for (SDRefactoring refactoring : refactorings) {
        System.out.println(refactoring.toString());
    }
}

See more details in this tutorial

Example

The following figure shows the number of refactorings detected by RefDiff when executed over all commits of JUnit4.

Junit4 results

Building from the source code

RefDiff uses Gradle as the build system. If you would like to work with the source code of RefDiff, clone the repository and run the following command inside the folder:

./gradlew eclipse

This will create Eclipse metadata for the project. Now, you can import the project refdiff-core into Eclipse IDE and work with the source code.

Publications

The algorithm RefDiff uses is described in details in the following paper:

The data used in the evaluation is available in this spreadsheet.

Learn more about our research group at http://aserg.labsoft.dcc.ufmg.br/

About

A tool to compare different versions of Java source code to find refactoring changes between them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.4%
  • HTML 1.6%