diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-07 13:58:09 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-07 17:15:07 -0400 |
commit | 9b3ff5f270572a6760ff07dda9577cdadb53b088 (patch) | |
tree | eacd325199fbb72fddaba94a057178a19e9c3360 /models-pdp/src/main/java/org/onap | |
parent | 3000fdca611c32b7001c553621660b8ea0d2eb49 (diff) |
Address sonar issues in models
Addressed the following sonar issues:
- use RE2 instead of java.util Pattern for "+" and "*"
- don't use deprecated methods
- for Date(long), sonar appeared not to parse the argument's
type correctly. Modified the code slightly to make sonar happy
- duplicate blocks of code
- either log or throw
- missing assert in junit
- for SDNR & VFC, eliminated threads, as they are unnecessary
- duplicate code block in different branches
- useless assignments
- redeclaring abstract methods
- cyclomatic complexity
- used lombok in some cases (e.g., EqualsAndHashCode)
- assert argument order
- actually deleted ControlLoopTargetType, because it is not needed
and sonar complains regardless of which order is used
- add private constructor to utility classes
- use StandardCharsets instead of literals
Also:
- added logback-test.xml to SO to eliminate the voluminous output
from the junit test
Issue-ID: POLICY-2305
Change-Id: I586c331781bedbd54a115a71847d04d293689445
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/main/java/org/onap')
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java | 19 | ||||
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java | 12 |
2 files changed, 15 insertions, 16 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index 7faf19748..8f647a4ee 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. 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. @@ -119,10 +119,11 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { } for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { - if (matchPolicyTypesExactly && areListsIdentical(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { - return true; - } else if (!matchPolicyTypesExactly - && findSupportedPolicyType(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + if (matchPolicyTypesExactly) { + if (areListsIdentical(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + return true; + } + } else if (findSupportedPolicyType(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { return true; } } @@ -172,9 +173,11 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { } for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { - if (matchPoliciesExactly && areListsIdentical(pdpSubGroup.getPolicies(), policyFilter)) { - return true; - } else if (!matchPoliciesExactly && findSingleElement(pdpSubGroup.getPolicies(), policyFilter)) { + if (matchPoliciesExactly) { + if (areListsIdentical(pdpSubGroup.getPolicies(), policyFilter)) { + return true; + } + } else if (findSingleElement(pdpSubGroup.getPolicies(), policyFilter)) { return true; } } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java index 0df620bcf..67458cf5f 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Model * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -239,7 +239,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> { } if (properties != null) { - result = validateProperties(result); + validateProperties(result); } if (pdpSubGroups == null) { @@ -257,11 +257,9 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> { /** * Validate the properties. * - * @param resultIn the incoming validation results so far - * @return the revalidation results including the property validation results + * @param result where to place any new validation results */ - private PfValidationResult validateProperties(PfValidationResult resultIn) { - PfValidationResult result = resultIn; + private void validateProperties(PfValidationResult result) { for (Entry<String, String> propertyEntry : properties.entrySet()) { if (!ParameterValidationUtils.validateStringParameter(propertyEntry.getKey())) { @@ -273,8 +271,6 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> { "a property value may not be null or blank")); } } - - return result; } @Override |