Using Error-Prone

Error Prone is static anaylsis tool for Java. It hooks into the compilation process. To use in your maven build you need do some configuration for the maven compiler plugin

An example of error prone being setup for maven compiler plugin

                        <!-- Promote this check to Error level for bug patters see -->
                    <!-- override plexus-compiler-javac-errorprone's dependency on
                        Error Prone with the latest version -->

In the above we increased the severity error-prone’s MissingOverride bugpattern to Error (error-prone default was WARNING)

This how the output looks like if now in maven’s compilation goal a class that has a missing @Override annotation

Another feature of error-prone is that it has Intellij Integration
You need to install the once that’s done you can change the compiler that Intellij uses

Now within Intellij you will get the same compilation errors as you get from maven

For more details about the installation, see the error-prone documentation

Leave a Reply

Your email address will not be published. Required fields are marked *