Fix major sonar issues 37/15437/5
authorshashikanth <shashikanth.vh@huawei.com>
Tue, 26 Sep 2017 10:06:17 +0000 (15:36 +0530)
committerShashikanth VH <shashikanth.vh@huawei.com>
Wed, 27 Sep 2017 04:58:42 +0000 (04:58 +0000)
Fix major sonar issues in policy/drools-applications module
https://sonar.onap.org/component_issues?id=org.onap.policy.drools-applications%3Adrools-pdp-apps#resolved=false|severities=MAJOR|rules=squid%3AS1132

Fixed string literal comparison for for SO and VF Module Create and few optimizations.

Issue-Id:POLICY-239
Change-Id: I8e228463ebc7f3114e5caba9b423552bb84dd52d
Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java

index a014c7a..8c1b23a 100644 (file)
@@ -136,10 +136,10 @@ public class SOActorServiceProvider implements Actor {
                
        }
        
-       /**
+        /**
         * Constructs and sends an AAI vserver Named Query
         * 
-        * @param eventRequestID
+        * @param onset
         * @returns the response to the AAI Named Query
         */
        private AAINQResponseWrapper AaiNamedQueryRequest(VirtualControlLoopEvent onset) {
@@ -239,9 +239,9 @@ public class SOActorServiceProvider implements Actor {
                        int nonBaseIndex = -1;
                        List<AAINQInventoryResponseItem> inventoryItems = namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;
                        for (AAINQInventoryResponseItem m : inventoryItems) {
-                               if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {
+                               if (m.vfModule != null && m.vfModule.isBaseVfModule) {
                                        baseIndex = inventoryItems.indexOf(m);
-                               } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {
+                               } else if (m.vfModule != null && m.vfModule.orchestrationStatus == null) {
                                        nonBaseIndex = inventoryItems.indexOf(m);
                                }
                                //
@@ -302,7 +302,7 @@ public class SOActorServiceProvider implements Actor {
                }
 
                // Extracted fields should not be null
-               if (checkExtractedFields() == false) {
+               if (!checkExtractedFields()) {
                        System.err.println("some fields are missing from AAI response.");
                        return;
                }
@@ -338,7 +338,7 @@ public class SOActorServiceProvider implements Actor {
         */
        public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
 
-               if (policy.getActor().equals("SO") && policy.getRecipe().equals("VF Module Create")) {
+               if ("SO".equals(policy.getActor()) && "VF Module Create".equals(policy.getRecipe())) {
                        // perform named query request and handle response
                        AaiNamedQueryRequest(onset);
                } else {
@@ -348,7 +348,7 @@ public class SOActorServiceProvider implements Actor {
           
                // check if the fields extracted from named query response are 
                // not null so we can proceed with SO request
-               if (checkExtractedFields() == false) {
+               if (!checkExtractedFields()) {
                        
                        System.err.println("AAI response is missing some required fields. Cannot proceed with SO Request construction.");
                        return null;
@@ -553,7 +553,7 @@ public class SOActorServiceProvider implements Actor {
        }
 
        /**
-        * @param serviceItemModeInvariantlId the serviceItemModelInvariantId to set
+        * @param serviceItemModelInvariantId the serviceItemModelInvariantId to set
         */
        private void setServiceItemModelInvariantId(String serviceItemModelInvariantId) {
                this.serviceItemModelInvariantId = serviceItemModelInvariantId;