tree: d1747579f54dfcbf2d9c029cb738572107aee16d [path history] [tgz]
  1. ant/
  2. lib/
  3. maven/
  4. nbproject/
  5. test/
  6. tool/
  7. build.sh
  8. build.xml
  9. rat-exclusions.txt
  10. README.md
cmdline/README.md

Apache NetBeans Standalone Java Hints

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.

Requirements

To Build

  • Apache NetBeans 12.3
  • JDK 8 and JDK 11
  • bash
  • Apache ant 1.9.9 or above
  • Apache Maven 3.3.9 or above

To Run

  • JDK 11

Building

Build using:

$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-12.3> -DJDK11=<path-to-JDK-11> build-and-test

The built product is in tool/build/jackpot.

Running

Run using:

$ jackpot <options> <files-to-inspect>

To get help on the options, run:

$ jackpot --help

Example

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.