This is the repository for Micro-change Miner.
Micro-changes are a set of code change
operations described in natural language, designed to bridge
the cognitive divide by translating the textual diffs into more
understandable natural-language described operations
- Micro-Change Miner
If you're using macOS or Linux and have make installed, you can skip manual setup. Just run:
$ make example-analysisThis will:
- Clone and build required tools (
git-stein,RefactoringMiner) - Set up directories
- Mine micro-changes from an example repository mbassador
If you prefer to install things manually, follow the steps below instead of using make
Install the following tools before using Micro-Change Miner
Used to convert Git repositories into method-level history.
- git-stein: Convert Git repository to method-level
$ git clone https://github.com/sh5i/git-stein.git
$ cd git-stein
$ ./gradlew executableJarWe use the RefactoringMiner, which is the state of the art refactoring mining tool, to capture refactorings.
- Note that in the paper, we extend the RefactoringMiner3.0.4 by considering the refactoring affected elements' locations
Install via Homebrew:
$ brew install gradleClone and build the project:
$ git clone git@github.com:MashiroCl/MicroChangeMiner.git
$ cd MicroChangeMiner
$ ./gradlew shadowJar$ java -jar <git-stein_path/build/libs/git-stein.jar> <target_repo_path> -o <output_repo_path> @historage-jdt --no-original --no-classes --no-fields --parsable --mapping Obtain a map from a method-level repository whose key is the original repository sha1, value is the corresponding method-level repository sha1, i.e. <original_sha1:method-level_sha1>
$ java -jar build/libs/miner-1.0-SNAPSHOT-all.jar commitMap -p <method_level_repo_path/.git> -o <output_jsonfile.json>$ java -jar build/libs/miner-1.0-SNAPSHOT-all.jar refmine <RefactoringMiner_path> <original_repo_path> <output_dir> >./runLog/<repo_name>_rm.log$ java -jar build/libs/miner-1.0-SNAPSHOT-all.jar mine <method_level_repo_path/.git> <output_json_path.json> --csv <output_csv_path.csv> --map <commit_map_path> --refactoring <mined_refactoring_directory> --original <original_repo_path/.git> --notCoveredPath <output_path_for_uncovered> >runLog/<repo_name>.log Example for mbassador:
$ java -jar build/libs/miner-1.0-SNAPSHOT-all.jar mine ./method_level/mbassador/.git ./mined/mbassador.json --csv ./mined/mbassador.csv --map ./commitMap/mbassador.json --refactoring ./minedRefactoring/mbassador --original ./OSS/mbassador/.git --notCoveredPath ./notCovered/mbassador.json >runLog/mbassador.logpublic class YourMicroChange implements MicroChangePattern{
@Override
public boolean matchConditionGumTree(Action action, Map<Tree, Tree> mappings) {
// Implement the match strategy here
// if you need the actions for all, implement the same name method below
return false;
}
@Override
public boolean matchConditionGumTree(Action action, Map<Tree, Tree> mappings, Map<Tree, List<Action>> nodeActions) {
// Implement the match strategy here
return false;
}
@Override
public SrcDstRange getSrcDstRange(Action action, Map<Tree, Tree> mappings, Map<Tree, List<Action>> nodeActions, EditScriptStorer editScriptStorer) {
// get the line range of this micro-change
SrcDstRange srcDstRange = new SrcDstRange();
// left side range
// right side range
return srcDstRange;
}
}2. Register your own micro-change for mining in org.mashirocl.command.MineCommand#loadMicroChanges()
public static void loadMicroChanges(PatternMatcher patternMatcherGumTree) {
patternMatcherGumTree.addMicroChange(new AddConjunctOrDisjunct());
...
patternMatcherGumTree.addMicroChange(new YourMicroChange());
}You can refer to the complete catalog of micro-change in Catalog.
The following article includes the details of the micro-changes and the miner. We encourage contributions to the micro-changes or the miner.
Lei Chen, Michele Lanza, Shinpei Hayashi: ''Understanding Code Change with Micro-Changes''. In Proceedings of the 40th IEEE International Conference on Software Maintenance and Evolution (ICSME 2024). Flagstaff, AZ, USA, oct, 2024.
π Read on arXiv
@inproceedings{chen2024understanding,
title={Understanding Code Change with Micro-Changes},
author={Chen, Lei and Lanza, Michele and Hayashi, Shinpei},
booktitle={Proceedings of the 40th International Conference on Software Maintenance and Evolution },
pages={363--374},
year={2024},
keywords = {Software maintenance;Codes;Natural languages;Focusing;Detectors;Programming;Cognitive science;Logic},
doi = {10.1109/ICSME58944.2024.00041},
url = {https://doi.ieeecomputersociety.org/10.1109/ICSME58944.2024.00041},
organization={IEEE}
}