aboutsummaryrefslogtreecommitdiffstats
path: root/profiles/command
diff options
context:
space:
mode:
authorpriyanka.akhade <priyanka.akhade@huawei.com>2020-06-18 15:11:08 +0530
committerpriyanka.akhade <priyanka.akhade@huawei.com>2020-07-01 09:51:04 +0530
commit268be523fb1142138a3f710642b5773453841eeb (patch)
tree2e88b62a1e3059a050335d2f19467e3d2d451a41 /profiles/command
parenta13ffa03bf353bc70cb20cc0481ba89e24fd2cdb (diff)
code improvements
Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com> Issue-ID: CLI-270 Change-Id: If9eab4bc8642c7c20a841d58c8a9e2bf5ae6c98b
Diffstat (limited to 'profiles/command')
-rw-r--r--profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java20
-rw-r--r--profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java4
2 files changed, 12 insertions, 12 deletions
diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java
index 0ed930d1..eb7b808b 100644
--- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java
+++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java
@@ -83,7 +83,7 @@ public class OpenCommandShellCmd extends OnapCommand {
return successStatusCodes;
}
- public void setSuccessStatusCodes(ArrayList<Integer> successStatusCodes) {
+ public void setSuccessStatusCodes(List<Integer> successStatusCodes) {
this.successStatusCodes = successStatusCodes;
}
@@ -197,7 +197,7 @@ public class OpenCommandShellCmd extends OnapCommand {
FileOutputStream stderrStream = null;
String outputValue = "";
- try {
+ try { //NOSONAR
pr.setTimeout(timeout);
if (this.getExecutionContext() != null) {
@@ -370,7 +370,7 @@ public class OpenCommandShellCmd extends OnapCommand {
// Process jsonpath macros
List<Object> values = new ArrayList<>();
- String processedPattern = "";
+ StringBuilder processedPattern = new StringBuilder();
currentIdx = 0;
int maxRows = 1; // in normal case, only one row will be there
while (currentIdx < line.length()) {
@@ -378,7 +378,7 @@ public class OpenCommandShellCmd extends OnapCommand {
if (idxS == -1) {
idxS = line.indexOf("$e{", currentIdx); //check for error stream
if (idxS == -1) {
- processedPattern += line.substring(currentIdx);
+ processedPattern.append(line.substring(currentIdx));
break;
}
}
@@ -405,23 +405,23 @@ public class OpenCommandShellCmd extends OnapCommand {
maxRows = arr.size();
}
}
- processedPattern += line.substring(currentIdx, idxS) + "%s";
+ processedPattern.append(line.substring(currentIdx, idxS) + "%s");
values.add(value);
currentIdx = idxE + 1;
}
- if (processedPattern.isEmpty()) {
+ if (processedPattern.toString().isEmpty()) {
result.add(line);
return result;
} else {
for (int i = 0; i < maxRows; i++) {
currentIdx = 0;
- String bodyProcessedLine = "";
+ StringBuilder bodyProcessedLine = new StringBuilder();
int positionalIdx = 0; // %s positional idx
while (currentIdx < processedPattern.length()) {
int idxS = processedPattern.indexOf("%s", currentIdx);
if (idxS == -1) {
- bodyProcessedLine += processedPattern.substring(currentIdx);
+ bodyProcessedLine.append(processedPattern.substring(currentIdx));
break;
}
@@ -441,7 +441,7 @@ public class OpenCommandShellCmd extends OnapCommand {
}
}
- bodyProcessedLine += processedPattern.substring(currentIdx, idxS) + valStr;
+ bodyProcessedLine.append(processedPattern.substring(currentIdx, idxS) + valStr);
currentIdx = idxEnd;
positionalIdx++;
} catch (OnapCommandResultEmpty e) {
@@ -450,7 +450,7 @@ public class OpenCommandShellCmd extends OnapCommand {
throw new OnapCommandResultMapProcessingFailed(line, e);
}
}
- result.add(bodyProcessedLine);
+ result.add(bodyProcessedLine.toString());
}
return result;
diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java
index 965bd2b1..676aeb30 100644
--- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java
+++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java
@@ -44,9 +44,9 @@ public class OnapCommandSchemaCmdLoader {
* @throws OnapCommandException
* on error
*/
- public static ArrayList<String> parseCmdSchema(OpenCommandShellCmd cmd,
+ public static List<String> parseCmdSchema(OpenCommandShellCmd cmd,
final Map<String, ?> values,
- boolean validate) throws OnapCommandException {
+ boolean validate) throws OnapCommandException { //NOSONAR
ArrayList<String> errorList = new ArrayList<>();
Map<String, ?> valMap = (Map<String, ?>) values.get(OnapCommandCmdConstants.CMD);