Committed by
Gerrit Code Review
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
Showing
9 changed files
with
8 additions
and
54 deletions
... | @@ -44,7 +44,6 @@ import com.google.common.base.MoreObjects; | ... | @@ -44,7 +44,6 @@ import com.google.common.base.MoreObjects; |
44 | import com.google.common.collect.ImmutableList; | 44 | import com.google.common.collect.ImmutableList; |
45 | 45 | ||
46 | import static java.util.stream.Collectors.toList; | 46 | import static java.util.stream.Collectors.toList; |
47 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_PRINT_STACK_TRACE; | ||
48 | 47 | ||
49 | /** | 48 | /** |
50 | * Command to print history of instance local ONOS Events. | 49 | * Command to print history of instance local ONOS Events. |
... | @@ -162,7 +161,7 @@ public class EventsCommand | ... | @@ -162,7 +161,7 @@ public class EventsCommand |
162 | * | 161 | * |
163 | * @param json JSON node to print | 162 | * @param json JSON node to print |
164 | */ | 163 | */ |
165 | - @java.lang.SuppressWarnings(SONAR_PRINT_STACK_TRACE) | 164 | + @java.lang.SuppressWarnings("squid:S1148") |
166 | private void printJson(JsonNode json) { | 165 | private void printJson(JsonNode json) { |
167 | try { | 166 | try { |
168 | print("%s", mapper().writerWithDefaultPrettyPrinter().writeValueAsString(json)); | 167 | print("%s", mapper().writerWithDefaultPrettyPrinter().writeValueAsString(json)); | ... | ... |
... | @@ -46,8 +46,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; | ... | @@ -46,8 +46,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; |
46 | import com.google.common.base.Stopwatch; | 46 | import com.google.common.base.Stopwatch; |
47 | import com.google.common.collect.Lists; | 47 | import com.google.common.collect.Lists; |
48 | 48 | ||
49 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_PRINT_STACK_TRACE; | ||
50 | - | ||
51 | /** | 49 | /** |
52 | * Installs bulk flows. | 50 | * Installs bulk flows. |
53 | */ | 51 | */ |
... | @@ -66,7 +64,7 @@ public class AddTestFlowsCommand extends AbstractShellCommand { | ... | @@ -66,7 +64,7 @@ public class AddTestFlowsCommand extends AbstractShellCommand { |
66 | String numOfRuns = null; | 64 | String numOfRuns = null; |
67 | 65 | ||
68 | @Override | 66 | @Override |
69 | - @java.lang.SuppressWarnings(SONAR_PRINT_STACK_TRACE) | 67 | + @java.lang.SuppressWarnings("squid:S1148") |
70 | protected void execute() { | 68 | protected void execute() { |
71 | FlowRuleService flowService = get(FlowRuleService.class); | 69 | FlowRuleService flowService = get(FlowRuleService.class); |
72 | DeviceService deviceService = get(DeviceService.class); | 70 | DeviceService deviceService = get(DeviceService.class); | ... | ... |
... | @@ -44,7 +44,6 @@ import org.slf4j.Logger; | ... | @@ -44,7 +44,6 @@ import org.slf4j.Logger; |
44 | import com.google.common.collect.Maps; | 44 | import com.google.common.collect.Maps; |
45 | 45 | ||
46 | import static com.google.common.base.Preconditions.checkNotNull; | 46 | import static com.google.common.base.Preconditions.checkNotNull; |
47 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_CALL_RUN; | ||
48 | import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED; | 47 | import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED; |
49 | import static org.onosproject.app.ApplicationEvent.Type.APP_DEACTIVATED; | 48 | import static org.onosproject.app.ApplicationEvent.Type.APP_DEACTIVATED; |
50 | import static org.onosproject.app.ApplicationEvent.Type.APP_INSTALLED; | 49 | import static org.onosproject.app.ApplicationEvent.Type.APP_INSTALLED; |
... | @@ -281,7 +280,7 @@ public class ApplicationManager | ... | @@ -281,7 +280,7 @@ public class ApplicationManager |
281 | } | 280 | } |
282 | 281 | ||
283 | // Invokes the specified function, if not null. | 282 | // Invokes the specified function, if not null. |
284 | - @java.lang.SuppressWarnings(SONAR_CALL_RUN) // We really do mean to call run() | 283 | + @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run() |
285 | private void invokeHook(Runnable hook, ApplicationId appId) { | 284 | private void invokeHook(Runnable hook, ApplicationId appId) { |
286 | if (hook != null) { | 285 | if (hook != null) { |
287 | try { | 286 | try { | ... | ... |
... | @@ -27,7 +27,6 @@ import org.slf4j.Logger; | ... | @@ -27,7 +27,6 @@ import org.slf4j.Logger; |
27 | import static com.google.common.base.MoreObjects.toStringHelper; | 27 | import static com.google.common.base.MoreObjects.toStringHelper; |
28 | import static com.google.common.base.Preconditions.checkNotNull; | 28 | import static com.google.common.base.Preconditions.checkNotNull; |
29 | import static org.onlab.packet.PacketUtils.checkInput; | 29 | import static org.onlab.packet.PacketUtils.checkInput; |
30 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_SWITCH_FALLTHROUGH; | ||
31 | import static org.slf4j.LoggerFactory.getLogger; | 30 | import static org.slf4j.LoggerFactory.getLogger; |
32 | 31 | ||
33 | /** | 32 | /** |
... | @@ -156,7 +155,7 @@ public class IGMP extends BasePacket { | ... | @@ -156,7 +155,7 @@ public class IGMP extends BasePacket { |
156 | * | 155 | * |
157 | * @return the serialized IGMP message | 156 | * @return the serialized IGMP message |
158 | */ | 157 | */ |
159 | - @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning | 158 | + @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning |
160 | @Override | 159 | @Override |
161 | public byte[] serialize() { | 160 | public byte[] serialize() { |
162 | byte[] data = new byte[8915]; | 161 | byte[] data = new byte[8915]; | ... | ... |
... | @@ -26,8 +26,6 @@ import java.util.concurrent.atomic.AtomicLong; | ... | @@ -26,8 +26,6 @@ import java.util.concurrent.atomic.AtomicLong; |
26 | 26 | ||
27 | import org.slf4j.LoggerFactory; | 27 | import org.slf4j.LoggerFactory; |
28 | 28 | ||
29 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_CALL_RUN; | ||
30 | - | ||
31 | /** | 29 | /** |
32 | * Implementation of ThreadPoolExecutor that bounds the work queue. | 30 | * Implementation of ThreadPoolExecutor that bounds the work queue. |
33 | * <p> | 31 | * <p> |
... | @@ -139,7 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor { | ... | @@ -139,7 +137,7 @@ public final class BoundedThreadPool extends ThreadPoolExecutor { |
139 | * Feedback policy that delays the caller's thread until the executor's work | 137 | * Feedback policy that delays the caller's thread until the executor's work |
140 | * queue falls below a threshold, then runs the job on the caller's thread. | 138 | * queue falls below a threshold, then runs the job on the caller's thread. |
141 | */ | 139 | */ |
142 | - @java.lang.SuppressWarnings(SONAR_CALL_RUN) // We really do mean to call run() | 140 | + @java.lang.SuppressWarnings("squid:S1217") // We really do mean to call run() |
143 | private static final class CallerFeedbackPolicy implements RejectedExecutionHandler { | 141 | private static final class CallerFeedbackPolicy implements RejectedExecutionHandler { |
144 | 142 | ||
145 | private final BlockingBoolean underLoad = new BlockingBoolean(false); | 143 | private final BlockingBoolean underLoad = new BlockingBoolean(false); | ... | ... |
... | @@ -19,8 +19,6 @@ import java.util.function.Function; | ... | @@ -19,8 +19,6 @@ import java.util.function.Function; |
19 | 19 | ||
20 | import com.google.common.base.Throwables; | 20 | import com.google.common.base.Throwables; |
21 | 21 | ||
22 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE; | ||
23 | - | ||
24 | /** | 22 | /** |
25 | * Function that retries execution on failure. | 23 | * Function that retries execution on failure. |
26 | * | 24 | * |
... | @@ -44,7 +42,7 @@ public class RetryingFunction<U, V> implements Function<U, V> { | ... | @@ -44,7 +42,7 @@ public class RetryingFunction<U, V> implements Function<U, V> { |
44 | this.maxDelayBetweenRetries = maxDelayBetweenRetries; | 42 | this.maxDelayBetweenRetries = maxDelayBetweenRetries; |
45 | } | 43 | } |
46 | 44 | ||
47 | - @SuppressWarnings(SONAR_CATCH_THROWABLE) | 45 | + @SuppressWarnings("squid:S1181") |
48 | // Yes we really do want to catch Throwable | 46 | // Yes we really do want to catch Throwable |
49 | @Override | 47 | @Override |
50 | public V apply(U input) { | 48 | public V apply(U input) { | ... | ... |
1 | -/* | ||
2 | - * Copyright 2016 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.onlab.util; | ||
17 | - | ||
18 | -/** | ||
19 | - * Constants to use to suppress SonarQube errors. | ||
20 | - */ | ||
21 | -public final class SonarSuppressionConstants { | ||
22 | - | ||
23 | - public static final String SONAR_PRINT_STACK_TRACE = "squid:S1148"; | ||
24 | - public static final String SONAR_SWITCH_FALLTHROUGH = "squid:S128"; | ||
25 | - public static final String SONAR_CATCH_THROWABLE = "squid:S1181"; | ||
26 | - public static final String SONAR_CALL_RUN = "squid:S1217"; | ||
27 | - | ||
28 | - /* | ||
29 | - * Prohibit construction. | ||
30 | - */ | ||
31 | - private SonarSuppressionConstants() { | ||
32 | - | ||
33 | - } | ||
34 | -} |
... | @@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory; | ... | @@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory; |
30 | import com.google.common.base.Charsets; | 30 | import com.google.common.base.Charsets; |
31 | 31 | ||
32 | import static com.google.common.base.Preconditions.checkState; | 32 | import static com.google.common.base.Preconditions.checkState; |
33 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_SWITCH_FALLTHROUGH; | ||
34 | 33 | ||
35 | /** | 34 | /** |
36 | * Decoder for inbound messages. | 35 | * Decoder for inbound messages. |
... | @@ -55,7 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> { | ... | @@ -55,7 +54,7 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> { |
55 | } | 54 | } |
56 | 55 | ||
57 | @Override | 56 | @Override |
58 | - @java.lang.SuppressWarnings(SONAR_SWITCH_FALLTHROUGH) // suppress switch fall through warning | 57 | + @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning |
59 | protected void decode( | 58 | protected void decode( |
60 | ChannelHandlerContext context, | 59 | ChannelHandlerContext context, |
61 | ByteBuf buffer, | 60 | ByteBuf buffer, | ... | ... |
... | @@ -67,8 +67,6 @@ import com.google.common.cache.CacheBuilder; | ... | @@ -67,8 +67,6 @@ import com.google.common.cache.CacheBuilder; |
67 | import com.google.common.cache.RemovalListener; | 67 | import com.google.common.cache.RemovalListener; |
68 | import com.google.common.cache.RemovalNotification; | 68 | import com.google.common.cache.RemovalNotification; |
69 | 69 | ||
70 | -import static org.onlab.util.SonarSuppressionConstants.SONAR_CATCH_THROWABLE; | ||
71 | - | ||
72 | /** | 70 | /** |
73 | * Implementation of MessagingService based on <a href="http://netty.io/">Netty</a> framework. | 71 | * Implementation of MessagingService based on <a href="http://netty.io/">Netty</a> framework. |
74 | */ | 72 | */ |
... | @@ -111,7 +109,7 @@ public class NettyMessaging implements MessagingService { | ... | @@ -111,7 +109,7 @@ public class NettyMessaging implements MessagingService { |
111 | protected char[] ksPwd; | 109 | protected char[] ksPwd; |
112 | protected char[] tsPwd; | 110 | protected char[] tsPwd; |
113 | 111 | ||
114 | - @SuppressWarnings(SONAR_CATCH_THROWABLE) | 112 | + @SuppressWarnings("squid:S1181") |
115 | // We really need to catch Throwable due to netty native epoll() handling | 113 | // We really need to catch Throwable due to netty native epoll() handling |
116 | private void initEventLoopGroup() { | 114 | private void initEventLoopGroup() { |
117 | // try Epoll first and if that does work, use nio. | 115 | // try Epoll first and if that does work, use nio. | ... | ... |
-
Please register or login to post a comment