Fix sonar issues in policy/gui

Issue-ID: POLICY-3095
Change-Id: Ida760b380acbc5784f685e0a4c95c09f017ebf57
Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
index 59af8f5..edaf7b7 100644
--- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
+++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
@@ -334,10 +334,10 @@
     triggerLabel.innerHTML = "Policy Trigger Event: ";
     var triggerevent = null;
     if (policy != null && policy.firstState != null && policy.firstState != "" && policy.state != null) {
-        for (i = 0; i < policy.state.entry.length; i++) {
-            if (policy.state.entry[i] != null && policy.state.entry[i].key != null) {
-                statename = policy.state.entry[i].key;
-                var state = policy.state.entry[i].value;
+        for (let entry of policy.state.entry) {
+            if (entry != null && entry.key != null) {
+                statename = entry.key;
+                var state = entry.value;
                 if (statename != null && statename == policy.firstState) {
                     triggerevent = {
                         "name" : state.trigger.name,
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js
index c6ef0db..2aa96e4 100644
--- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js
+++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyTab.js
@@ -81,9 +81,9 @@
                     "</td>";
 
                 policyTableRow += "<td><table class='ebTable'><thead><tr class='headerRow'><th>Task Reference</th><th>Output Type</th><th>Output</th></thead><tbody>";
-                for (let entry of state.taskReferences.entry) {
-                    var taskKey = entry.key;
-                    var taskRef = entry.value;
+                for (let taskEntry of state.taskReferences.entry) {
+                    var taskKey = taskEntry.key;
+                    var taskRef = taskEntry.value;
 
                     policyTableRow +=
                         "<tr><td>"                +
diff --git a/gui-pdp-monitoring/src/webapp/js/MonitoringUtils.js b/gui-pdp-monitoring/src/webapp/js/MonitoringUtils.js
index 9c6e076..2f2b044 100644
--- a/gui-pdp-monitoring/src/webapp/js/MonitoringUtils.js
+++ b/gui-pdp-monitoring/src/webapp/js/MonitoringUtils.js
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -309,11 +310,11 @@
 
 function getPdpList(data) {
     const pdpArray = [];
-    for (let i = 0; i < data.groups.length; i++) {
+    for (let value of data.groups) {
         var map = {};
-        map.title = data.groups[i].name;
+        map.title = value.name;
         map.children = [];
-        (data.groups[i].pdpSubgroups).forEach((pdpSubgroup, index) => {
+        (value.pdpSubgroups).forEach((pdpSubgroup, index) => {
             map.children[index] = {};
             map.children[index].title = pdpSubgroup.pdpType;
             const instanceId = [];
diff --git a/gui-pdp-monitoring/src/webapp/js/PdpListView.js b/gui-pdp-monitoring/src/webapp/js/PdpListView.js
index 9ae5c23..1e248ce 100644
--- a/gui-pdp-monitoring/src/webapp/js/PdpListView.js
+++ b/gui-pdp-monitoring/src/webapp/js/PdpListView.js
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020-2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,20 +27,20 @@
         var isNode=false
     function insertChildren(parentNode, traverseArr, subGroup) {
 
-        for(let i = 0; i < traverseArr.length; i++) {
+        for(let value of traverseArr) {
             if(parentNode === root) {
                 childLevel = 0
             }
             var currentLi = document.createElement('li')
             currentLi.setAttribute('level', childLevel)
-            if(traverseArr[i].children && traverseArr[i].children.length > 0) {
+            if(value.children && value.children.length > 0) {
                 var title = document.createElement('div')
                 var triangle = document.createElement('i')
                 var text = document.createElement('p')
                 currentLi.classList.add('parentNode')
                 title.classList.add('title')
                 triangle.classList.add('triangle')
-                text.innerText = traverseArr[i].title
+                text.innerText = value.title
                 title.appendChild(triangle)
                 title.appendChild(text)
                 currentLi.appendChild(title)
@@ -48,12 +49,12 @@
                 if(subGroup !== null){
                     index+= subGroup+"/"
                 }
-                insertChildren(currentLi, traverseArr[i].children, traverseArr[i].title)
+                insertChildren(currentLi, value.children, value.title)
             }else {
                 var a = document.createElement('a')
-                a.setAttribute('href',"#"+index+subGroup+"/"+traverseArr[i].title)
+                a.setAttribute('href',"#"+index+subGroup+"/"+value.title)
                 a.classList.add('pdps__link')
-                a.textContent= traverseArr[i].title
+                a.textContent= value.title
                 currentLi.appendChild(a)
                 isNode=true
             }