First, you install it (you must have Python 3.7.5 and Pip installed):
$ pip3 install aibolit
To analyze your Java sources, located at src/java
(for example), run:
$ aibolit recommend --filenames src/java/File.java src/java/AnotherFile.java
Also, you can set a folder with Java files:
$ aibolit recommend --folder src/java
It will run recommendation function for the model (model is located in aibolit/binary_files/model.pkl.
The model finds a pattern which contribution is the largest to the Cyclomatic Complexity.
If anything is found, you will see all recommendations for the mentioned patterns.
You can see the list of all patterns in Patterns.md.
The output of recommendation will be saved to the out.xml
file into the current directory.
You can change the output file, using the --output
parameter.
Model is automatically installed with aibolit package, but you can also try your own model
$ aibolit recommend --folder src/java --model_file /mnt/d/some_folder/model.pkl
If you need help, run
$ aibolit recommend --help
Train
command does the following:
- Calculates patterns and metrics
- Creates a dataset
- Trains model and save it
Train works only with cloned git repository.
- Clone aibolit repository
- Go to
cloned_aibolit_path
- Run
pip install .
- Set env variable
export HOME_AIBOLIT=cloned_aibolit_path
(example for Linux). - If you need to set up own directory where model will be saved, set up also
SAVE_MODEL_FOLDER
environment variable. Otherwise model will be saved intocloned_aibolit_path/aibolit/binary_files/model.pkl
- If you need to set up own folder with Java files, use
--java_folder parameter
, the default value will bescripts/target/01
of aibolit cloned repo - You need to install Java 13 and Maven
Or you can use our docker image (link will be soon here)
Run train pipeline:
$ aibolit train --java_folder=src/java [--max_classes=100]
First, you need to install:
Install the following packages if you don't have :
$ apt-get install ruby-dev libz-dev libxml2
Then, you fork the repo and make the changes. Then, you make sure the build is still clean, by running:
$ make
To build white paper:
$ cd wp
$ latexmk -c && latexmk -pdf wp.tex
If everything is fine, submit a pull request.
Using Docker recommendation pipeline
$ docker run --rm -it \
-v <absolute_path_to_folder_with_classes>:/in \
-v <absolute_path_to_out_dir>:/out \
yegor256/aibolit-image