False-Positive and Won't Fix - NOLINT

Based on documentation SonarQube only support //NOSONAR tag to suppress issues.

Can SonarQube be configured to support also following tag?

// NOLINT
// NOLINTNEXTLINE

Hey there.

Today, SonarQube doesn’t support this.

What language(s) are you developing in? Where does this tag come from (is it used by other tools already)?

It is C++ and the tags are from clang-tidy linter.

https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics

Hello @Olexandr_Shamin,

Could you elaborate on why you need these tags in addition to NOSONAR?
Is it to avoid duplicating the tags or is there another reason?

Thank you,
Amélie

We are in the same situation. In our existing C++ codebase we have added a bunch of exception tags for clang-tidy (NOLINT, NOLINTNEXTLINE). We are not keen to add duplicate NOSONAR tags as they will clutter the codebase and reduce its readability.

Furthermore, in some cases it is not possible to add extra tags without breaking our code style rule, which is automatically enforced. If adding Sonar tags requires us to reformat our codebase, that makes your tool completely unacceptable for us.

Hi @Ross_Younger and welcome to the Sonar Community!
One way to suppress issues without adding extra tags is to resolve them as Won’t Fix in SonarQube, and I’d be interested to know if this could be a solution for you.

We’re aware that //NOSONAR is far from being a perfect solution to suppress issues. We have plans to evaluate the opportunity to support extra tags that make sense for the different language community (examples included //NOLINT, //NOLINTNEXTLINE for C++ and #noqa for Python); we’re not there yet but there are chances we’ll manage to advance on this topic during 2023.

Hi Marco, thanks for the information. From where I stand, having the option to support NOLINT and other similar tag standards is a no-brainer.

We have set up the Bitbucket integration to report on PRs. Do you expect that when I mark an issue as Won’t Fix in a PR, the resolution should be transferred to the main branch? I think that this is not happening, but right now we are still drowning in Sonar noise that makes it hard to keep track.

Hi Ross,

When you flag an issue as Won’t Fix in your PR, this status should automatically propagate from the PR to its target branch when your PR is merged. If your PR is targeting the main branch, the issue should then show up as Won’t fix in this branch.

Chris