Fix few Major sonar issues
authorramu.n <ramu.n@huawei.com>
Mon, 18 Sep 2017 13:37:17 +0000 (19:07 +0530)
committerramu.n <ramu.n@huawei.com>
Mon, 18 Sep 2017 14:18:26 +0000 (19:48 +0530)
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 <ramu.n@huawei.com>
sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java
sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java
sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java

index 5e19a52..b9ad19e 100644 (file)
@@ -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();
        }
 
-       
-       
+
+
 }
index 2327743..aca904d 100644 (file)
@@ -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());
        }
 
 }
index 11b5fde..532ad31 100644 (file)
@@ -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;
        }
 
 }