aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorjitendra007 <jitendra.sharma1@huawei.com>2020-07-21 14:35:31 +0530
committerpriyanka.akhade <priyanka.akhade@huawei.com>2020-08-04 09:44:38 +0530
commit9921b1751cde31721958d004935f2b7fc5e95513 (patch)
treee41a158075ba6f95af21fc9ef25425e0dca51851 /main
parentfc9af3118881c83a0928e9a21135641808288f84 (diff)
Code improvement for pending sonar issues
Issue-ID: CLI-270 Signed-off-by: jitendra007 <jitendra.sharma1@huawei.com> Change-Id: Ie27d3ff077fa1ef4d13788849aa82d695f183eeb
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java86
1 files changed, 39 insertions, 47 deletions
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index 061c1f7b..1c27205f 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -225,8 +225,8 @@ public class OnapCli {
if (this.profile != null) {
OnapCommandRegistrar.getRegistrar().setProfile(
this.profile,
- new ArrayList<String>(),
- new ArrayList<String>());
+ new ArrayList<>(),
+ new ArrayList<>());
}
} catch (Exception e) {
this.print(e);
@@ -378,10 +378,9 @@ public class OnapCli {
break;
} else if (OnapCliConstants.PARAM_INTERACTIVE_CLEAR.equalsIgnoreCase(line)) {
console.clearScreen();
- continue;
- }
- this.args = new ArrayList<>();
- this.args.addAll(Arrays.asList(line.split(OnapCliConstants.PARAM_INTERACTIVE_ARG_SPLIT_PATTERN)));
+ } else {
+ this.args = new ArrayList<>();
+ this.args.addAll(Arrays.asList(line.split(OnapCliConstants.PARAM_INTERACTIVE_ARG_SPLIT_PATTERN)));
if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_USE)) {
if (args.size() == 1) {
@@ -397,53 +396,46 @@ public class OnapCli {
}
} else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_HELP)) {
- try {
- this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion());
- this.print(OnapCli.getDirectiveHelp());
- } catch (OnapCommandException e) {
- this.print(e);
- }
-
- } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_VERSION)) {
- this.printVersion = true;
- handleVersion();
-
- } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_PROFILE)) {
- if (args.size() == 1) {
- this.print("Please use it in the form of 'profile <profile-name>'\n");
- this.print("Available profiles: ");
- this.print(OnapCommandRegistrar.getRegistrar().getUserProfiles().toString());
- } else {
- this.profile = args.get(1);
- handleProfile();
- }
+ this.print(OnapCommandRegistrar.getRegistrar().getHelpForEnabledProductVersion());
+ this.print(OnapCli.getDirectiveHelp());
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_VERSION)) {
+ this.printVersion = true;
+ handleVersion();
+
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_PROFILE)) {
+ if (args.size() == 1) {
+ this.print("Please use it in the form of 'profile <profile-name>'\n");
+ this.print("Available profiles: ");
+ this.print(OnapCommandRegistrar.getRegistrar().getUserProfiles().toString());
+ } else {
+ this.profile = args.get(1);
+ handleProfile();
+ }
- } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_SET)) {
- if (args.size() > 1) {
- String [] paramEntry = args.get(1).trim().split("=", 2);
- if (paramEntry.length == 2) {
- OnapCommandRegistrar.getRegistrar().addParamCache(paramEntry[0].trim(), paramEntry[1].trim());
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_SET)) {
+ if (args.size() > 1) {
+ String[] paramEntry = args.get(1).trim().split("=", 2);
+ if (paramEntry.length == 2) {
+ OnapCommandRegistrar.getRegistrar().addParamCache(paramEntry[0].trim(), paramEntry[1].trim());
+ } else {
+ this.print("Please use it in the form of 'set <param-name>=<param-value>'");
+ }
} else {
- this.print("Please use it in the form of 'set <param-name>=<param-value>'");
+ this.print(OnapCommandRegistrar.getRegistrar().getParamCache().toString());
}
- } else {
- this.print(OnapCommandRegistrar.getRegistrar().getParamCache().toString());
- }
- } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_UNSET)) {
- if (args.size() > 1) {
- for (int i = 1; i <args.size(); i++) {
- OnapCommandRegistrar.getRegistrar().removeParamCache(args.get(i));
+ } else if (!args.isEmpty() && this.args.get(0).equals(OnapCliConstants.PARAM_INTERACTIVE_UNSET)) {
+ if (args.size() > 1) {
+ for (int i = 1; i < args.size(); i++) {
+ OnapCommandRegistrar.getRegistrar().removeParamCache(args.get(i));
+ }
+ }
+ } else {
+ if (!(args.size() == 1 && args.get(0).trim().isEmpty())) {
+ this.setArgs(this.args.toArray(new String[]{}));
+ handleCommand();
}
}
- } else {
- if (args.size() == 1 && args.get(0).trim().isEmpty()) {
- //Ignore blanks // NOSONAR
- continue;
- }
-
- this.setArgs(this.args.toArray(new String [] {}));
- handleCommand();
}
}
} catch (IOException e) { // NOSONAR