fix PCE SpotBugs issues 18/89518/3
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 29 Apr 2020 14:49:38 +0000 (16:49 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 30 Apr 2020 08:32:57 +0000 (08:32 +0000)
- add a SuppressFBwarning decorator on classes with false positives
- remove uncalled private methods
- enforce SpotBugs at build time in PCE pom.xml

JIRA: TRNSPRTPCE-244
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I1c2f7e8ec1b8cd9994641d31a004733e5d77c272

pce/pom.xml
pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java
pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java
pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java

index 67ec610bfebb6649bb098d3fbdefcf32eae698a1..c39133d3090d2a77e6b5530bd7e5b5a6726bcfbe 100644 (file)
@@ -104,10 +104,4 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
     </plugins>
   </build>
 
-<!-- checkstyle and spotbugds enforced by odlparent since Magnesium -->
-  <properties>
-    <!-- odlparent.checkstyle.enforce>false</odlparent.checkstyle.enforce -->
-    <odlparent.spotbugs.enforce>false</odlparent.spotbugs.enforce>
-  </properties>
-
 </project>
index bd4052d79fb50d8feffd5d5e12b9a4fba4f29811..245be1b6a32b7eea45a949d4f8881edd51810fe9 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.transportpce.pce.graph;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -36,6 +37,9 @@ public class PostAlgoPathValidator {
     public static final Long CONST_OSNR = 1L;
     public static final double SYS_MARGIN = 0;
 
+    @SuppressFBWarnings(
+        value = "SF_SWITCH_FALLTHROUGH",
+        justification = "intentional fallthrough")
     public PceResult checkPath(GraphPath<String, PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes,
         PceResult pceResult, PceConstraints pceHardConstraints, String serviceType) {
 
@@ -344,61 +348,6 @@ public class PostAlgoPathValidator {
         return tribSlotMap;
     }
 
-    private List<List<Uint16>> chooseTribSlot3(GraphPath<String, PceGraphEdge> path,
-        Map<NodeId, PceNode> allPceNodes) {
-        List<List<Uint16>> tribSlot = new ArrayList<>();
-        boolean statusOK = true;
-        boolean check = false;
-        Object nodeClass = allPceNodes.getClass();
-        if (nodeClass.getClass().isInstance(PceNode.class)) {
-            LOG.debug("In choosetribSlot: AllPceNodes contains PceNode instance, no trib port search");
-            return tribSlot;
-        } else if (nodeClass.getClass().isInstance(PceNode.class)) {
-            LOG.debug("In choosetribPort: {} {}", path.getLength(), path);
-        }
-        for (PceGraphEdge edge : path.getEdgeList()) {
-            LOG.debug("In chooseTribSlot: source {} ", edge.link().getSourceId());
-            PceNode pceNode = allPceNodes.get(edge.link().getSourceId());
-            Object tps = allPceNodes.get(edge.link().getSourceTP());
-            Object tpd = allPceNodes.get(edge.link().getDestTP());
-            if ((pceNode.getAvailableTribSlots().containsKey(tps.toString()))
-                && (pceNode.getAvailableTribSlots().containsKey(tpd.toString()))) {
-                List<Uint16> tribSlotEdgeSourceN = pceNode.getAvailableTribSlots().get(tps.toString());
-                List<Uint16> tribSlotEdgeDestN = pceNode.getAvailableTribSlots().get(tps.toString());
-                check = false;
-                for (int i = 0; i <= 79; i++) {
-                    if (tribSlotEdgeSourceN.get(i) == null) {
-                        break;
-                    }
-                    // TODO This will need to be modified as soon as the trib-slots allocation per
-                    // trib-port
-                    // policy applied by the different manufacturer is known
-                    if (tribSlotEdgeSourceN.get(i).equals(tribSlotEdgeDestN.get(i))) {
-                        check = true;
-                    } else {
-                        check = false;
-                        LOG.debug("In chooseTribSlot: Misalignement of trib slots between source {} and dest {}",
-                            edge.link().getSourceId(), edge.link().getDestId());
-                        break;
-                    }
-                }
-                if (check) {
-                    tribSlot.add(tribSlotEdgeSourceN);
-                }
-            } else {
-                LOG.debug("In chooseTribSlot: source {} does not have provisonned hosting HO interface ",
-                    edge.link().getSourceId());
-                statusOK = false;
-            }
-        }
-        if (statusOK && check) {
-            return tribSlot;
-        } else {
-            tribSlot.clear();
-            return tribSlot;
-        }
-    }
-
     // Check the path OSNR
     private boolean checkOSNR(GraphPath<String, PceGraphEdge> path) {
         double linkOsnrDb;
index 47f3b700845008a6857a54177a4b12deef754f04..bda495cfa1727d9b69c7e3735422e73e23d76104 100644 (file)
@@ -271,67 +271,6 @@ public class PceOtnNode implements PceNode {
         return false;
     }
 
-    private Boolean findClientCompliantInterface(List<SupportedInterfaceCapability> sic) {
-        boolean compliant = false;
-        for (SupportedInterfaceCapability sit : sic) {
-            String interfacetype = sit.getIfCapType().getName();
-            switch (interfacetype) {
-                case "If1GEODU0":
-                case "If1GE":
-                    if ("1GE".equals(this.otnServiceType)) {
-                        compliant = true;
-                    }
-                    break;
-                case "If10GEODU2e":
-                case "If10GE":
-                    if ("10GE".equals(this.otnServiceType)) {
-                        compliant = true;
-                    }
-                    break;
-                case "If100GEODU4":
-                case "If100GE":
-                    if ("100GE".equals(this.otnServiceType)) {
-                        compliant = true;
-                    }
-                    break;
-                case "IfOTU4ODU4":
-                case "IfOCHOTU4ODU4":
-                    if ("OTU4".equals(this.otnServiceType) || "ODU4".equals(this.otnServiceType)) {
-                        compliant = true;
-                    }
-                    break;
-                default:
-                    compliant = false;
-                    break;
-            }
-        }
-        return compliant;
-    }
-
-    private Boolean findNetworkCompliantInterface(List<SupportedInterfaceCapability> sic) {
-        boolean compliant = false;
-        for (SupportedInterfaceCapability sit : sic) {
-            String interfacetype = sit.getIfCapType().toString();
-            switch (interfacetype) {
-                case "IfOTU4ODU4":
-                case "IfOCHOTU4ODU4":
-                    compliant = true;
-                    break;
-                case "IfOTU2ODU2":
-                case "IfOCHOTU2ODU2":
-                    if (("1GE".equals(this.otnServiceType)) || ("10GE".equals(this.otnServiceType))) {
-                        compliant = true;
-                    }
-                    break;
-                // add all use case with higher rate interfaces when it shows up
-                default:
-                    compliant = false;
-                    break;
-            }
-        }
-        return compliant;
-    }
-
     public void validateXponder(String anodeId, String znodeId) {
         if (!isValid()) {
             return;
index 9d860f8a3a8b804acdce8d28a124e84643f6e12a..85ccde2b1034f8d63a5dd3b0135683a4b35cbdb3 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.transportpce.pce.service;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
@@ -74,6 +75,9 @@ public class PathComputationServiceImpl implements PathComputationService {
         LOG.info("close.");
     }
 
+    @SuppressFBWarnings(
+        value = "UPM_UNCALLED_PRIVATE_METHOD",
+        justification = "false positive, this method is used by public method cancelResourceReserve")
     private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName,
             RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) {
         ServicePathRpcResultBuilder servicePathRpcResultBuilder =