17

How can I ignore SonarQube warnings in Python code

In Java, I can use

@SuppressWarnings("squid:S1166")

Where the ID is the SonarQube rule ID. But what syntax should I use in Python?

I've tried

# noinspection python:S1313

but it didn't work.

To be clear, I'm looking for a solution in python code. NOT JAVA.

Daniel Scott
  • 6,757
  • 4
  • 33
  • 53
  • Possible duplicate of [In Sonar, how to prevent checking some rules in some packages?](http://stackoverflow.com/questions/6708628/in-sonar-how-to-prevent-checking-some-rules-in-some-packages) – CSchulz Jun 06 '16 at 12:10
  • 5
    That is quite clearly tagged as a java question... – Daniel Scott Jun 12 '16 at 07:46

1 Answers1

19

I believe the only syntax supported for Python (assuming it is supported) is the NOSONAR comment, so #NOSONAR at the end of the line where you want to ignore issues.

Unfortunately, this is a global issue suppression: it kills all issues on the line, not just those from a specific rule.

G. Ann - SonarSource Team
  • 21,458
  • 4
  • 36
  • 65