REDEC, also known as Readability Decreasing Heuristics (RDH), is a Java code processing tool that employs a collection of heuristics to intentionally reduce the readability of the code. This project achieves its goal by transforming Java code into the Abstract Syntax Tree (AST) using Spoon, a library for Java code analysis and transformation. The primary objective of this project is to generate training data for a code readability classifier.
To execute the code within this project, ensure that you have Maven installed. Follow these steps to run the project:
-
Clone the repository:
git clone https://github.com/LuKrO2011/readability-decreasing-heuristics.git
-
Navigate to the project directory:
cd readability-decreasing-heuristics
-
Build the project using Maven:
mvn clean install
-
Run the project using the generated jar file:
java -jar target/readability-decreasing-heuristics-1.0-SNAPSHOT-jar-with-dependencies.jar <input-path> -o <output-path>
The following command-line options are available for running the readability-decreasing-heuristics
tool:
-
-h
,--help
: Display the help message and exit. -
-c=<configPath>
,--config=<configPath>
: Provide the path to a configuration file for the tool. If not specified, the default configuration will be used. -
-o=<outputPath>
,--output=<outputPath>
: Specify the path to the output directory. If not provided, the output will be written to the input directory (or file). -
-p=<probabilitiesPath>
,--probs
,--probabilities=<probabilitiesPath>
: Supply the path to a configuration file containing probability distributions for the refactorings. If not specified, the default configuration will be used. -
--seed=<seed>
: Initialize the random instance with a given seed to ensure reproducible runs. -
-V
,--version
: Print version information and exit.
-
Java SDK: 17
-
Language Level: 20
-
Build Tool: Maven
For more information about the Spoon library and its capabilities, please refer to the official Spoon Website.
Feel free to explore, experiment, and contribute to this project to further its objectives in generating training data for source code readability classification.
To build the podman container, run the following command:
podman build -t rdh .
-
t : name of the container
-
. : path to the Dockerfile
To run the podman container, run the following command:
podman run -it --rm -v $(pwd):/app rdh
-
it : interactive mode
-
rm : remove container after exit
-
v $(pwd):/app : mount current directory to /app in container
-
readability-classifier : name of the container
The default Dockerfile
does not support realistic method renaming.
To do realistic method renaming, code2vec and its dependencies are required.
You can use the Dockerfile-realistic
for this purpose.