fix sonar clumsy issues 56/83456/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Tue, 18 Jun 2019 09:44:47 +0000 (11:44 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Tue, 6 Aug 2019 14:32:50 +0000 (16:32 +0200)
JIRA: TRNSPRTPCE-133

Change-Id: Iec0da57ea10bf0553205ca1ffc786b76c17c01f1
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/InfoSubtree.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology121.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopology22.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceConstraintsCalc.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceGraph.java
pce/src/main/java/org/opendaylight/transportpce/pce/PceNode.java
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraints.java

index bbbc57898b21be7240aa419e0623e763a5f48728..b870224c5081d401942ebfa9bb9693cf739feb01 100644 (file)
@@ -47,9 +47,9 @@ public class InfoSubtree {
     public boolean getDeviceInfo(String nodeId, DeviceTransactionManager deviceTransactionManager) {
         switch (this.openRoadmVersion) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return getDeviceInfo1_2_1(nodeId, deviceTransactionManager);
+                return getDeviceInfo121(nodeId, deviceTransactionManager);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return getDeviceInfo2_2_1(nodeId, deviceTransactionManager);
+                return getDeviceInfo221(nodeId, deviceTransactionManager);
             default:
                 LOG.info("Device version {} not supported",this.openRoadmVersion);
                 return false;
@@ -57,7 +57,7 @@ public class InfoSubtree {
 
     }
 
-    private boolean getDeviceInfo1_2_1(String nodeId, DeviceTransactionManager deviceTransactionManager) {
+    private boolean getDeviceInfo121(String nodeId, DeviceTransactionManager deviceTransactionManager) {
 
         //Read clli from the device
         InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
@@ -85,7 +85,7 @@ public class InfoSubtree {
 
     }
 
-    private boolean getDeviceInfo2_2_1(String nodeId, DeviceTransactionManager deviceTransactionManager) {
+    private boolean getDeviceInfo221(String nodeId, DeviceTransactionManager deviceTransactionManager) {
 
         //TODO : change back to operational when testing on real device
         //Read clli from the device
index 07de58816dd4145293a917fcff4107e73fc9ff30..3ce7215ec7a48a9d6fad73e8310a30ce43cff138 100644 (file)
@@ -267,10 +267,8 @@ public class OpenRoadmTopology121 {
             for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
                 if (cp.getPorts() != null) {
                     for (Ports port : cp.getPorts()) {
-                        if (port.getPortQual() != null) {
-                            if (port.getPortQual().getIntValue() == 4) {
-                                client++;
-                            }
+                        if ((port.getPortQual() != null) && (port.getPortQual().getIntValue() == 4)) {
+                            client++;
                         }
                     }
                 }
index 9d7518c8df1a13ee89f47c8e77b2ad0827d430da..f6f214403015a9cb742076f3e75fe6c79bab21c8 100644 (file)
@@ -269,10 +269,8 @@ public class OpenRoadmTopology22 {
             for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
                 if (cp.getPorts() != null) {
                     for (Ports port : cp.getPorts()) {
-                        if (port.getPortQual() != null) {
-                            if (port.getPortQual().getIntValue() == 4) {
-                                client++;
-                            }
+                        if ((port.getPortQual() != null) && (port.getPortQual().getIntValue() == 4)) {
+                            client++;
                         }
                     }
                 }
index 97beb039fe04bca57663aff48eaf90f1037b4046..700f91f06c06eda54b4c6ab965ae955ae114aacc 100644 (file)
@@ -145,11 +145,9 @@ public class PceConstraintsCalc {
         }
 
         Diversity diversity = tmpGeneral.getDiversity();
-        if (diversity != null) {
-            if (diversity.getExistingServiceApplicability().isNode()) {
-                LOG.info("in readGeneralContrains {}", diversity.toString());
-                readDiversityNodes(diversity.getExistingService(), constraints);
-            }
+        if ((diversity != null) && (diversity.getExistingServiceApplicability().isNode())) {
+            LOG.info("in readGeneralContrains {}", diversity.toString());
+            readDiversityNodes(diversity.getExistingService(), constraints);
         }
 
     }
index 89013ca2643dc46d4dcd00cbeccb7b29241862b1..08886ca87e2532c1216e69b554e9e6fbb8277273 100644 (file)
@@ -371,14 +371,12 @@ public class PceGraph {
 
         Long latencyConstraint = this.pceHardConstraints.getMaxLatency();
 
-        if (latencyConstraint > 0) {
-            if (this.tmpAtozLatency > latencyConstraint) {
-                this.foundButTooHighLatency = true;
-                this.pceResult.setLocalCause(LocalCause.TOO_HIGH_LATENCY);
-                LOG.info("In validateLatency: AtoZ path has too high LATENCY {} > {}", this.tmpAtozLatency,
-                        latencyConstraint);
-                return false;
-            }
+        if ((latencyConstraint > 0) && (this.tmpAtozLatency > latencyConstraint)) {
+            this.foundButTooHighLatency = true;
+            this.pceResult.setLocalCause(LocalCause.TOO_HIGH_LATENCY);
+            LOG.info("In validateLatency: AtoZ path has too high LATENCY {} > {}", this.tmpAtozLatency,
+                latencyConstraint);
+            return false;
         }
         LOG.info("In validateLatency: AtoZ path  is {}", this.pathAtoZ.toString());
         return true;
index 91a1f8ceff61d5a2434946bd0524d96b78c7dcd8..57797640ea7e1bfe5bf26e0dc69a61afa79acf3c 100644 (file)
@@ -257,17 +257,11 @@ public class PceNode {
     }
 
     public boolean checkTP(String tp) {
-        if (this.usedXpndrNWTps.contains(tp)) {
-            return false;
-        }
-        return true;
+        return !(this.usedXpndrNWTps.contains(tp));
     }
 
     public boolean checkWL(long index) {
-        if (this.availableWLindex.contains(index)) {
-            return true;
-        }
-        return false;
+        return (this.availableWLindex.contains(index));
     }
 
     public boolean isValid() {
@@ -294,4 +288,4 @@ public class PceNode {
     public String toString() {
         return "PceNode type=" + this.nodeType + " ID=" + this.nodeId.getValue();
     }
-}
\ No newline at end of file
+}
index b6da829b55e9676968cd0e8e2110fdfaf848f596..4ed561f1aff9051564a971bbc22341f910d83887 100644 (file)
@@ -141,7 +141,7 @@ public class PathComputationServiceImpl implements PathComputationService {
                 PathDescriptionBuilder path = null;
                 path = sendingPCE.getPathDescription();
                 LOG.info("PCE response: {} {}", message, responseCode);
-                if ((sendingPCE.getSuccess() == false) || (path == null)) {
+                if (!(sendingPCE.getSuccess()) || (path == null)) {
                     configurationResponseCommon.setAckFinalIndicator("Yes")
                             .setRequestId(input.getServiceHandlerHeader().getRequestId()).setResponseCode(responseCode)
                             .setResponseMessage(message);
index 639b662479ee8ce7bd5c758ea980755cc5c34227..d56f116f06d15e65f9ced6db35e011466f38306e 100644 (file)
@@ -106,7 +106,7 @@ public final class DowngradeConstraints {
         return result.build();
     }
 
-    private static Exclude updateExclude(Exclude hard, Exclude soft) throws NullPointerException {
+    private static Exclude updateExclude(Exclude hard, Exclude soft) {
         ExcludeBuilder result = new ExcludeBuilder(soft);
         if (hard != null) {
             result.getFiberBundle().addAll(hard.getFiberBundle());
@@ -117,7 +117,7 @@ public final class DowngradeConstraints {
         return result.build();
     }
 
-    private static Diversity updateDiveristy(Diversity hard, Diversity soft) throws NullPointerException {
+    private static Diversity updateDiveristy(Diversity hard, Diversity soft) {
         DiversityBuilder result = new DiversityBuilder(soft);
         if (hard != null) {
             result.getExistingService().addAll(hard.getExistingService());
@@ -141,7 +141,7 @@ public final class DowngradeConstraints {
         .or.general.co.routing.CoRouting updateCoCoRouting(org.opendaylight.yang.gen.v1.http.org.openroadm.routing
                 .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRouting hard, org.opendaylight
                     .yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.co
-                        .routing.CoRouting soft) throws NullPointerException {
+                        .routing.CoRouting soft) {
         org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general
             .co.routing.CoRoutingBuilder result = new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
                 .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRoutingBuilder(soft);