Cleanup sonar-reported code smells 91/83191/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 19 Jul 2019 15:19:57 +0000 (17:19 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 26 Jul 2019 10:52:46 +0000 (10:52 +0000)
This is a simple pass over reported issues, making trivial fixes.

Change-Id: If2094f3e9b02ccfea407dd3eddc641937b186170
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f3064526ab982735bbd490da15246a2a4ce35de9)

bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.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 299ec26ce9b25dfb64054819e8459766b8eab033..2d1a5fa60615d92a60de83c240f153c901a85c2c 100644 (file)
@@ -573,7 +573,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(@Nonnull final ByteBuf nlri) throws BGPParsingException {
+    protected final List<Flowspec> parseNlriFlowspecList(@Nonnull final ByteBuf nlri) {
         if (!nlri.isReadable()) {
             return null;
         }
index 410ff3170e488fcdb90e40179723f96464834f53..a61227196a6c8b3b4c3920604b1a4ae159301173 100644 (file)
@@ -44,39 +44,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 1c6a8d454e5e65970e5cb7a0b2626a2ec3f6b1ab..1d0bc44ac33f000ac637c052adb3eadc049e4078 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 92e4c89b04b5ce99117acfe8867806be827d3e0f..c67624ddff887a161ed1a065fbb35999deaed3c9 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 796cef1bc1f6510b7e5c89905468f76eb1f0b645..7b1cb5e43b5011cc29328be274f909c047d1e713 100644 (file)
@@ -154,10 +154,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 ced799abc3dae9cd58ea1079dae5eb9a865adc83..6c43e401d327060517efb960e0c1f3156783da13 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 672e431bf9fdb1d587279e88943441cc56aa6a3a..68a7181a37c5a98a8d4838183f06493e6248be60 100644 (file)
@@ -150,7 +150,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);
         }
     }
 }