This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure Google Error Prone static code analysis tool (apache#8879)
### Motivation Google's [Error Prone static code analysis tool](https://errorprone.info/) 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` and `errorprone-jdk8` or `errorprone-jdk11` maven profiles in addition to `main` or `core-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. - this setting cannot be enabled by default since JDK9+ doesn't include the `javax.annotation.Generated` annotation by default and adding the required dependency will change the classpath dependency resolution results. - There is an open issue to support lombok.Generated annotion in ErrorProne, 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` - usability is better when used together with IntelliJ 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
- Loading branch information
Showing
3 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
# this is the top level Lombok configuration file | ||
# see https://projectlombok.org/features/configuration for reference | ||
|
||
config.stopBubbling = true | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters