-
Notifications
You must be signed in to change notification settings - Fork 48
Setting Up CheckStyle
- Go to our Main Repository and download these 2 files under the
Miscellaneous
folder.
-
checkstyle-8.2-all.jar
- this provides the actual checkstyle program -
cs2030_checks.xml
- this provides the configuration file specifically for CS2030 for checkstyle
Make sure you save them to a directory that you can remember. In this case, I chose to save them to ~/checkstyle_files
.
-
In the shell, change directory to the folder where you saved the files, with
cd /place/where/you/saved/the/files
. -
Check that the files are there with
ls
. -
Your download files should already have the right read permissions, but we will set it again just to be sure. Run
chmod u+r checkstyle-8.2-all.jar cs2030_checks.xml
. What this command does is that it CHanges the MODe of the files (i.e. its permissions), and adds read (+r
) to the user (u+r
). -
To help us accurately determine the location of the files later, run
realpath -e checkstyle-8.2-all.jar cs2030_checks.xml
(yes I missed out the-e
switch in the screenshot above).realpath
outputs the full absolute file path while the-e
switch ensures it checks for file existence first.
- Now that we know the absolute location of the two files, we can create our very own
checkstyle
command. Run, in a single command,echo 'alias checkstyle="java -jar your/full/filepath/here/checkstyle-8.2-all.jar -c your/full/filepath/here/cs2030_checks.xml *.java"' >> ~/.bashrc
.
- remember to swap out the directories in the command above with your actual directories you found in step 5
- make sure you have TWO right brackets
>>
instead of one. the two right brackets ensures it appends to the~/.bashrc
file instead of rewriting it. - if you use any other shell like
zsh
orfish
, please change the command to work with your respective shell configuration files, e.g.~/.zshrc
For me, I ran echo 'alias checkstyle="java -jar /home/chris/checkstyle_files/checkstyle-8.2-all.jar -c /home/chris/checkstyle_files/cs2030_checks.xml *.java"' >> ~/.bashrc
.
What this command does is that it appends the line alias checkstyle="java -jar /home/chris/checkstyle_files/checkstyle-8.2-all.jar -c /home/chris/checkstyle_files/cs2030_checks.xml *.java"
to the end of your shell configuration file (commonly ~/.bashrc
). Your shell configuration file is ran (or more accurately, sourced) whenever you start your shell.
As for alias checkstyle="java -jar /home/chris/checkstyle_files/checkstyle-8.2-all.jar -c /home/chris/checkstyle_files/cs2030_checks.xml *.java"
, what this does is that it sets a command alias called checkstyle
, so that whenever you run checkstyle
in your shell, it will run java -jar /home/chris/checkstyle_files/checkstyle-8.2-all.jar -c /home/chris/checkstyle_files/cs2030_checks.xml *.java
, which is the command to properly run checkstyle and load the configuration file in java.
-
Restart your shell, i.e. close it and start it again. (alternatively, you can just run
source ~/.bashrc
) -
Change directory to a directory with
.java
files and runcheckstyle
. It should work now.
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