Where is the documentation on how to suppress each kind of warning?


(Randy Strauss) #1

I sometimes want to suppress individual warnings.
For instance, I use a logger for my java web server, but I want to output an error and quit if the configuration is missing- I want it to go to stderr as well as the logger.
What rune do I put in
to suppress the S106 warning?

But in general, for a given random warning, where do I find the doc that tells me how to suppress it?

(Randy Strauss) #2

Never mind, found it:

(Gilbert Rebhan) #3

Hi Randy,

it’s also possible to suppress more than one rule via @SuppressWarnings({“squid:xxx”,“squid:xxx”})
See documentation

As Sonarqube admin be sure to use:

  1. squid:S1309 ‘Track uses of “@SuppressWarnings” annotations’
    with an appropriate whitelist to prevent some clever developers
    using @SuppressWarnings("all") in all their classes

  2. squid:NoSonar ‘Track uses of “NOSONAR” comments’
    to prevent the use of //NOSONAR for hiding issues

Also note that issues for rules working on file level, e.g.
squid:S00104 ‘Files should not have too many lines of code’ can’t be suppressed,
see https://docs.sonarqube.org/display/PLUG/Java+FAQ#JavaFAQ-SuppressWarnings