This sample code is used to demo different static verification tools such as FindBugs, PMD, Google ErrorProne, SpotBugs, CogniCrypt, and Coverity.
Some of the tools demonstrated here require a compiled jar file. To create the jar file for this sample project, run
mvn clean package assembly:single
-
I downloaded the FindBugs jar file from this link. Note that there are alternative ways to run FindBugs. You can check them on their webpage.
-
Run FindBugs on the current project (run the following command from the main directory of this project):
java -jar <path to FindBugs jar file>
-
The above command will open a GUI. You can follow the GUI instructions here to see how to use set up a new project. Note that for the source directory, you need to select the
src/main/java
directory. -
Once you set up the project, you can view the different warnings in the GUI.
-
An alternative way for running FindBugs is through
ant
. There is already abuild.xml
file that configures the build for you so you can run FindBugs through the command line. Please note that you may need to update the path to the FindBugs directory to wherever you unzipped the above archive to.
ant findbugs
Running the above command will create an xml output file called demo-findbugs.xml
- The
pom.xml
file in this repo already has the pmd plugin as part of the reporting phase. To produce the pmd report, run:
mvn pmd:pmd
- In the target folder, you will find a
pmd.xml
file that contains the results of running PMD. You can also visualize those results by viewing thetarget/site/pmd.html
file
-
To run ErrorProne, go to the
pom.xml
file and uncomment all parts mared byfor running google error prone
. -
Run
mvn clean compile
to force a compilation. You will notice that the build now fails. Google ErrorProne is integrated into the build process and causes it to fail upon detecting any error (based on its ruleset).
-
The
pom.xml
file already has the SpotBugs dependency added -
Run
mvn spotbugs:check
. It will show you the errors spotted and that you can visually look at the errors by runningmvn spotbugs:gui
-
Download the precompiled version of CongniCrypt from their repo, as well as the set of Crysl rules they have there
-
Run
java -cp ../CogniCrypt/CryptoAnalysis-1.0.0-jar-with-dependencies.jar crypto.HeadlessCryptoScanner --rulesDir=../CogniCrypt/JCA_rules/ --applicationCp=target/findbugs-1.0-SNAPSHOT.jar
from inside the main directory