You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2017/12/04 16:08:42 UTC

aurora git commit: Clean up some lint rules

Repository: aurora
Updated Branches:
  refs/heads/master 89338dd7f -> a0628efd1


Clean up some lint rules

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


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

Branch: refs/heads/master
Commit: a0628efd1773bd1a650de7e4d8c94ffdf0313651
Parents: 89338dd
Author: Bill Farner <wf...@apache.org>
Authored: Mon Dec 4 08:08:43 2017 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Mon Dec 4 08:08:43 2017 -0800

----------------------------------------------------------------------
 config/pmd/main.xml                             |  7 -----
 config/spotbugs/excludeFilter.xml               | 31 --------------------
 .../aurora/scheduler/http/Utilization.java      |  7 +++--
 .../aurora/scheduler/http/api/ApiBeta.java      |  2 +-
 .../api/security/AuthorizeHeaderTokenTest.java  |  2 +-
 5 files changed, 6 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/a0628efd/config/pmd/main.xml
----------------------------------------------------------------------
diff --git a/config/pmd/main.xml b/config/pmd/main.xml
index b90c221..9c3f578 100644
--- a/config/pmd/main.xml
+++ b/config/pmd/main.xml
@@ -23,10 +23,6 @@ limitations under the License.
   </description>
 
   <rule ref="rulesets/java/design.xml">
-    <!-- This rule suffers from false positivies in cases where we are implementing a third-party
-         interface. -->
-    <exclude name="UseVarargs"/>
-
     <!-- We're not currently focusing on localization. -->
     <exclude name="SimpleDateFormatNeedsLocale"/>
     <exclude name="UseLocaleWithCaseConversions"/>
@@ -40,9 +36,6 @@ limitations under the License.
     <!-- Unfortunately we have several large classes that trip this rule.
          TODO(wfarner): Break apart god classes. -->
     <exclude name="GodClass"/>
-
-    <!-- Classes that are only meant to be managed by mybatis with reflection trip this rule. -->
-    <exclude name="MissingStaticMethodInNonInstantiatableClass"/>
   </rule>
 
   <!-- Custom rules -->

http://git-wip-us.apache.org/repos/asf/aurora/blob/a0628efd/config/spotbugs/excludeFilter.xml
----------------------------------------------------------------------
diff --git a/config/spotbugs/excludeFilter.xml b/config/spotbugs/excludeFilter.xml
index 51790cc..799ccdc 100644
--- a/config/spotbugs/excludeFilter.xml
+++ b/config/spotbugs/excludeFilter.xml
@@ -21,12 +21,6 @@ limitations under the License.
       <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" />
@@ -38,18 +32,6 @@ limitations under the License.
     </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>
@@ -80,10 +62,6 @@ limitations under the License.
     <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>
@@ -113,15 +91,6 @@ limitations under the License.
   </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" />

http://git-wip-us.apache.org/repos/asf/aurora/blob/a0628efd/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/Utilization.java b/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
index efacd8c..d4dfd1b 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
@@ -178,12 +178,13 @@ public class Utilization {
   }
 
   private MetricType getTypeByName(String name) throws WebApplicationException {
-    MetricType type = MetricType.valueOf(name.toUpperCase(Locale.ENGLISH));
-    if (type == null) {
+    try {
+      return MetricType.valueOf(name.toUpperCase(Locale.ENGLISH));
+    } catch (IllegalArgumentException e) {
       throw new WebApplicationException(
+          e,
           Response.status(Status.BAD_REQUEST).entity("Invalid metric type.").build());
     }
-    return type;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/aurora/blob/a0628efd/src/main/java/org/apache/aurora/scheduler/http/api/ApiBeta.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/api/ApiBeta.java b/src/main/java/org/apache/aurora/scheduler/http/api/ApiBeta.java
index f923067..2414d37 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/api/ApiBeta.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/api/ApiBeta.java
@@ -107,7 +107,7 @@ public class ApiBeta {
     return params.toArray();
   }
 
-  private Method getApiMethod(String name, Class<?>[] parameterTypes) {
+  private Method getApiMethod(String name, Class<?>... parameterTypes) {
     try {
       return Iface.class.getMethod(name, parameterTypes);
     } catch (NoSuchMethodException e) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/a0628efd/src/test/java/org/apache/aurora/scheduler/http/api/security/AuthorizeHeaderTokenTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/security/AuthorizeHeaderTokenTest.java b/src/test/java/org/apache/aurora/scheduler/http/api/security/AuthorizeHeaderTokenTest.java
index 9e956de..89dc447 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/security/AuthorizeHeaderTokenTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/security/AuthorizeHeaderTokenTest.java
@@ -27,7 +27,7 @@ public class AuthorizeHeaderTokenTest {
 
   @Test(expected = IllegalArgumentException.class)
   public void testInvalidScheme() {
-    new AuthorizeHeaderToken("Basic " + ALADDIN_OPEN_SESAME).getAuthorizeHeaderValue();
+    new AuthorizeHeaderToken("Basic " + ALADDIN_OPEN_SESAME);
   }
 
   @Test(expected = IllegalArgumentException.class)