Skip to content

Running errorprone

Bear Giles edited this page Jul 21, 2024 · 1 revision

Errorprone is a powerful static analysis tool. It can be easily added to the maven-compiler-plugin configuration stanza.

Modifications to maven-compiler-plugin configuration

    <compilerArgs>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
        <arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
        <arg>-Xplugin:ErrorProne -Xep:AssertEqualsArgumentOrderChecker:WARN -Xep:DefaultCharset:WARN -Xep:EqualsIncompatibleType:WARN -Xep:ImmutableEnumChecker:WARN -Xep:MissingOverride:WARN -Xep:RemoveUnusedImports:WARN -Xep:StreamResourceLeak:WARN -Xep:ThreadLocalUsage:WARN -Xep:UnusedException:WARN -Xep:UnnecessaryParentheses:WARN -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/generated-sources/.* </arg>
    </compilerArgs>
    <annotationProcessorPaths>
        <path>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_core</artifactId>
            <version>2.29.2</version>
        </path>
    </annotationProcessorPaths>

Official resources

Additional resources

Clone this wiki locally