aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Migrate from findbugs to spotbugs
Date Tue, 07 Nov 2017 07:27:06 GMT
Repository: aurora
Updated Branches:
  refs/heads/master d10165544 -> ad86177a0


Migrate from findbugs to spotbugs

Findbugs [1] is no longer developed and replaced by spotbugs [2]
as mostly a drop-in replacement.

[1] https://github.com/findbugsproject/findbugs
[2] https://mailman.cs.umd.edu/pipermail/findbugs-discuss/2017-September/004383.html

Reviewed at https://reviews.apache.org/r/63564/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/ad86177a
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/ad86177a
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/ad86177a

Branch: refs/heads/master
Commit: ad86177a0b241f206eedb51bb708b74f5292afdc
Parents: d101655
Author: Stephan Erb <serb@apache.org>
Authored: Tue Nov 7 08:26:58 2017 +0100
Committer: Stephan Erb <serb@apache.org>
Committed: Tue Nov 7 08:26:58 2017 +0100

----------------------------------------------------------------------
 build.gradle                                    |  18 +--
 config/findbugs/excludeFilter.xml               | 129 ------------------
 config/spotbugs/excludeFilter.xml               | 136 +++++++++++++++++++
 .../scheduler/offers/OfferOrderBuilder.java     |   4 +-
 4 files changed, 145 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/ad86177a/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 26051ac..ddf153d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,11 +17,11 @@ plugins {
   id 'com.github.hierynomus.license' version '0.11.0'
   id 'com.moowork.node' version '1.2.0'
   id 'me.champeau.gradle.jmh' version '0.4.4'
+  id "com.github.spotbugs" version "1.6.0"
 }
 
 apply plugin: 'application'
 apply plugin: 'checkstyle'
-apply plugin: 'findbugs'
 apply plugin: 'jacoco'
 apply plugin: 'pmd'
 
@@ -85,7 +85,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
   ext.asyncHttpclientRev = '2.0.37'
   ext.jacksonRev = '2.5.1'
   ext.jerseyRev = '1.19'
-  ext.jsrRev = '3.0.1'
   ext.junitRev = '4.12'
   ext.logbackRev = '1.2.3'
   ext.mybatisRev = '3.4.1'
@@ -112,7 +111,6 @@ For more details, please see https://issues.apache.org/jira/browse/AURORA-1169
         failOnVersionConflict()
         force "com.fasterxml.jackson.core:jackson-annotations:${jacksonRev}"
         force "com.fasterxml.jackson.core:jackson-core:${jacksonRev}"
-        force "com.google.code.findbugs:jsr305:${jsrRev}"
         force "com.google.code.gson:gson:${gsonRev}"
         force "com.google.guava:guava:${guavaRev}"
         force "com.google.protobuf:protobuf-java:${protobufRev}"
