From a74b012e58223276e9903db3b0905ba72e4cb259 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Mon, 18 Sep 2017 19:07:17 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Remove useless parentheses * Remove useless assignment to local variable * Use logger method instead of string formatting Change-Id: Ie9958d0bc4e754c36c127d465a1953160c2c3e2b Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java | 92 +++++++++++----------- .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 6 +- .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 14 ++-- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java index 5e19a52c..b9ad19e2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java @@ -8,9 +8,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. @@ -22,7 +22,7 @@ package org.onap.ccsdk.sli.core.sli; public class SvcLogicAtom extends SvcLogicExpression { - + public enum AtomType { NUMBER, STRING, @@ -30,7 +30,7 @@ public class SvcLogicAtom extends SvcLogicExpression { CONTEXT_VAR } - + private AtomType atomType; private String atom; @@ -39,9 +39,9 @@ public class SvcLogicAtom extends SvcLogicExpression { { this.atomType = AtomType.valueOf(atomType); this.atom = atom; - + } - + public SvcLogicAtom(String atom) { @@ -73,9 +73,9 @@ public class SvcLogicAtom extends SvcLogicExpression { { this.atomType = AtomType.IDENTIFIER; this.atom = atom; - + } - + } } } @@ -83,7 +83,7 @@ public class SvcLogicAtom extends SvcLogicExpression { public AtomType getAtomType() { return atomType; } - + public void setAtomType(String newType) { atomType = AtomType.valueOf(newType); @@ -92,9 +92,9 @@ public class SvcLogicAtom extends SvcLogicExpression { public String getAtom() { return atom; } - - - + + + public void setAtomType(AtomType atomType) { this.atomType = atomType; } @@ -110,27 +110,27 @@ public class SvcLogicAtom extends SvcLogicExpression { StringBuffer sbuff = new StringBuffer(); switch(getAtomType()) { - case CONTEXT_VAR: - sbuff.append("$"); - case IDENTIFIER: - boolean needDot = false; - for (SvcLogicExpression term: this.getOperands()) - { - if (needDot) + case CONTEXT_VAR: + sbuff.append("$"); + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term: this.getOperands()) { - sbuff.append("."); + if (needDot) + { + sbuff.append("."); + } + sbuff.append(term.toString()); + needDot = true; } - sbuff.append(term.toString()); - needDot = true; - } - return(sbuff.toString()); - case STRING: - case NUMBER: - default: - return(atom); + return sbuff.toString(); + case STRING: + case NUMBER: + default: + return atom; } } - + public String asParsedExpr() { // simplify debugging output for NUMBER type @@ -139,32 +139,32 @@ public class SvcLogicAtom extends SvcLogicExpression { } StringBuffer sbuff = new StringBuffer(); - + sbuff.append("(atom"); sbuff.append("<"); sbuff.append(atomType.toString()); sbuff.append(">"); - + switch(atomType) { - case IDENTIFIER: - case CONTEXT_VAR: - for (SvcLogicExpression term : getOperands()) - { + case IDENTIFIER: + case CONTEXT_VAR: + for (SvcLogicExpression term : getOperands()) + { + sbuff.append(" "); + sbuff.append(term.asParsedExpr()); + + } + break; + default: sbuff.append(" "); - sbuff.append(term.asParsedExpr()); - - } - break; - default: - sbuff.append(" "); - sbuff.append(atom); + sbuff.append(atom); } - + sbuff.append(")"); - return(sbuff.toString()); + return sbuff.toString(); } - - + + } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index 23277439..aca904d1 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -212,7 +212,7 @@ public class SvcLogicContext { if (ctxVarName.indexOf('[') == -1) { // Ctx variable contains no arrays - return (this.getAttribute(ctxVarName)); + return getAttribute(ctxVarName); } // Resolve any array references @@ -225,7 +225,7 @@ public class SvcLogicContext { if (endBracketLoc == -1) { // Missing end bracket ... give up parsing LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName); - return (this.getAttribute(ctxVarName)); + return getAttribute(ctxVarName); } String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); @@ -242,7 +242,7 @@ public class SvcLogicContext { } } - return (this.getAttribute(sbuff.toString())); + return getAttribute(sbuff.toString()); } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 11b5fdea..532ad31b 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -8,9 +8,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. @@ -43,7 +43,7 @@ public class SvcLogicStoreFactory { } try { - return (getSvcLogicStore(new FileInputStream(propFile))); + return getSvcLogicStore(new FileInputStream(propFile)); } catch (Exception e) { throw new ConfigurationException( "Could load service store from properties file " + propfile, @@ -62,7 +62,7 @@ public class SvcLogicStoreFactory { throw new ConfigurationException("Could not get load properties from input stream", e); } - return(getSvcLogicStore(props)); + return getSvcLogicStore(props); } public static SvcLogicStore getSvcLogicStore(Properties props) @@ -74,8 +74,8 @@ public class SvcLogicStoreFactory { } - SvcLogicStore retval = null; - LOG.debug(String.format("Using org.onap.ccsdk.sli.dbtype=%s", storeType)); + SvcLogicStore retval; + LOG.debug("Using org.onap.ccsdk.sli.dbtype={}", storeType); if ("jdbc".equalsIgnoreCase(storeType)) { retval = new SvcLogicJdbcStore(); @@ -90,7 +90,7 @@ public class SvcLogicStoreFactory { retval.init(props); - return (retval); + return retval; } } -- cgit 1.2.3-korg