aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm.miernik <m.miernik@samsung.com>2021-06-22 11:37:46 +0200
committerKAPIL SINGAL <ks220y@att.com>2021-06-23 15:48:40 +0000
commitcb7e5aa3c0445882a2bc04222573c1563b98117b (patch)
tree54a754eb9a85890bddf3d05ae6787a6a6bd8e885
parenta285920200ba5cdff0d2df4f794518a0db395922 (diff)
Fix sonar issues
Replaced methods size() to isEmpty() based on Sonar recommendations Issue-ID: SDNC-1568 Change-Id: I9b2548ba1d42e009a62ddd34f4f43452622c6ff0 Signed-off-by: m.miernik <m.miernik@samsung.com>
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java2
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java6
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java2
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java8
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java2
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java2
9 files changed, 14 insertions, 14 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
index f513e011c..6715be1dc 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
@@ -79,7 +79,7 @@ class SectionValue {
public void removeComment(String comment) {
this.comments.remove(comment);
- this.isUncommented = this.comments.size()==0;
+ this.isUncommented = this.comments.isEmpty();
}
public List<String> getComments() {
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
index 359b9d04b..83c08b270 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
@@ -40,7 +40,7 @@ public class BoolQueryBuilder extends QueryBuilder {
}
public static boolean isEmpty(JSONObject o) {
- return o.keySet().size() <= 0;
+ return o.keySet().isEmpty();
}
public BoolQueryBuilder must(QueryBuilder query) {
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
index 948bd7317..b23d882c8 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
@@ -361,7 +361,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
}
- if (failures.size() > 0) {
+ if (!failures.isEmpty()) {
throw new DataInconsistencyException(new ArrayList<>(repairList.values()),
"inventory list is not consistent;\n" + String.join("\n", failures));
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
index 9fd6975b6..ac9cb44fe 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
@@ -48,7 +48,7 @@ public class MarkdownTable {
public String toMarkDown() {
StringBuilder sb = new StringBuilder();
final int cols =
- this.columns != null ? this.columns.length : this.rows.size() > 0 ? this.rows.get(0).length : 0;
+ this.columns != null ? this.columns.length : !this.rows.isEmpty() ? this.rows.get(0).length : 0;
if (cols > 0) {
sb.append("|");
for (int i = 0; i < cols; i++) {
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
index e69ddb737..b44906289 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
@@ -134,7 +134,7 @@ public class DataTreeProviderImpl {
public DataTreeObject readInventoryTree(List<String> tree, String filter) throws IOException {
//root nodes will be node-information -> below inventory
- if (tree == null || tree.size() <= 0) {
+ if (tree == null || tree.isEmpty()) {
return this.readInventoryTreeWithNode(filter);
}
//root node will be inventory on tree-level if sliced treePath
@@ -155,7 +155,7 @@ public class DataTreeProviderImpl {
throws IOException {
DataTreeObject tree = new DataTreeObject(INVENTORY_PROPERTY_PARENTUUID, INVENTORY_PROPERTY_UUID);
final String parentUuid = list.size() > 1 ? list.get(list.size() - 2) : null;
- final String uuid = list.size() > 0 ? list.get(list.size() - 1) : null;
+ final String uuid = list.isEmpty() ? null : list.get(list.size() - 1);
List<SearchHit> matches = this.search(Entity.Inventoryequipment, filter, INVENTORY_PROPERTY_NODEID, nodeId,
INVENTORY_PROPERTY_PARENTUUID, parentUuid, INVENTORY_PROPERTY_UUID, uuid, INVENTORY_PROPERTY_TREELEVEL);
@@ -163,7 +163,7 @@ public class DataTreeProviderImpl {
List<SearchHit> others = this.search(Entity.Inventoryequipment, (String) null, INVENTORY_PROPERTY_NODEID, nodeId,
null, null, null, null, INVENTORY_PROPERTY_TREELEVEL);
if (matches.size() > 0) {
- int treeLevelToStart = (list == null || list.size() <= 0) ? 0 : list.size() - 1;
+ int treeLevelToStart = (list == null || list.isEmpty()) ? 0 : list.size() - 1;
//build tree
JSONObject hitData;
//fill root elems
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
index 50b0215d6..fe166c92d 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
@@ -99,7 +99,7 @@ public class ResyncNetworkElementHouskeepingService implements ResyncNetworkElem
List<String> nodeNamesInput;
// Create list of mountpoints if input is empty, using the content in ES
- if (nodeNames == null || nodeNames.size() <= 0) {
+ if (nodeNames == null || nodeNames.isEmpty()) {
nodeNamesInput = this.databaseClientEvents.getAllNodesWithCurrentAlarms();
} else {
nodeNamesInput = nodeNames;
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
index ebf11b6af..35dbeec9f 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
@@ -72,7 +72,7 @@ public class HelpInfrastructureObject extends JSONObject {
public static class NodeObject extends JSONObject {
public NodeObject(Path base, File dir, String label, ArrayList<VersionObject> versions) {
this.put("label", label);
- if (versions != null && versions.size() > 0) {
+ if (versions != null && !versions.isEmpty()) {
JSONObject o = new JSONObject();
this.put("versions", o);
for (VersionObject version : versions) {
@@ -87,7 +87,7 @@ public class HelpInfrastructureObject extends JSONObject {
for (File f : list) {
if (f.isDirectory()) {
ArrayList<VersionObject> versions2 = findReadmeVersionFolders(base, f.toPath(), true);
- if (versions2 != null && versions2.size() > 0) {
+ if (versions2 != null && !versions2.isEmpty()) {
JSONObject nodes;
if (!this.has("nodes")) {
this.put("nodes", new JSONObject());
@@ -112,7 +112,7 @@ public class HelpInfrastructureObject extends JSONObject {
for (File f : list) {
if (f.isDirectory()) {
ArrayList<VersionObject> versions = findReadmeVersionFolders(root.toPath(), f.toPath(), true);
- if (versions != null && versions.size() > 0) {
+ if (versions != null && !versions.isEmpty()) {
NodeObject o = new NodeObject(pRoot, f, f.getName(), versions);
this.put(o.getString("label").toLowerCase(), o);
}
@@ -134,7 +134,7 @@ public class HelpInfrastructureObject extends JSONObject {
}
Collections.sort(list, VersionObject.getComparer());
Collections.reverse(list);
- if (list.size() > 0 && appendCurrent) {
+ if (!list.isEmpty() && appendCurrent) {
list.add(list.get(0).cloneAsCurrent());
}
return list;
diff --git a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
index 636c9db29..bbe36c840 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/com/opensymphony/xwork2/util/ClassLoaderUtil.java
@@ -203,7 +203,7 @@ public class ClassLoaderUtil {
private Enumeration<E> determineCurrentEnumeration() {
if (cur != null && !cur.hasMoreElements()) {
- if (enums.size() > 0) {
+ if (!enums.isEmpty()) {
cur = enums.removeLast();
} else {
cur = null;
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
index 4d3975379..b920ffe71 100644
--- a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
@@ -79,7 +79,7 @@ public class SchemaInfo {
@JsonIgnore
public boolean isValid() {
return this.namespace != null
- && (this.notification == null || (this.notification != null && this.notification.size() > 0));
+ && (this.notification == null || (this.notification != null && !this.notification.isEmpty()));
}
/**