Sonar related fixes

- suppress SONAR warning for printing stack trace in CLI
- add string constants for the Sonar suppression identifiers

Change-Id: I03992f89675f9d074347042b7a196dbcc1036c28
diff --git a/utils/misc/src/main/java/org/onlab/packet/IGMP.java b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
index cabd252..938cd6e 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IGMP.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
@@ -15,21 +15,21 @@
  */
 package org.onlab.packet;
 
-import org.slf4j.Logger;
-
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Arrays;
+
+import org.slf4j.Logger;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onlab.packet.PacketUtils.checkInput;
+import static org.onlab.util.SonarSuppressionConstants.SONAR_SWITCH_FALLTHROUGH;
 import static org.slf4j.LoggerFactory.getLogger;
 
-
 /**
  * Implements IGMP control packet format.
  */
@@ -156,7 +156,7 @@
      *
      * @return the serialized IGMP message
      */
-    @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
+    @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning
     @Override
     public byte[] serialize() {
         byte [] data = new byte[8915];
diff --git a/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java b/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
index 4364345..627f141 100644
--- a/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
+++ b/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
@@ -15,8 +15,6 @@
  */
 package org.onlab.util;
 
-import org.slf4j.LoggerFactory;
-
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -26,6 +24,10 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.slf4j.LoggerFactory;
+
+import static org.onlab.util.SonarSuppressionConstants.SONAR_CALL_RUN;
+
 /**
  * Implementation of ThreadPoolExecutor that bounds the work queue.
  * <p>
@@ -137,7 +139,7 @@
      * Feedback policy that delays the caller's thread until the executor's work
      * queue falls below a threshold, then runs the job on the caller's thread.
      */
-    @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
+    @java.lang.SuppressWarnings(SONAR_CALL_RUN) // We really do mean to call run()
     private static final class CallerFeedbackPolicy implements RejectedExecutionHandler {
 
         private final BlockingBoolean underLoad = new BlockingBoolean(false);
diff --git a/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java b/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
index 1e32053..bb07c12 100644
--- a/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
+++ b/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
@@ -19,6 +19,8 @@
 
 import com.google.common.base.Throwables;
 
+import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE;
+
 /**
  * Function that retries execution on failure.
  *
@@ -42,7 +44,7 @@
         this.maxDelayBetweenRetries = maxDelayBetweenRetries;
     }
 
-    @SuppressWarnings("squid:S1181")
+    @SuppressWarnings(SONAR_CATCH_THROWABLE)
     // Yes we really do want to catch Throwable
     @Override
     public V apply(U input) {
diff --git a/utils/misc/src/main/java/org/onlab/util/SonarSuppressionConstants.java b/utils/misc/src/main/java/org/onlab/util/SonarSuppressionConstants.java
new file mode 100644
index 0000000..d087e63
--- /dev/null
+++ b/utils/misc/src/main/java/org/onlab/util/SonarSuppressionConstants.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onlab.util;
+
+/**
+ * Constants to use to suppress SonarQube errors.
+ */
+public final class SonarSuppressionConstants {
+
+    public static final String SONAR_PRINT_STACK_TRACE = "squid:S1148";
+    public static final String SONAR_SWITCH_FALLTHROUGH = "squid:S128";
+    public static final String SONAR_CATCH_THROWABLE = "squid:S1181";
+    public static final String SONAR_CALL_RUN = "squid:S1217";
+
+    /*
+     * Prohibit construction.
+     */
+    private SonarSuppressionConstants() {
+
+    }
+}