generated from nus-cs2030/base-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up CheckStyle
nothingistrue edited this page Sep 12, 2022
·
7 revisions
- On your host machine, download the checkstyle-8.2-all.jar and the cs2030_checks.xml file to the folder that is mounted to your docker container's
/workspace
. The following commands below downloads the required files for Ubuntu terminal, Windows WSL, Mac terminal.
git clone https://github.com/nus-cs2030/2223-s1.git
cp 2223-s1/checkstyle-10.3.3-all.jar <folder mounted on docker>
cp 2223-s1/cs2030_checks.xml <folder mounted on docker>
You can also go to click the checkstyle link and styles xml link to download and move the files manually to the right location.
-
Start the docker container. In the container, make sure you place these 2 files in the same directory as your java files.
-
In the container, to run the checkstyle command, execute the following command:
java -jar ./checkstyle-10.3.3-all.jar -c ./cs2030_checks.xml *.java
- To run the checkstyle on specific files, execute the following command:
java -jar ./checkstyle-10.3.3-all.jar -c ./cs2030_checks.xml [YOUR_JAVA_FILES]
For example:
java -jar ./checkstyle-10.3.3-all.jar -c ./cs2030_checks.xml Point.java Circle.java Square.java
Place the alias at the bottom of your .bashrc
file or wherever you prefer.
(If you are using zsh
, replace .bashrc
below with .zshrc
.)
- Edit .bashrc file in vim
vim ~/.bashrc
2a. To make checkstyle alias on all java files in the folder Add alias to anywhere in the file and save it (w!)
alias checkstyle="java -jar /[PATH_TO_FOLDER]/checkstyle-10.3.3-all.jar -c /[PATH_TO_FOLDER]/cs2030_checks.xml *.java"
ALTERNATIVE 2b. To make checkstyle alias on specific java file only Add alias to anywhere in the file and save it (w!)
alias checkstyle="java -jar /[PATH_TO_FOLDER]/checkstyle-10.3.3-all.jar -c /[PATH_TO_FOLDER]/cs2030_checks.xml"
- Read and execute the file
source ~/.bashrc
Welcome to CS2030 AY22/23 Sem 1 Wiki