Enable SpotBugs enforcement in yang-validation-tool 47/87647/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 17:59:43 +0000 (18:59 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 19:58:06 +0000 (20:58 +0100)
There are just two issues reported, fix/suppress them and flip
enforcement on.

Change-Id: Id145facbd6da836108d8d938150e34462f9fde5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang-validation-tool/pom.xml
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/Params.java
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/ParamsUtil.java

index 1e1fc8e4a048ca8d0249089a57d79aee1245a7c4..b8f63681138a88f037fb7113c1ef78bbeeb424b2 100644 (file)
     <artifactId>yang-validation-tool</artifactId>
     <version>4.0.8-SNAPSHOT</version>
 
-    <properties>
-        <!-- FIXME: we have some violations here -->
-        <odlparent.spotbugs.enforce>false</odlparent.spotbugs.enforce>
-    </properties>
-
     <dependencyManagement>
         <dependencies>
             <dependency>
index 82b92cfceab90200c435c3ac2c20606a62563da1..aab1789532b1333a213788b2d7f303d462b2131d 100644 (file)
@@ -15,8 +15,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class Params {
-
     private static final Logger LOG = LoggerFactory.getLogger(Params.class);
+
     @Arg(dest = "yang-source-dir")
     private File yangSourceDir;
 
@@ -48,7 +48,12 @@ final class Params {
             LOG.error("Yang source directory has to be readable");
             return false;
         }
-        if (yangSourceDir.list().length == 0) {
+        final String[] listed = yangSourceDir.list();
+        if (listed == null) {
+            LOG.error("Yang source directory {} is not a directory or cannot be read", yangSourceDir.getPath());
+            return false;
+        }
+        if (listed.length == 0) {
             LOG.error("Yang source directory {} doesn't contain any model", yangSourceDir.getPath());
             return false;
         }
index bfdfc3c7f05d4cdfcec61345f07af01e4001ffa5..498c00b0a820794d6c5f04271a05452f5c8007cb 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.validation.tool;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import net.sourceforge.argparse4j.inf.ArgumentParser;
 import net.sourceforge.argparse4j.inf.ArgumentParserException;
 
@@ -15,7 +16,8 @@ final class ParamsUtil {
 
     }
 
-    public static Params parseArgs(final String[] args, final ArgumentParser parser) {
+    @SuppressFBWarnings(value = "DM_EXIT", justification = "We do expect to terminate the JVM")
+    static Params parseArgs(final String[] args, final ArgumentParser parser) {
         final Params params = new Params();
         try {
             parser.parseArgs(args, params);