diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-07 09:18:12 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-07 11:59:10 -0400 |
commit | 19663843f4fc612f73df8ba970800f2f1a5166a2 (patch) | |
tree | 47176d60279a21cd975831b433227917d43de39b /policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java | |
parent | ece155048af47ea83ff898c999aa5137dc99a988 (diff) |
Address sonar issues in policy-management
Addressed the following sonar issues:
- modified code to specify the correct class name in the
getLogger() call
- use equals() instead of "==" for string comparison
- remove deprecated code
- use ',' instead of "," in indexOf
- remove code that is commented out; typically bogus, so the comment
was adjusted to satisfy sonar
- missing assert in junits
- use "{}" instead of concatenation when using logger
- either log or rethrow
- put arguments for assertEquals() in the correct order
- remove "return" statements from the end of void methods
- don't always return the same value; just disabled sonar as
refactoring would have obfuscated the code
- cognitive complexity; used eclipse auto-refactoring to extract
out chunks of code into separate methods
- don't pass array of classes to class.getDeclaredMethod(); use
ellided arguments instead
- fix argument count in logger calls
- remove unnecessary casts
- don't use "volatile"
- make methods "synchronized" to match parent class definitions
Issue-ID: POLICY-2305
Change-Id: Ie96418f696da4ae6c2ca8d4a914371469e695419
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java')
-rw-r--r-- | policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java index 9b832b04..4e4fddf9 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -195,9 +195,8 @@ public class MavenDroolsController implements DroolsController { if (newGroupId.equalsIgnoreCase(this.getGroupId()) && newArtifactId.equalsIgnoreCase(this.getArtifactId()) - && newVersion.equalsIgnoreCase(this.getVersion())) { - logger.warn("All in the right version: " + newGroupId + ":" - + newArtifactId + ":" + newVersion + " vs. " + this); + && newVersion.equalsIgnoreCase(this.getVersion())) { + logger.warn("All in the right version: {}:{}:{} vs. {}", newGroupId, newArtifactId, newVersion, this); return; } @@ -516,8 +515,13 @@ public class MavenDroolsController implements DroolsController { } + /* + * This method always returns "true", which causes a sonar complaint. However, + * refactoring or restructuring it would unnecessarily complicate it, thus we'll just + * disable the sonar complaint. + */ @Override - public <T> boolean offer(T event) { + public <T> boolean offer(T event) { // NOSONAR logger.debug("{}: OFFER event", this); if (this.locked || !this.alive || this.policyContainer.getPolicySessions().isEmpty()) { @@ -541,7 +545,7 @@ public class MavenDroolsController implements DroolsController { boolean successInject = this.policyContainer.insertAll(event); if (!successInject) { - logger.warn(this + "Failed to inject into PolicyContainer {}", this.getSessionNames()); + logger.warn("{} Failed to inject into PolicyContainer {}", this, this.getSessionNames()); } FeatureApiUtils.apply(getDroolsProviders().getList(), @@ -687,7 +691,7 @@ public class MavenDroolsController implements DroolsController { } } } catch (Exception e) { - logger.warn("Can't retrieve CORE sessions: " + e.getMessage(), e); + logger.warn("Can't retrieve CORE sessions", e); sessionNames.add(e.getMessage()); } return sessionNames; |