checkstyle
is a tool to automatically check style issues in your code. Here we provide some checkstyle
rules in checkstyle.xml to help you check for any style issues in your code.
Warning
checkstyle
does not check for all items in our style guide. Passing all our checkstyle rules does not guarantee that you'll get full points on style (but you'll get most of them). Please do follow our style guide and manually check for each item before submission. Here's a non-exhaustive list thatcheckstyle
can't check.
- File headers
- Variable names
- Magic numbers for string and char literals
- Short methods
- Download Checkstyle 10.7.0 (
checkstyle-10.7.0-all.jar
) from Github. - Download
checkstyle.xml
from this repo. - Copy both files to the folder where you store your code.
- In the terminal, run
java -jar checkstyle-10.7.0-all.jar -c checkstyle.xml [your java file]
, for example,java -jar checkstyle-10.7.0-all.jar -c checkstyle.xml MyLinkedList.java
. You'll see a list of errors that indicate style issues in your code.