Fix sonar issues 83/109483/3
authorsebdet <sebastien.determe@intl.att.com>
Wed, 24 Jun 2020 10:14:27 +0000 (12:14 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 5 Jul 2020 09:56:45 +0000 (09:56 +0000)
Fix sonar/checkstyle issues in sdc code

Issue-ID: SDC-3158
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ib6ee78fd5756d615c2a103ac0d7d26070fd24206

asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java

index 236f819..cad059c 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -27,45 +27,27 @@ import org.openecomp.sdc.asdctool.impl.ProductLogic;
  */
 public class RemoveUtils {
 
-       public static void main(String[] args) {
-
-               if (args == null || args.length < 1) {
-                       removeUsage();
-               }else {
-                       String operation = args[0];
-                       if(operation.equalsIgnoreCase("remove-products")) {
-                               boolean isValid = verifyParamsLength(args, 5);
-                               if (!isValid) {
-                                       removeUsage();
-                                       System.exit(1);
-                               }
-                               ProductLogic productLogic = new ProductLogic();
-                               boolean result = productLogic.deleteAllProducts(args[1], args[2], args[3], args[4]);
-       
-                               if (!result) {
-                                       System.exit(2);
-                               }
-                       }else {
-                               removeUsage();
-                       }
-               }
-       }
-
-       private static void removeUsage() {
-               System.out.println("Usage: remove-products <janusgraph.properties> <BE host> <BE port> <admin user>");
-       }
-
-       private static boolean verifyParamsLength(String[] args, int i) {
-               if (args == null) {
-                       if (i > 0) {
-                               return false;
-                       }
-                       return true;
-               }
-
-               if (args.length >= i) {
-                       return true;
-               }
-               return false;
-       }
+    public static void main(String[] args) {
+        if (args == null || args.length == 0) {
+            showRemoveUsage();
+            System.exit(1);
+        } else if (args[0].equalsIgnoreCase("remove-products") && verifyParamsLength(args, 5)) {
+            if (!new ProductLogic().deleteAllProducts(args[1], args[2], args[3], args[4])) {
+                System.exit(2);
+            }
+        } else {
+            showRemoveUsage();
+        }
+    }
+
+    private static void showRemoveUsage() {
+        System.out.println("Usage: remove-products <janusgraph.properties> <BE host> <BE port> <admin user>");
+    }
+
+    private static boolean verifyParamsLength(String[] args, int nbOfArgumentsMin) {
+        if (args == null) {
+            return nbOfArgumentsMin == 0;
+        }
+        return args.length >= nbOfArgumentsMin;
+    }
 }