Revert changes to use constants for Sonar suppression
It turns out that suppression annotations have to have the actual
string literal in them; if you use a defined constant SonarQube
ignores the suppression.
Change-Id: I3628df116d182b01a108da0d6f059784a3be4fed
diff --git a/apps/events/src/main/java/org/onosproject/events/EventsCommand.java b/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
index 4d26466..03419af 100644
--- a/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
+++ b/apps/events/src/main/java/org/onosproject/events/EventsCommand.java
@@ -44,7 +44,6 @@
import com.google.common.collect.ImmutableList;
import static java.util.stream.Collectors.toList;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_PRINT_STACK_TRACE;
/**
* Command to print history of instance local ONOS Events.
@@ -162,7 +161,7 @@
*
* @param json JSON node to print
*/
- @java.lang.SuppressWarnings(SONAR_PRINT_STACK_TRACE)
+ @java.lang.SuppressWarnings("squid:S1148")
private void printJson(JsonNode json) {
try {
print("%s", mapper().writerWithDefaultPrettyPrinter().writeValueAsString(json));
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java
index 93939e9..23032ca 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java
@@ -46,8 +46,6 @@
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_PRINT_STACK_TRACE;
-
/**
* Installs bulk flows.
*/
@@ -66,7 +64,7 @@
String numOfRuns = null;
@Override
- @java.lang.SuppressWarnings(SONAR_PRINT_STACK_TRACE)
+ @java.lang.SuppressWarnings("squid:S1148")
protected void execute() {
FlowRuleService flowService = get(FlowRuleService.class);
DeviceService deviceService = get(DeviceService.class);
diff --git a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index 35555a1..a8609ac 100644
--- a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -44,7 +44,6 @@
import com.google.common.collect.Maps;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_CALL_RUN;
import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED;
import static org.onosproject.app.ApplicationEvent.Type.APP_DEACTIVATED;
import static org.onosproject.app.ApplicationEvent.Type.APP_INSTALLED;
@@ -281,7 +280,7 @@
}
// Invokes the specified function, if not null.
- @java.lang.SuppressWarnings(SONAR_CALL_RUN) // We really do mean to call run()
+ @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run()
private void invokeHook(Runnable hook, ApplicationId appId) {
if (hook != null) {
try {
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 5f82d82..212c7a1 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IGMP.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
@@ -27,7 +27,6 @@
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;
/**
@@ -156,7 +155,7 @@
*
* @return the serialized IGMP message
*/
- @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning
+ @java.lang.SuppressWarnings("squid:S128") // 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 627f141..5ca88c2 100644
--- a/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
+++ b/utils/misc/src/main/java/org/onlab/util/BoundedThreadPool.java
@@ -26,8 +26,6 @@
import org.slf4j.LoggerFactory;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_CALL_RUN;
-
/**
* Implementation of ThreadPoolExecutor that bounds the work queue.
* <p>
@@ -139,7 +137,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(SONAR_CALL_RUN) // We really do mean to call run()
+ @java.lang.SuppressWarnings("squid:S1217") // 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 bb07c12..1e32053 100644
--- a/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
+++ b/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
@@ -19,8 +19,6 @@
import com.google.common.base.Throwables;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE;
-
/**
* Function that retries execution on failure.
*
@@ -44,7 +42,7 @@
this.maxDelayBetweenRetries = maxDelayBetweenRetries;
}
- @SuppressWarnings(SONAR_CATCH_THROWABLE)
+ @SuppressWarnings("squid:S1181")
// 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
deleted file mode 100644
index d087e63..0000000
--- a/utils/misc/src/main/java/org/onlab/util/SonarSuppressionConstants.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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() {
-
- }
-}
diff --git a/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java b/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
index e5382e1..1c582a1 100644
--- a/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
+++ b/utils/netty/src/main/java/org/onlab/netty/MessageDecoder.java
@@ -30,7 +30,6 @@
import com.google.common.base.Charsets;
import static com.google.common.base.Preconditions.checkState;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_SWITCH_FALLTHROUGH;
/**
* Decoder for inbound messages.
@@ -55,7 +54,7 @@
}
@Override
- @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning
+ @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning
protected void decode(
ChannelHandlerContext context,
ByteBuf buffer,
diff --git a/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java b/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
index 77d4a40..03f7276 100644
--- a/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
+++ b/utils/netty/src/main/java/org/onlab/netty/NettyMessaging.java
@@ -67,8 +67,6 @@
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
-import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE;
-
/**
* Implementation of MessagingService based on <a href="http://netty.io/">Netty</a> framework.
*/
@@ -111,7 +109,7 @@
protected char[] ksPwd;
protected char[] tsPwd;
- @SuppressWarnings(SONAR_CATCH_THROWABLE)
+ @SuppressWarnings("squid:S1181")
// We really need to catch Throwable due to netty native epoll() handling
private void initEventLoopGroup() {
// try Epoll first and if that does work, use nio.