mirror of https://github.com/apache/kafka.git
KAFKA-7389: Enable spotBugs with Java 11 and disable false positive warnings (#5943)
See https://github.com/spotbugs/spotbugs/issues/756 for details on the false positives affecting try with resources. An example is: > RCN | Nullcheck of fc at line 629 of value previously dereferenced in > org.apache.kafka.common.utils.Utils.readFileAsString(String, Charset) Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>
This commit is contained in:
parent
de24d4a459
commit
0ee16350ac
27
build.gradle
27
build.gradle
|
@ -149,8 +149,7 @@ subprojects {
|
|||
apply plugin: 'maven'
|
||||
apply plugin: 'signing'
|
||||
apply plugin: 'checkstyle'
|
||||
if (!JavaVersion.current().isJava11Compatible())
|
||||
apply plugin: "com.github.spotbugs"
|
||||
apply plugin: "com.github.spotbugs"
|
||||
|
||||
sourceCompatibility = minJavaVersion
|
||||
targetCompatibility = minJavaVersion
|
||||
|
@ -372,20 +371,18 @@ subprojects {
|
|||
}
|
||||
test.dependsOn('checkstyleMain', 'checkstyleTest')
|
||||
|
||||
if (!JavaVersion.current().isJava11Compatible()) {
|
||||
spotbugs {
|
||||
toolVersion = '3.1.8'
|
||||
excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
|
||||
ignoreFailures = false
|
||||
}
|
||||
test.dependsOn('spotbugsMain')
|
||||
spotbugs {
|
||||
toolVersion = '3.1.8'
|
||||
excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
|
||||
ignoreFailures = false
|
||||
}
|
||||
test.dependsOn('spotbugsMain')
|
||||
|
||||
tasks.withType(com.github.spotbugs.SpotBugsTask) {
|
||||
reports {
|
||||
// Continue supporting `xmlFindBugsReport` for compatibility
|
||||
xml.enabled(project.hasProperty('xmlSpotBugsReport') || project.hasProperty('xmlFindBugsReport'))
|
||||
html.enabled(!project.hasProperty('xmlSpotBugsReport') && !project.hasProperty('xmlFindBugsReport'))
|
||||
}
|
||||
tasks.withType(com.github.spotbugs.SpotBugsTask) {
|
||||
reports {
|
||||
// Continue supporting `xmlFindBugsReport` for compatibility
|
||||
xml.enabled(project.hasProperty('xmlSpotBugsReport') || project.hasProperty('xmlFindBugsReport'))
|
||||
html.enabled(!project.hasProperty('xmlSpotBugsReport') && !project.hasProperty('xmlFindBugsReport'))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,17 @@ This file dictates which categories of bugs and individual false positives that
|
|||
For a detailed description of spotbugs bug categories, see https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
|
||||
-->
|
||||
<FindBugsFilter>
|
||||
|
||||
<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
|
||||
<Match>
|
||||
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
|
||||
</Match>
|
||||
|
||||
<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
|
||||
<Match>
|
||||
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- Disable warnings about mutable objects and the use of public fields.
|
||||
EI_EXPOSE_REP: May expose internal representation by returning reference to mutable object
|
||||
|
|
Loading…
Reference in New Issue