@@ -187,7 +185,6 @@ project(':commons') {
   }
 
   dependencies {
-    compile "com.google.code.findbugs:jsr305:${jsrRev}"
     compile "com.google.code.gson:gson:${gsonRev}"
     compile "com.google.guava:guava:${guavaRev}"
     compile "com.google.inject:guice:${guiceRev}"
@@ -373,7 +370,6 @@ dependencies {
   compile 'aopalliance:aopalliance:1.0'
   compile "ch.qos.logback:logback-classic:${logbackRev}"
   compile "com.beust:jcommander:1.72"
-  compile "com.google.code.findbugs:jsr305:${jsrRev}"
   compile "com.google.inject:guice:${guiceRev}"
   compile "com.google.inject.extensions:guice-assistedinject:${guiceRev}"
   compile "com.google.protobuf:protobuf-java:${protobufRev}"
@@ -417,7 +413,7 @@ dependencies {
 def runCodeQuality = project.hasProperty('q')
 def codeQualityTasks = [
     Checkstyle,
-    FindBugs,
+    com.github.spotbugs.SpotBugsTask,
     nl.javadude.gradle.plugins.license.License,
     Pmd
 ]
@@ -432,18 +428,18 @@ checkstyle {
   toolVersion = '7.3'
 }
 
-findbugs {
-  toolVersion = '3.0.1'
+spotbugs {
+  toolVersion = '3.1.0'
   effort = "max"
 }
 
-tasks.withType(FindBugs) {
+tasks.withType(com.github.spotbugs.SpotBugsTask) {
   reports {
     xml.enabled = false
     html.enabled = true
   }
-  maxHeapSize = '2g'
-  excludeFilter = rootProject.file('config/findbugs/excludeFilter.xml')
+  maxHeapSize = '1g'
+  excludeFilter = rootProject.file('config/spotbugs/excludeFilter.xml')
 }
 
 pmd {

http://git-wip-us.apache.org/repos/asf/aurora/blob/ad86177a/config/findbugs/excludeFilter.xml
----------------------------------------------------------------------
diff --git a/config/findbugs/excludeFilter.xml b/config/findbugs/excludeFilter.xml
deleted file mode 100644
index 4d5b36f..0000000
--- a/config/findbugs/excludeFilter.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-<!--
-Licensed 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.
--->
-<FindBugsFilter>
-  <!-- Warnings triggered in thrift-generated code. -->
-  <Match>
-    <Or>
-      <Package name="org.apache.aurora.gen" />
-      <Package name="org.apache.aurora.gen.comm" />
-      <Package name="org.apache.aurora.gen.storage" />
-      <Package name="org.apache.aurora.gen.test" />
-      <Package name="org.apache.aurora.benchmark.generated" />
-      <Package name="org.openjdk.jmh.infra.generated" />
-      <!-- Un-namespaced structs used by the executor. -->
-      <Class name="ProcessState" />
-      <Class name="ProcessStatus" />
-      <Class name="RunnerHeader" />
-      <Class name="RunnerState" />
-      <Class name="TaskStatus" />
-    </Or>
-    <Or>
-      <Bug pattern="BC_IMPOSSIBLE_CAST" />
-      <Bug pattern="CN_IDIOM" />
-      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
-      <Bug pattern="NM_CLASS_NAMING_CONVENTION" />
-      <Bug pattern="UUF_UNUSED_FIELD" />
-      <Bug pattern="URF_UNREAD_FIELD" />
-    </Or>
-  </Match>
-
-  <!-- Warnings triggered for mybatis shim classes. -->
-  <Match>
-    <Package name="org.apache.aurora.scheduler.storage.db.views" />
-    <Or>
-      <!-- The shim classes trip these warnings since we have no code that explicitly
sets fields,
-           but mybatis reflects and sets them for us.
-       -->
-      <Bug pattern="NP_UNWRITTEN_FIELD" />
-      <Bug pattern="UWF_UNWRITTEN_FIELD" />
-    </Or>
-  </Match>
-
-  <!-- We don't make use of Java serialization and this can prevent, for example, declaring
an
-       HttpServlet as an anonymous inner class for testing. -->
-  <Match>
-    <Bug pattern="SE_BAD_FIELD" />
-  </Match>
-
-  <!-- We must maintain reflexivity with WildcardPermission's equals, so we cannot override
-       it even though we add fields in our subclass. We cannot use delegation because
-       WildcardPermission's implies method checks that its argument is an instance of
-       WildcardPermission. -->
-  <Match>
-    <Or>
-      <Class name="org.apache.aurora.scheduler.spi.Permissions$JobScopedRpcPermission"
/>
-      <Class name="org.apache.aurora.scheduler.spi.Permissions$UnscopedRpcPermission"
/>
-    </Or>
-    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
-  </Match>
-
-  <!-- Method is intentionally only callable by EventBus. -->
-  <Match>
-    <Class name="org.apache.aurora.scheduler.events.PubsubEventModule$1" />
-    <Bug pattern="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS" />
-  </Match>
-
-  <!-- Technical debt. -->
-  <Match>
-    <Class name="org.apache.aurora.scheduler.log.mesos.MesosLog$LogStream" />
-    <Bug pattern="IS2_INCONSISTENT_SYNC" />
-  </Match>
-  <Match>
-    <Class name="org.apache.aurora.scheduler.http.Utilization" />
-    <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
-  </Match>
-  <Match>
-    <Class name="~org\.apache\.aurora.*$" />
-    <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" />
-  </Match>
-  <Match>
-    <Or>
-      <Class name="org.apache.aurora.scheduler.storage.backup.StorageBackup$StorageBackupImpl"
/>
-      <Class name="org.apache.aurora.scheduler.storage.backup.StorageBackupTest" />
-    </Or>
-    <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
-  </Match>
-  <Match>
-    <Or>
-      <Class name="org.apache.aurora.scheduler.app.SchedulerIT$IntPosition" />
-      <Class name="org.apache.aurora.scheduler.log.mesos.MesosLog$LogStream$LogPosition"
/>
-      <Class name="org.apache.aurora.scheduler.log.testing.FileLog$FileStream$CounterPosition"
/>
-    </Or>
-    <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
-  </Match>
-  <Match>
-    <Or>
-      <Class name="org.apache.aurora.scheduler.cron.testing.AbstractCronIT" />
-      <Class name="org.apache.aurora.scheduler.log.mesos.MesosLogTest" />
-      <Class name="org.apache.aurora.scheduler.thrift.ThriftIT" />
-      <Class name="org.apache.aurora.scheduler.thrift.ThriftIT$1" />
-    </Or>
-    <Bug pattern="DM_DEFAULT_ENCODING" />
-  </Match>
-
-  <Match>
-    <!-- False positives on a check introduced in findbugs 3.0.1 -->
-    <Or>
-      <Class name="org.apache.aurora.scheduler.storage.db.DbStorage$3" />
-      <Class name="org.apache.aurora.scheduler.http.api.security.AuthorizeHeaderTokenTest"
/>
-    </Or>
-    <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
-  </Match>
-
-  <Match>
-    <!-- Options fields may be flagged as always null, since they are set reflectively.
-->
-    <Class name="~org.apache.aurora.scheduler.*Options" />
-    <Bug pattern="UWF_NULL_FIELD" />
-  </Match>
-</FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/aurora/blob/ad86177a/config/spotbugs/excludeFilter.xml
----------------------------------------------------------------------
diff --git a/config/spotbugs/excludeFilter.xml b/config/spotbugs/excludeFilter.xml
new file mode 100644
index 0000000..51790cc
--- /dev/null
+++ b/config/spotbugs/excludeFilter.xml
@@ -0,0 +1,136 @@
+<!--
+Licensed 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.
+-->
+<FindBugsFilter>
+  <!-- Warnings triggered in thrift-generated code. -->
+  <Match>
+    <Or>
+      <Package name="org.apache.aurora.gen" />
+      <Package name="org.apache.aurora.gen.comm" />
+      <Package name="org.apache.aurora.gen.storage" />
+      <Package name="org.apache.aurora.gen.test" />
+      <Package name="org.apache.aurora.benchmark.generated" />
+      <Package name="org.openjdk.jmh.infra.generated" />
+      <!-- Un-namespaced structs used by the executor. -->
+      <Class name="ProcessState" />
+      <Class name="ProcessStatus" />
+      <Class name="RunnerHeader" />
+      <Class name="RunnerState" />
+      <Class name="TaskStatus" />
+    </Or>
+    <Or>
+      <Bug pattern="BC_IMPOSSIBLE_CAST" />
+      <Bug pattern="CN_IDIOM" />
+      <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+      <Bug pattern="NM_CLASS_NAMING_CONVENTION" />
+      <Bug pattern="UUF_UNUSED_FIELD" />
+      <Bug pattern="URF_UNREAD_FIELD" />
+    </Or>
+  </Match>
+
+  <!-- Warnings triggered for mybatis shim classes. -->
+  <Match>
+    <Package name="org.apache.aurora.scheduler.storage.db.views" />
+    <Or>
+      <!-- The shim classes trip these warnings since we have no code that explicitly
sets fields,
+           but mybatis reflects and sets them for us.
+       -->
+      <Bug pattern="NP_UNWRITTEN_FIELD" />
+      <Bug pattern="UWF_UNWRITTEN_FIELD" />
+    </Or>
+  </Match>
+
+  <!-- We don't make use of Java serialization and this can prevent, for example, declaring
an
+       HttpServlet as an anonymous inner class for testing. -->
+  <Match>
+    <Bug pattern="SE_BAD_FIELD" />
+  </Match>
+
+  <!-- We must maintain reflexivity with WildcardPermission's equals, so we cannot override
+       it even though we add fields in our subclass. We cannot use delegation because
+       WildcardPermission's implies method checks that its argument is an instance of
+       WildcardPermission. -->
+  <Match>
+    <Or>
+      <Class name="org.apache.aurora.scheduler.spi.Permissions$JobScopedRpcPermission"
/>
+      <Class name="org.apache.aurora.scheduler.spi.Permissions$UnscopedRpcPermission"
/>
+    </Or>
+    <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
+  </Match>
+
+  <!-- Method is intentionally only callable by EventBus. -->
+  <Match>
+    <Class name="org.apache.aurora.scheduler.events.PubsubEventModule$1" />
+    <Bug pattern="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS" />
+  </Match>
+
+  <!-- Technical debt. -->
+  <Match>
+    <Class name="org.apache.aurora.scheduler.log.mesos.MesosLog$LogStream" />
+    <Bug pattern="IS2_INCONSISTENT_SYNC" />
+  </Match>
+  <Match>
+    <Class name="org.apache.aurora.scheduler.http.Utilization" />
+    <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
+  </Match>
+  <Match>
+    <Class name="~org\.apache\.aurora.*$" />
+    <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" />
+  </Match>
+  <Match>
+    <Or>
+      <Class name="org.apache.aurora.scheduler.storage.backup.StorageBackup$StorageBackupImpl"
/>
+      <Class name="org.apache.aurora.scheduler.storage.backup.StorageBackupTest" />
+    </Or>
+    <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
+  </Match>
+  <Match>
+    <Or>
+      <Class name="org.apache.aurora.scheduler.app.SchedulerIT$IntPosition" />
+      <Class name="org.apache.aurora.scheduler.log.mesos.MesosLog$LogStream$LogPosition"
/>
+      <Class name="org.apache.aurora.scheduler.log.testing.FileLog$FileStream$CounterPosition"
/>
+    </Or>
+    <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
+  </Match>
+  <Match>
+    <Or>
+      <Class name="org.apache.aurora.scheduler.cron.testing.AbstractCronIT" />
+      <Class name="org.apache.aurora.scheduler.log.mesos.MesosLogTest" />
+      <Class name="org.apache.aurora.scheduler.thrift.ThriftIT" />
+      <Class name="org.apache.aurora.scheduler.thrift.ThriftIT$1" />
+    </Or>
+    <Bug pattern="DM_DEFAULT_ENCODING" />
+  </Match>
+
+  <Match>
+    <!-- False positives on a check introduced in findbugs 3.0.1 -->
+    <Or>
+      <Class name="org.apache.aurora.scheduler.storage.db.DbStorage$3" />
+      <Class name="org.apache.aurora.scheduler.http.api.security.AuthorizeHeaderTokenTest"
/>
+    </Or>
+    <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
+  </Match>
+
+  <Match>
+    <!-- Options fields may be flagged as always null, since they are set reflectively.
-->
+    <Class name="~org.apache.aurora.scheduler.*Options" />
+    <Bug pattern="UWF_NULL_FIELD" />
+  </Match>
+
+  <Match>
+    <!-- FIXME: We ignore return values of guava collection builders and thus trip this
warning.
+         We need to wait until either https://github.com/spotbugs/spotbugs/issues/463 or
+         https://github.com/google/guava/issues/2960 has been resolved -->
+    <Bug pattern="RV_RETURN_VALUE_IGNORED" />
+  </Match>
+</FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/aurora/blob/ad86177a/src/main/java/org/apache/aurora/scheduler/offers/OfferOrderBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/offers/OfferOrderBuilder.java b/src/main/java/org/apache/aurora/scheduler/offers/OfferOrderBuilder.java
index 2676da0..9b395fa 100644
--- a/src/main/java/org/apache/aurora/scheduler/offers/OfferOrderBuilder.java
+++ b/src/main/java/org/apache/aurora/scheduler/offers/OfferOrderBuilder.java
@@ -74,11 +74,11 @@ final class OfferOrderBuilder {
     return Ordering
         .natural()
         .onResultOf(o -> {
-          Double resource = bagFromMesosResources(
+          double resource = bagFromMesosResources(
               getRevocableOfferResources(o.getOffer())).valueOf(resourceType);
           // resource will be 0.0 if there is no revocable cpus available. Since the purpose
of
           // this ordering is to bin-pack revocable then we push those offers to the back.
-          return resource.equals(0.0) ? Double.MAX_VALUE : resource;
+          return resource == 0.0 ? Double.MAX_VALUE : resource;
         });
   }
 


Mime
View raw message