Enable spotbugs in yang-model-export 97/83897/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Aug 2019 12:44:39 +0000 (14:44 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 22 Aug 2019 12:44:39 +0000 (14:44 +0200)
SpotBugs is getting confused by our use of checkArgument, not
understanding we will catch nulls. Refactor the code removing
the violation and remove enforcement override.

Change-Id: I787359c01f2761448cb4f3d33aea0baf5e642ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-export/pom.xml
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/ExportUtils.java

index 7ff27cb5064f7e16d271cc9725cb9b373fa8140a..75d72a5f6d9193fbdb4ba40f5c181d25809581ec 100644 (file)
     <name>${project.artifactId}</name>
     <description>${project.artifactId}</description>
 
-    <properties>
-        <!-- FIXME: we have some violations here -->
-        <odlparent.spotbugs.enforce>false</odlparent.spotbugs.enforce>
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index 1baf8002fcfef50e3dbd8c33c86727443027a242..585cfeac6a93cbc6f844603de8d51b5b506adedb 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.model.export;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Verify.verify;
 
 import java.util.Map;
@@ -59,7 +58,10 @@ final class ExportUtils {
             }
         }
 
-        checkArgument(prefix != null, "Failed to find prefix for statement %s", stmtName);
+        if (prefix == null) {
+            throw new IllegalArgumentException("Failed to find prefix for statement " + stmtName);
+        }
+
         verify(!prefix.isEmpty(), "Empty prefix for statement %s", stmtName);
         return Optional.of(prefix);
     }