-
Notifications
You must be signed in to change notification settings - Fork 48
Setting Up CheckStyle
- Go to your Ubuntu or Mac Terminal and download the checkstyle jar file and the cs2030 xml file to prepare the setup for checkstyle. The following 2 commands below downloads the required files
wget http://www.comp.nus.edu.sg/~cs2030/checkstyle-8.2-all.jar
wget http://www.comp.nus.edu.sg/~cs2030/cs2030_checks.xml
-
Make sure you place these 2 files in the same directory as your java files.
-
To run the checkstyle command, execute the following command:
java -jar ./checkstyle-8.2-all.jar -c ./cs2030_checks.xml *.java
- To run the checkstyle on specific files, execute the following command:
java -jar ./checkstyle-8.2-all.jar -c ./cs2030_checks.xml [YOUR_JAVA_FILES]
For example:
java -jar ./checkstyle-8.35-all.jar -c ./cs2030_checks.xml Point.java Circle.java Square.java
All credits from this thread and its contributors - Setting alias for checkstyle #37
Simply by creating aliases!
-
Create a folder to store
checkstyle-8.2-all.jar
andcs2030_checks.xml
. Refer to the above for more info. -
Navigate to the folder that you created with the 2 items inside and enter
pwd
to print the current directory to fit intoPATH_TO_FOLDER
. -
Edit your terminal setting file.
Place the alias at the bottom of your .bashrc
file or wherever you prefer.
(If you are using zsh
, replace .bashrc
below with .zshrc
.)
1. 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-8.2-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-8.2-all.jar -c /[PATH_TO_FOLDER]/cs2030_checks.xml"
3. Read and execute the file
source ~/.bashrc
Place the alias at the bottom of your .bash_profile
file or wherever you prefer.
1. Edit .bash_profile file in vim
vim ~/.bash_profile
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-8.2-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-8.2-all.jar -c /[PATH_TO_FOLDER]/cs2030_checks.xml"
3. Read and execute the file
source ~/.bash_profile
Proceed to test it out with
- If checkstyle alias set up for all java files in the same folder as the checkstyle files
checkstyle
- If checkstyle alias set up for specific java file (works for files not in the same folder as the checkstyle files) Go into the folder containing the java file and run
checkstyle [FILE_NAME].java
Peer Learning
Codecrunch Contributions
Piazza Contributions
Wiki Contributions
Guides
Setting Up Checkstyle
Setting Up Java
Setting Up MacVim
Setting Up Sunfire
Setting Up Unix For Mac
Setting Up Unix For Windows
Setting Up Vim
Setting up SSH Config
CS2030 Contents
Lecture 1 SummaryCompile-run vs Run-time Summary
Quick Guide To Abstraction
Generics and Variance of Types
Comparable vs Comparator
Summary of completable future
CS2030S Notes
ELI5 Optional.map vs Optional.flatMap
PECS Example Code
Java Collection Framework (Iterator)
Generic
Generic Type Parameter and Generic Wildcard
Calculator
Lambda-Expression
Single Abstract Method (SAM)
Method Reference
Functional Interfaces 2
Simple Usage of Sandbox
Associative-but-not-commutative
Higher Order function
Functional Programming
Calculator With Functor
Eager Evaluation VS Lazy Evaluation
Simple Usage of Lazy Evaluation
Lazy Evaluation for LazyList
Lazy Evaluation for BinaryTree
Stream
Parallel Stream
Optional
Simple Usage of Stream
Asynchronous Programming
Notes on CompletableFuture
Notes on CompletableFuture 2
Simple Usage of CompletableFuture
Mind Map
Exception Handling
Links
CS2030 Java Style Guide
CS2030 Javadoc Specification
JDK 11 Download Link
JDK 11 API Docs
Codecrunch
Piazza Forum