为某些代码关闭Sonar [英] Turning Sonar off for certain code
问题描述
是否可以关闭特定代码块的声纳( www.sonarsource.org )测量值,一个人不想被测量?
Is it possible to turn off sonar (www.sonarsource.org) measurements for specific blocks of code, which one doesn't want to be measured?
一个例子是Findbugs输出的保留堆栈跟踪警告。离开服务器时,我可能只想将消息传递回客户端,不包括我刚捕获的实际异常,如果客户端不知道该异常(因为客户端没有JAR,那么例如包含异常。
An example is the "Preserve Stack Trace" warning which Findbugs outputs. When leaving the server, I might well want to only pass the message back to the client, not including the actual exception which I just caught, if that exception is unknown to the client (because the client doesn't have the JAR in which that exception was contained for example).
推荐答案
这是常见问题解答。您可以在触发警告的行上放置 // NOSONAR
。我更喜欢使用FindBugs机制,它包括添加@SuppressFBWarnings注释:
This is a FAQ. You can put //NOSONAR
on the line triggering the warning. I prefer using the FindBugs mechanism though, which consists in adding the @SuppressFBWarnings annotation:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "NAME_OF_THE_FINDBUGS_RULE_TO_IGNORE",
justification = "Why you choose to ignore it")
这篇关于为某些代码关闭Sonar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!