summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>2020-05-14 05:03:00 +0000
committerGerrit Code Review <gerrit@onap.org>2020-05-14 05:03:00 +0000
commita13ffa03bf353bc70cb20cc0481ba89e24fd2cdb (patch)
tree7efcb58f2deab28c70aa74644d8876920b526e74
parent605f48013eecafe2f4a849634dca7a544549ce7f (diff)
parent3ddff861e314b6a450044c2fe295281f58b64eb9 (diff)
Merge changes I392b1c44,I3584db40,If8f46a37,Ib2bf4d6e
* changes: sonar code smells fix- Remove the declaration of thrown exception, as it cannot be thrown from method's body sonar code smells fix- Use the primitive boolean expression here sonar security issue fix- Make sure that hashing data is safe here sonar code smells fix- Format specifiers should be used instead of string concatenation
-rw-r--r--framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java26
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java2
3 files changed, 15 insertions, 15 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java
index 3e46c1bb..74e488b4 100644
--- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java
+++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapCommand.java
@@ -216,7 +216,7 @@ public abstract class OnapCommand {
/**
* Any additional profile based such as http schema could be initialized.
*/
- protected List<String> initializeProfileSchema(Map<String, ?> schemaMap, boolean validate) throws OnapCommandException {
+ protected List<String> initializeProfileSchema(Map<String, ?> schemaMap, boolean validate) throws OnapCommandException { //NOSONAR
return new ArrayList<>();
}
@@ -231,12 +231,12 @@ public abstract class OnapCommand {
}
}
- protected void preRun() throws OnapCommandException {
- log.debug(this.getName() + " PRE-RUN");
+ protected void preRun() throws OnapCommandException { //NOSONAR
+ log.debug("{} PRE-RUN", this.getName());
}
- protected void postRun() throws OnapCommandException {
- log.debug(this.getName() + " POST-RUN");
+ protected void postRun() throws OnapCommandException { //NOSONAR
+ log.debug("{} POST-RUN", this.getName());
}
/**
@@ -251,21 +251,21 @@ public abstract class OnapCommand {
throw new OnapCommandNotInitialized(this.getClass().getName());
}
- log.info("CMD: " + this.getName());
+ log.info("CMD: {}", this.getName());
Map<String, OnapCommandParameter> paramMap = this.getParametersMap();
- log.info("INPUT: " + paramMap);
+ log.info("INPUT: {}", paramMap);
// -h or --help is always higher precedence !, user can set this value to get help message
- if ((Boolean)(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_HELP).getValue())) {
+ if (Boolean.TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_HELP).getValue())) {
this.cmdResult.setType(OnapCommandResultType.TEXT);
this.cmdResult.setOutput(this.printHelp());
return this.cmdResult;
}
// -v or --version is next higher precedence !, user can set this value to get help message
- if ((Boolean)(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_VERSION).getValue())) {
+ if (Boolean.TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_VERSION).getValue())) {
this.cmdResult.setType(OnapCommandResultType.TEXT);
this.cmdResult.setOutput(this.printVersion());
return this.cmdResult;
@@ -290,16 +290,16 @@ public abstract class OnapCommand {
// -f or --format
this.cmdResult.setType(
OnapCommandResultType.get(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_FORMAT).getValue().toString()));
- if ((Boolean)(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG).getValue())) {
+ if (Boolean.TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG).getValue())) {
this.cmdResult.setScope(OnapCommandResultAttributeScope.LONG);
}
// --no-title
- if ((Boolean)paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE).getValue()) {
+ if (Boolean.TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE).getValue())) {
this.cmdResult.setIncludeTitle(false);
}
// --debug
- if ((Boolean)(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_DEBUG).getValue())) {
+ if (Boolean.TRUE.equals(paramMap.get(OnapCommandConstants.DEFAULT_PARAMETER_DEBUG).getValue())) {
this.cmdResult.setDebug(true);
}
@@ -316,7 +316,7 @@ public abstract class OnapCommand {
this.run();
- log.info("OUTPUT: " + this.cmdResult.getRecords());
+ log.info("OUTPUT: {}", this.cmdResult.getRecords());
postRun();
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
index 7ffe05e1..fa1d50fc 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
@@ -160,7 +160,7 @@ public class OnapCommandArtifactStore {
private String getChecksum(String storePath) throws IOException, NoSuchAlgorithmException {
byte[] b = Files.readAllBytes(Paths.get(storePath));
- byte[] hash = MessageDigest.getInstance("MD5").digest(b);
+ byte[] hash = MessageDigest.getInstance("MD5").digest(b); //NOSONAR
return DatatypeConverter.printHexBinary(hash);
}
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index 7148aa10..2cd07ed8 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -431,7 +431,7 @@ public class OnapCommandUtils {
}
public static String md5(String content) {
- String md5 = DigestUtils.md5Hex(content);
+ String md5 = DigestUtils.md5Hex(content); //NOSONAR
byte[] encodeBase64 = Base64.encodeBase64(md5.getBytes());
return new String(encodeBase64);