Cleanup sonar-reported code smells 82/83182/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 19 Jul 2019 15:19:57 +0000 (17:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 19 Jul 2019 16:00:35 +0000 (18:00 +0200)
This is a simple pass over reported issues, making trivial fixes.

Change-Id: If2094f3e9b02ccfea407dd3eddc641937b186170
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/BgpAttributeConditionsUtil.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseBestPath.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCSyncOptimization.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrorIdentifier.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/config/PCEPTopologyProviderUtil.java
pcep/topology/topology-stats/src/main/java/org/opendaylight/bgpcep/pcep/topology/stats/provider/TopologyStatsProviderImpl.java

index 79cb599ae3bcd3913b3515ed6e0e3e0717c7d803..8dc6206814b75c81f7b098fd5306c6aa981b7e39 100644 (file)
@@ -561,7 +561,7 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param nlri byte representation of NLRI which will be parsed
      * @return list of Flowspec
      */
-    protected final List<Flowspec> parseNlriFlowspecList(final @NonNull ByteBuf nlri) throws BGPParsingException {
+    protected final List<Flowspec> parseNlriFlowspecList(final @NonNull ByteBuf nlri) {
         if (!nlri.isReadable()) {
             return null;
         }
index 1c1d279e95ecce7916557018305b1e336cb5c039..116ef3709c148b74ff684800250ef110b18d4bd5 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSeriali
 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
@@ -35,8 +34,6 @@ public final class FlowspecL3vpnIpv6RIBSupport
         FlowspecL3vpnRouteKey> {
     private static final FlowspecL3vpnIpv6Routes EMPTY_CONTAINER
             = new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
-    private static final FlowspecL3vpnIpv6RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv6RoutesCaseBuilder()
-            .setFlowspecL3vpnIpv6Routes(EMPTY_CONTAINER).build();
     private static FlowspecL3vpnIpv6RIBSupport SINGLETON;
 
     private FlowspecL3vpnIpv6RIBSupport(
index 42ba6b934e0199ce0f05636e0936ef18d9be3cc4..2d374e4ace1e62eeefbc2d4e8e27e79c6d7f06fb 100644 (file)
@@ -45,39 +45,18 @@ final class BgpAttributeConditionsUtil {
             final Class<? extends AfiSafiType> afiSafi,
             final Attributes attributes,
             final BgpConditions conditions) {
-        if (!matchAfiSafi(afiSafi, conditions.getAfiSafiIn())) {
-            return false;
-        }
-
-        if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
-            return false;
-        }
-
-        if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
-            return false;
-        }
-
-        if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
-            return false;
-        }
-
-        if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
-            return false;
-        }
-
-        if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
-            return false;
-        }
-        return true;
+        return matchAfiSafi(afiSafi, conditions.getAfiSafiIn())
+            && matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())
+            && matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())
+            && matchOrigin(attributes.getOrigin(), conditions.getOriginEq())
+            && matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())
+            && matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq());
     }
 
     private static boolean matchAfiSafi(
             final Class<? extends AfiSafiType> afiSafi,
             final List<Class<? extends AfiSafiType>> afiSafiIn) {
-        if (afiSafiIn == null) {
-            return true;
-        }
-        return afiSafiIn.contains(afiSafi);
+        return afiSafiIn == null ? true : afiSafiIn.contains(afiSafi);
     }
 
     private static boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
index 0306dcf5d2e1eb3ce12c99eee3de41e239c85e81..9837d1c070dd3de17f465cb3e3bc2de8a82280f3 100644 (file)
@@ -57,12 +57,6 @@ final class BaseBestPath extends AbstractBestPath {
             return false;
         }
         final BaseBestPath other = (BaseBestPath) obj;
-        if (!this.routerId.equals(other.routerId)) {
-            return false;
-        }
-        if (!this.state.equals(other.state)) {
-            return false;
-        }
-        return true;
+        return this.routerId.equals(other.routerId) && this.state.equals(other.state);
     }
 }
index af69c48e5826c53f5e8605c41eea9f1232fa987f..c2cfc3f4e4d5c7114c13d1ea6f73e7345cf9941f 100644 (file)
@@ -403,7 +403,7 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
     }
 
     @Override
-    public synchronized final void channelInactive(final ChannelHandlerContext ctx) {
+    public final synchronized void channelInactive(final ChannelHandlerContext ctx) {
         LOG.debug("Channel {} inactive.", ctx.channel());
         endOfInput();
 
@@ -415,18 +415,18 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
     }
 
     @Override
-    protected synchronized final void channelRead0(final ChannelHandlerContext ctx, final Message msg) {
+    protected final synchronized void channelRead0(final ChannelHandlerContext ctx, final Message msg) {
         LOG.debug("Message was received: {}", msg);
         handleMessage(msg);
     }
 
     @Override
-    public synchronized final void handlerAdded(final ChannelHandlerContext ctx) {
+    public final synchronized void handlerAdded(final ChannelHandlerContext ctx) {
         this.sessionUp();
     }
 
     @Override
-    public  synchronized void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
+    public synchronized void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
         handleException(cause);
     }
 
index a3f2d835ebe54a13bb93e562ee1efcfdcccec641..eeb6f0b1089826cfb448bb9d9a9c45985888f64f 100644 (file)
@@ -153,10 +153,7 @@ final class PCCSyncOptimization {
     }
 
     public boolean isSyncNeedIt() {
-        if (doesLspDbMatch() && !this.resynchronizing) {
-            return false;
-        }
-        return true;
+        return !doesLspDbMatch() || this.resynchronizing;
     }
 
     public void setResynchronizingState(final Boolean resync) {
index e17a12fa3f5b8adb3bb6decc58dab41708258d04..0871128d239f94c57322cd4b9f1b04fc4d962cb1 100644 (file)
@@ -48,10 +48,7 @@ final class PCEPErrorIdentifier implements Serializable {
             return false;
         }
         final PCEPErrorIdentifier other = (PCEPErrorIdentifier) obj;
-        if (this.type != other.type || this.value != other.value) {
-            return false;
-        }
-        return true;
+        return this.type == other.type && this.value == other.value;
     }
 
     @Override
index 5a1999b1cb339478940f0b30b3849ce5c875faf0..a7207c7a45806a5dc402e7fb036e572e3db9e528 100644 (file)
@@ -25,13 +25,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev181109.PcepNodeSyncConfig;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 final class PCEPTopologyProviderUtil {
 
-    private static final Logger LOG = LoggerFactory.getLogger(PCEPTopologyProviderUtil.class);
-
     private PCEPTopologyProviderUtil() {
         throw new UnsupportedOperationException();
     }
index ae6f3725d1d79afed2b7fa011cff5ad1e270ca21..d3ff3eef50c8d5738b765bb256bf1b144e6c7bb5 100644 (file)
@@ -149,7 +149,7 @@ public final class TopologyStatsProviderImpl implements TransactionChainListener
         try {
             wTx.commit().get();
         } catch (final InterruptedException | ExecutionException e) {
-            LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId());
+            LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId(), e);
         }
     }
 }