[build] Configure Google Error Prone static code analysis tool for Pulsar maven build #8879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Google's Error Prone static code analysis tool can detect typical programming mistakes (for more info see https://errorprone.info/). This PR adds configuration to Pulsar maven build so that Error Prone static code analysis
can be run for the Pulsar code base. This additional configuration is not active by default and requires activating
errorprone
anderrorprone-jdk8
orerrorprone-jdk11
maven profiles in addition tomain
orcore-modules
profile for running the analysis.Modifications
add a separate maven profile for running errorprone analysis
it is not active by default
Add top-level
lombok.config file
for configuring Lombok.This file doesn't contain any other settings that
marks it as the top most config file with
config.stopBubbling = true
(see https://projectlombok.org/features/configuration for reference)
Before running the Error Prone analysis, it's necessary to
manually configure Lombok to add
@javax.annotation.Generated("lombok")
annotation on all fields, methods, and types that are generated.
This makes Error Prone skip the analysis for Lombok generated code.
the
javax.annotation.Generated
annotation by default and adding therequired dependency will change the classpath dependency resolution results.
ErrorProne, lombok.Generated annotation is ignored google/error-prone#1863
example usage:
Configure Lombok to add Generated annotations
echo "lombok.addJavaxGeneratedAnnotation = true" >> lombok.config
then,
on JDK8
mvn -Perrorprone,errorprone-jdk8,core-modules compile
on JDK11+
mvn -Perrorprone,errorprone-jdk11,core-modules compile
since one can click on the error message to navigate
to the code location
also add configuration for Error Prone SLF4J plugin
https://github.com/KengoTODA/errorprone-slf4j
which helps detect misusage of SLF4J API