I am on SonarQube 10.3.
I have a particular function which breaks rule c:S1244 “Floating point numbers should not be tested for equality”. In this function, there is nothing at all wrong with testing for equality, so I want to exclude it from the rule. How do I do this exclusion without going and clicking on each instance in the SonarQube web site?
What I am really looking for is exclusion tags, e.g.
/* SONARQUBE_EXCLUDE_START (c:S1244) */
/* SONARQUBE_EXCLUDE_END (c:S1244) */
I cannot find documentation on this. Does it not exist? What is the alternative?
Welcome to the community!
I guess you don’t want to have to mark it Won’t Fix / Accepted across branches?
While you can turn off specific rules for specific files, your best bet is probably to use a
//NOSONAR comment on the line where the issues is raised. Note that this will suppress all issues on the line, not just this one. But it happens at the code level, so it will take effect across (all future) branches.
I was actually just reading about
sonar.issue.ignore.block, which I think would be more what I’m looking for, but thank you anyway.
Do you know if there is a timeline for turning off individual rules with tags like this?
Per the docs,
sonar.issue.ignore.block ignores all issues within the block not just your selected one, and it requires you to denote the blocks with begin and end strings. It’s intended to allow you to exclude blocks of generated code within a file. I don’t believe it’s appropriate for your situation.
There’s been some discussion on this topic, but I’m not aware of a timeline.