Fixed some major sonar issues in yang-validation-tool 02/26902/9
authorIgor Foltin <igor.foltin@pantheon.sk>
Mon, 14 Sep 2015 08:25:36 +0000 (10:25 +0200)
committerIgor Foltin <igor.foltin@pantheon.sk>
Tue, 22 Sep 2015 13:01:08 +0000 (13:01 +0000)
Change-Id: Ifba514ef314df1829f8e1497238cfc3a7705bd0f
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/Main.java
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/Params.java

index b1c94b0cbcb9fe7e74f554da441a7d5e3246fd99..78ee8a535a312ee33f8e2dcb5d3e02edf8e3b58e 100644 (file)
@@ -11,8 +11,13 @@ import java.io.File;
 import java.net.URISyntaxException;
 import java.util.Arrays;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class Main {
+
+    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
+
     private Main() {
 
     }
@@ -27,7 +32,7 @@ public final class Main {
             try {
                 yangParser.parseFiles(Arrays.asList(yangModels));
             } catch (Exception e) {
-
+                LOG.error("Yang files could not be parsed.", e);
             }
         }
     }
index 6cd01cd64231cdb4218c131ff7e93bff31819806..205f54c3316e4a7a9d2bce287caee03be86e030f 100644 (file)
@@ -12,9 +12,12 @@ import java.net.URISyntaxException;
 import net.sourceforge.argparse4j.ArgumentParsers;
 import net.sourceforge.argparse4j.annotation.Arg;
 import net.sourceforge.argparse4j.inf.ArgumentParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 final class Params {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Params.class);
     @Arg(dest = "yang-source-dir")
     private File yangSourceDir;
 
@@ -39,15 +42,15 @@ final class Params {
             return false;
         }
         if (!yangSourceDir.exists()) {
-            System.err.println("Yang source directory has to exist");
+            LOGGER.error("Yang source directory has to exist");
             return false;
         }
         if (!yangSourceDir.canRead()) {
-            System.err.println("Yang source directory has to be readable");
+            LOGGER.error("Yang source directory has to be readable");
             return false;
         }
         if (yangSourceDir.list().length == 0) {
-            System.err.printf("Yang source directory '%s' does't contain any model%n", yangSourceDir.getPath());
+            LOGGER.error("Yang source directory {} doesn't contain any model", yangSourceDir.getPath());
             return false;
         }