Use SpotBugs 3.1.2, and NP_NONNULL_PARAM_VIOLATION 08/70208/2
authorStephen Kitt <skitt@redhat.com>
Thu, 29 Mar 2018 14:48:03 +0000 (07:48 -0700)
committerStephen Kitt <skitt@redhat.com>
Fri, 30 Mar 2018 19:44:15 +0000 (12:44 -0700)
This patch upgrades the SpotBugs plugin to 3.1.3 and the engine to
3.1.2. The changelog is
https://github.com/spotbugs/spotbugs/blob/3.1.2/CHANGELOG.md

SpotBugs 3.1.2 supports the nullable annotations in Checker Framework
(see
https://github.com/spotbugs/spotbugs/commit/dd436ff56abf0273a080ad228fcf5abd8ee3a097
for the patch), so we can re-enable NP_NONNULL_PARAM_VIOLATION when
using SpotBugs. This involves using a separate configuration, so this
patch splits everything out, including the report directory for
projects which run both FindBugs and SpotBugs.

Change-Id: I8cb110f12d79414d476b7a6c525412f3b7e2c188
Signed-off-by: Stephen Kitt <skitt@redhat.com>
odlparent/pom.xml
pom.xml
spotbugs/pom.xml [new file with mode: 0644]
spotbugs/src/main/resources/spotbugs-exclude.xml [new file with mode: 0644]

index ae41889f899901da0c2dfa0b855af2e5896ee03f..0e00a47f1b65d8c2a49bd65a285c1812323976fc 100644 (file)
         <plugin>
           <groupId>com.github.spotbugs</groupId>
           <artifactId>spotbugs-maven-plugin</artifactId>
-          <version>3.1.1</version>
+          <version>3.1.3</version>
           <dependencies>
             <dependency>
               <groupId>com.github.spotbugs</groupId>
               <artifactId>spotbugs</artifactId>
-              <version>3.1.1</version>
+              <version>3.1.2</version>
             </dependency>
             <dependency>
               <groupId>org.opendaylight.odlparent</groupId>
-              <artifactId>findbugs</artifactId>
+              <artifactId>spotbugs</artifactId>
               <version>4.0.0-SNAPSHOT</version>
             </dependency>
           </dependencies>
             <!-- Build doesn't fail if problems are found -->
             <failOnError>false</failOnError>
             <!-- References the excluded rules -->
-            <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
+            <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
             <!-- Produces XML report -->
             <xmlOutput>true</xmlOutput>
             <!-- Configures the directory in which the XML report is created -->
-            <findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
+            <findbugsXmlOutputDirectory>${project.build.directory}/spotbugs</findbugsXmlOutputDirectory>
           </configuration>
           <executions>
             <!--
diff --git a/pom.xml b/pom.xml
index 14e8243d1a6b35c6988a599cb0c598a758875901..965f046877e59af2369ea6e37347f66f4eb5b8be 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@
         <!-- odlparent tools -->
         <module>checkstyle</module>
         <module>findbugs</module>
+        <module>spotbugs</module>
         <module>license</module>
 
         <!-- Features test (SFT) -->
diff --git a/spotbugs/pom.xml b/spotbugs/pom.xml
new file mode 100644 (file)
index 0000000..4836130
--- /dev/null
@@ -0,0 +1,51 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent-lite</artifactId>
+    <version>4.0.0-SNAPSHOT</version>
+    <relativePath>../odlparent-lite</relativePath>
+  </parent>
+
+  <artifactId>spotbugs</artifactId>
+  <name>ODL :: odlparent :: ${project.artifactId}</name>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>3.0.2</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>3.0.1</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <scm>
+    <connection>scm:git:ssh://git.opendaylight.org:29418/odlparent.git</connection>
+    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/odlparent.git</developerConnection>
+    <tag>HEAD</tag>
+    <url>https://wiki.opendaylight.org/view/ODL_Root_Parent:Main</url>
+  </scm>
+
+  <!--
+    Maven Site Configuration
+
+    The following configuration is necessary for maven-site-plugin to
+    correctly identify the correct deployment path for OpenDaylight Maven
+    sites.
+  -->
+  <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+  <distributionManagement>
+    <site>
+      <id>opendaylight-site</id>
+      <url>${nexus.site.url}/${project.artifactId}/</url>
+    </site>
+  </distributionManagement>
+
+</project>
diff --git a/spotbugs/src/main/resources/spotbugs-exclude.xml b/spotbugs/src/main/resources/spotbugs-exclude.xml
new file mode 100644 (file)
index 0000000..28168cb
--- /dev/null
@@ -0,0 +1,19 @@
+<FindBugsFilter>
+  <Match>
+    <Or>
+      <Package name="~.*protobuff\.messages.*" />
+      <Package name="~org\.opendaylight\.yang\.gen\..*" />
+      <Package name="~org\.opendaylight\.controller\.config\.yang\.config\..*" />
+    </Or>
+  </Match>
+
+  <Match>
+    <Or>
+      <!-- Anonymous inner classes are very common in ODL. -->
+      <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
+
+      <!-- We use static slf4j Logger (this rule is from KengoTODA/findbugs-slf4j jp.skypencil.findbugs.slf4:bug-pattern) -->
+      <Bug pattern="SLF4J_LOGGER_SHOULD_BE_NON_STATIC" />
+    </Or>
+  </Match>
+</FindBugsFilter>