Add noqa support to SonarLint for Python (and consider it for other languages)

Python static analysis tools, such as flake8 or pylint support the convention of adding a # noqa: <rule> or # pylint: <rule> comment line to disregard a rule on a specific line. I’d love to see this same kind of thing come to Sonar Qube or Sonar Lint. Ideally, I’d prefer for it to use the pylint or noqa on its own rather than defining a new one.

This would give me, as the developer, the ability to add exceptions for specific rules on a line or file basis without having to change the sonar-project file or the project config on the server.

Documentation of the existing standards:

BTW, while I give Python specific examples here (and it would be nice to support existing standards here), I think having something like this for each language would be a good thing.

Maybe for C#, something like:

string s = "";
  s = File.ReadAllText(fileName);
catch (Exception e)
  throw;  // nosonar: S2737

Hello @Josh_Schneider and thanks for posting this suggestion, we’ve made a note of it.

What is already possible today in SonarQube is to:

In both cases, when you use SonarLint in connected mode, those settings will be automatically synchronized from SonarQube to your IDE. Please note that such mechanism is totally language-agnostic and you can use it for any of your projects.

To better understand the context of your suggest, it would be very interesting for us to understand ( especially in case you already tried the above) why your preference goes for using comments in the source code; is it because you use additional tools / linters and you are seeking of a more “standard” why to suppress detections?

@Josh_Schneider, I forgot to mention that, as an additional workaround you can specify a #NOSONAR comment for the line where you want to mute issues:

Please note that with this workaround, you cannot specify a specific rule - all issues on that line will be mute.

And still, I would be interested to understand which approach you prefer between this one and those I described above, and why :wink: