From 6d95c7cfb45cebed0de5e31fae5874ffaa0fb577 Mon Sep 17 00:00:00 2001 From: sebdet Date: Wed, 24 Jun 2020 12:14:27 +0200 Subject: Fix sonar issues Fix sonar/checkstyle issues in sdc code Issue-ID: SDC-3158 Signed-off-by: sebdet Change-Id: Ib6ee78fd5756d615c2a103ac0d7d26070fd24206 --- .../openecomp/sdc/asdctool/main/RemoveUtils.java | 68 ++++++++-------------- 1 file changed, 25 insertions(+), 43 deletions(-) (limited to 'asdctool/src/main/java/org/openecomp') diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java index 236f819063..cad059cd01 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java @@ -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 "); - } - - 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 "); + } + + private static boolean verifyParamsLength(String[] args, int nbOfArgumentsMin) { + if (args == null) { + return nbOfArgumentsMin == 0; + } + return args.length >= nbOfArgumentsMin; + } } -- cgit 1.2.3-korg