@Julien_HENRY : I am using Sonar Lint in PyCharm. I should be clear here though… the rule that it is checking against is a valid rule… in Python, PEP8 style guide says that function and method names should be defined in
snake_case. We are choosing to deviate from this guideline and allow
PascalCase in the method names for only these
pytest unit test files (since we feel it increases traceability).
I have an exception defined in my
sonar-project.properties to handle this exception, but Sonar Lint does not use the file, so at the moment, we just ignore that error in those files.
Example from my
# Rule specific ignores # Ignore function name does not match regex in unit test files. sonar.issue.ignore.multicriteria=e1 sonar.issue.ignore.multicriteria.e1.ruleKey=python:S1542 sonar.issue.ignore.multicriteria.e1.resourceKey=**/unit_tests/test_*.py
I really, really wish that Sonar Qube and Sonar Lint would also support the
# noqa comment that is pretty standard across
flake8 and other static analysis tools. This allows me to ignore a specific violation on a specific line. For instance:
def test_MyCoolClass_init(): # noqa: S1542 ...
In this case, I could tell it myself to ignore that rule on that line.