This tool allows to run NetBeans Java code checker without the NetBeans IDE. This includes running the custom Java hints specified in META-INF/upgrade/*.hint.
Build using:
$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-11.1> -DJDK11=<path-to-JDK-11> build-and-test
The built product is in tool/build/jackpot.
Run using:
$ jackpot <options> <files-to-inspect>
To get help on the options, run:
$ jackpot --help
Consider this sample code:
package test; public class Test { public void test(boolean b) { int i = 0; if (b) System.err.println("was true"); assert (i = 1) == 1; } }
It is possible to get a warning for the improper indentation like this:
$ jackpot --hint "Confusing indentation" <somedir>/src <somedir>/src/test/Test.java:9: warning: [Confusing_indentation] Confusing indentation assert (i = 1) == 1; ^
Or a warning for the side-effects inside the assert:
$ jackpot --hint "Assert with side effects" <somedir>/src <somedir>/src/test/Test.java:9: warning: [Assert_with_side_effects] Assert condition produces side effects assert (i = 1) == 1; ^
All supported hints can be listed using:
$ jackpot --list
It is also possible to use a configuration file which enables multiple hints at once using:
$ jackpot --config-file <path-to-config-file> <path-to-sources-to-check>
The config file can be generated by the NetBeans IDE, using Project Properties/Hints, or similar ways.