From 153ec0fda79b07ca1ecf7016f1e7f4e2c792f04e Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 5 Feb 2018 09:38:29 -0500 Subject: Remove technical debt * String literals on the left * Unnecessary initialization of variables * Change ArrayList to using List * Remove extra semicolons * Empty Constructor comments * Useless parenthesis I also added a comment on some code that is suspicious. Not comfortable with changing that code. Issue-ID: POLICY-482 Change-Id: I89d889737d398d047fab4b25cb5d962ee1ecdd03 Signed-off-by: Pamela Dragosh --- .../java/org/onap/policy/admin/PolicyManagerServlet.java | 2 +- .../org/onap/policy/controller/AutoPushController.java | 16 ++++++++++------ .../controller/CreateClosedLoopFaultController.java | 16 ++++++++-------- .../onap/policy/controller/CreateFirewallController.java | 4 +++- 4 files changed, 22 insertions(+), 16 deletions(-) (limited to 'POLICY-SDK-APP/src') diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java index 93fe82c34..16a8ff7a9 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java @@ -1276,7 +1276,7 @@ public class PolicyManagerServlet extends HttpServlet { } } }else{ - List activePoliciesInPDP = new ArrayList(); + List activePoliciesInPDP = new ArrayList<>(); if(!policyEntityobjects.isEmpty()){ for(Object object : policyEntityobjects){ policyEntity = (PolicyEntity) object; diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java index e0388e5d6..96e104656 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java @@ -119,8 +119,8 @@ public class AutoPushController extends RestrictedBaseController{ @RequestMapping(value={"/get_AutoPushPoliciesContainerData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPolicyGroupContainerData(HttpServletRequest request, HttpServletResponse response){ try{ - Set scopes = null; - List roles = null; + Set scopes; + List roles; data = new ArrayList<>(); String userId = UserUtils.getUserSession(request).getOrgUserId(); Map model = new HashMap<>(); @@ -139,7 +139,7 @@ public class AutoPushController extends RestrictedBaseController{ scopes.add(multipleScopes[i]); } }else{ - if(!userRole.getScope().equals("")){ + if(!"".equals(userRole.getScope())){ scopes.add(userRole.getScope()); } } @@ -220,7 +220,7 @@ public class AutoPushController extends RestrictedBaseController{ // Get the current selection String selectedItem = policyId; // - assert (selectedItem != null); + assert selectedItem != null; // create the id of the target file // Our standard for file naming is: // ...xml @@ -328,6 +328,10 @@ public class AutoPushController extends RestrictedBaseController{ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups)); JSONObject j = new JSONObject(msg); out.write(j.toString()); + // + // Why is this here? This defeats the purpose of the loop?? + // Sonar says to remove it or make it conditional + // return null; } } @@ -336,7 +340,7 @@ public class AutoPushController extends RestrictedBaseController{ request.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); logger.error(e); - out.write(PolicyUtils.CATCH_EXCEPTION);; + out.write(PolicyUtils.CATCH_EXCEPTION); } return null; } @@ -393,7 +397,7 @@ public class AutoPushController extends RestrictedBaseController{ request.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); logger.error(e); - out.write(PolicyUtils.CATCH_EXCEPTION);; + out.write(PolicyUtils.CATCH_EXCEPTION); } return null; } diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java index 7cfc4fed4..d942939d1 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java @@ -168,7 +168,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{ @SuppressWarnings("unchecked") - private String connectTriggerSignature(int index, ArrayList triggerSignatures, Object object) { + private String connectTriggerSignature(int index, List triggerSignatures, Object object) { StringBuilder resultBody = new StringBuilder(); Map connectTraps = (Map) triggerSignatures.get(index); try{ @@ -381,7 +381,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{ //connect traps data set to JSON Body as String @SuppressWarnings({ "unchecked", "rawtypes" }) - private String getUIConnectTraps(ArrayList connectTrapSignatures) { + private String getUIConnectTraps(List connectTrapSignatures) { StringBuilder resultBody = new StringBuilder(); String connectMainBody = ""; for(int j = 0; j < connectTrapSignatures.size(); j++){ @@ -617,8 +617,8 @@ class ClosedLoopGridJSONData{ private String clearTimeOut; private String trapMaxAge; private String verificationclearTimeOut; - private ArrayList connecttriggerSignatures; - private ArrayList connectVerificationSignatures; + private List connecttriggerSignatures; + private List connectVerificationSignatures; public String getClearTimeOut() { return clearTimeOut; @@ -640,16 +640,16 @@ class ClosedLoopGridJSONData{ } - public ArrayList getConnecttriggerSignatures() { + public List getConnecttriggerSignatures() { return connecttriggerSignatures; } - public void setConnecttriggerSignatures(ArrayList connecttriggerSignatures) { + public void setConnecttriggerSignatures(List connecttriggerSignatures) { this.connecttriggerSignatures = connecttriggerSignatures; } - public ArrayList getConnectVerificationSignatures() { + public List getConnectVerificationSignatures() { return connectVerificationSignatures; } - public void setConnectVerificationSignatures(ArrayList connectVerificationSignatures) { + public void setConnectVerificationSignatures(List connectVerificationSignatures) { this.connectVerificationSignatures = connectVerificationSignatures; } } \ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java index 2750ff505..7001aa9a8 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java @@ -113,7 +113,9 @@ public class CreateFirewallController extends RestrictedBaseController { CreateFirewallController.commonClassDao = commonClassDao; } - public CreateFirewallController(){} + public CreateFirewallController(){ + // Empty constructor + } private List termCollectorList; -- cgit 1.2.3-korg