This is a prototype which was made in the context of a research on automatic code refactoring for the GIICIS group.
This tool uses two main external libraries.
- Homplexity for measuring code quality.
- Haskell-Tools for applying refactors with the tool HT-Refact.
Three modes:
- Interactive. Accept or deny a sorted list of refactors manually.
- SA (Simulated Annealing). Automatic code refactor using SA algorithm. (Not completed)
- Random. Automatic code Refactor using random algorithm.
- Can refactor a few types of code-smells. This is because there aren't many possible refactors. However this can be fixed if other tool is used or by developing new refactors for Haskell-Tools library.
- Refactor one file at the time.
We have created a Dockerfile that contains the exact versions of the libraries required for running this script and it's uploaded to this repository.
docker build . -t refactor-image
Mount a volume that contains both the code you want to refactor and all the scripts in this repository.
docker run -v ~/code:/code -ti refactor-image /bin/bash
cd code
python3 main.py --file haskell/Main1.hs --iterations 1 --type manual --maxTempIterations 50
This is not ideal. The building process can take some time and the image is heavy but it's a temporary solution that we have used. We will improve this.