Right now, we often use the “false positive” action in the SonarCloud UI to mark an issue as a false positive. The problem with this is the following:
If we ever loose or change our sonarqube instance (as we did when we moved from sonar.xwiki.org to sonarcloud years ago), we loose all these configs.
A local developers having sonarlint installed but not connected to sonarcloud cannot have the info about what should be ignored.
The proposal is to bring this inside the code as much as possible, using the following rules:
Use the @SuppressWarnings(<rule id>) annotation whenever it’s valid to use it, ie everywhere except inside methods (except for variable declarations). Note that <rule id> is the full id, e.g. java:S1133
For the places where the @SuppressWarnings annotation is not allowed, continue using th SonarCloud UI for now. An alternative would be to use // NOSONAR but it disables all rules which is not nice.
Sometimes we also need to disable rules on several classes. For example right now we ignore the java:S1133 rule (see RSPEC) for all classes in **/xwiki-platform-legacy-*/**/*.java.
So I’ve tested it and the issue is gone and thus there’s no way to see what was the issue. That’s a bit painful. When we mark issues as false positives in the UI, we can still see the issue and get the explanation for it, and thus it’s easy to review it and undo the false positive if need be. Here with the annotation it’s much harder to understand the problem…