A library that detects performed refactorings in changes in Kotlin code.
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:
- Move Class
- Rename Class
- Rename Method
- Add Parameter
- Remove Parameter
- Reorder Parameter
- Move Method
- Move And Rename Class
- Move And Rename Method
- Extract Method
- Inline Method
- Pull Up Method
- Push Down Method
- Extract Superclass
- Extract Class
- Extract Interface
- Extract And Move Method
- Move And Inline Method
- Change Attribute Type
- Change Variable Type
- Change Parameter Type
- Move Attribute
- Pull Up Attribute
- Push Down Attribute
- Rename Attribute
- Rename Variable
- Inline Variable
- Extract variable
kotlinRMiner is published in JitPack, you can add the dependency to your dependencies list:
implementation 'com.github.JetBrains-Research:kotlinRMiner:v1.2'
-
Clone the repository
git clone https://github.com/JetBrains-Research/kotlinRMiner.git
-
Run
./gradlew jar
in the project directory -
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.
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
If you have any questions or suggestions, don't hesitate to open an issue. If you want to contribute, please create pull requests.