Skip to content

Detects performed refactorings in the changes in Kotlin code

License

Notifications You must be signed in to change notification settings

JetBrains-Research/kotlinRMiner

Repository files navigation

kotlinRMiner

JB Research Build

A library that detects performed refactorings in changes in Kotlin code.

About

The library is based on RefactoringMiner, a tool that detects performed refactorings in code changes written in Java. The tool analyzes commit history of a Git project, parses code changes in each commit, uses detection rules and heuristics to detect performed refactorings, and returns a list of detected refactorings in each commit with a description.

Currently, kotlinRMiner supports the detection of the following refactorings:

  1. Move Class
  2. Rename Class
  3. Rename Method
  4. Add Parameter
  5. Remove Parameter
  6. Reorder Parameter
  7. Move Method
  8. Move And Rename Class
  9. Move And Rename Method
  10. Extract Method
  11. Inline Method
  12. Pull Up Method
  13. Push Down Method
  14. Extract Superclass
  15. Extract Class
  16. Extract Interface
  17. Extract And Move Method
  18. Move And Inline Method
  19. Change Attribute Type
  20. Change Variable Type
  21. Change Parameter Type
  22. Move Attribute
  23. Pull Up Attribute
  24. Push Down Attribute
  25. Rename Attribute
  26. Rename Variable
  27. Inline Variable
  28. Extract variable

Usage

As a dependency:

kotlinRMiner is published in JitPack, you can add the dependency to your dependencies list:

implementation 'com.github.JetBrains-Research:kotlinRMiner:v1.2'

As CLI:

  1. Clone the repository

    git clone https://github.com/JetBrains-Research/kotlinRMiner.git

  2. Run ./gradlew jar in the project directory

  3. Now you can use a library as CLI

    cd kotlinrminer-cli/build/libs

    java -jar kotlinRMiner-cli-1.0.jar <option>

The list of supported options:

    -c   <git-repo-folder> <commit-sha1>                            Detect refactorings at the specific commit <commit-sha1> for project <git-repo-folder>.
    -bc  <git-repo-folder> <start-commit-sha1> <end-commit-sha1>    Detect refactorings between <start-commit-sha1> and <end-commit-sha1> for a project <git-repo-folder>.    
    -all <git-repo-folder> <branch>                                 Detect all refactorings at the <branch> for <git-repo-folder>. If <branch> is not specified, commits from master branch are analyzed.

Example

To test the tool, you can clone the repository with the toy refactoring instances in Kotlin

git clone https://github.com/JetBrains-Research/kotlin-refactoring-samples

And run detection of refactorings in all commits in the mster branch

java -jar kotlinRMiner-cli-1.0.jar -all /path/to/kotlin-refactoring-samples master

Contacts

If you have any questions or suggestions, don't hesitate to open an issue. If you want to contribute, please create pull requests.

About

Detects performed refactorings in the changes in Kotlin code

Resources

License

Stars

Watchers

Forks

Packages

No packages published