Skip a particular rule for tests

  • ALM used: GitHub
  • CI system used: Travis CI
  • Languages of the repository: Python

Hi, I am using SonarCloud on an open source project.
The unit tests include parameterized tests with several arbitrary IP addresses as parameter.
SonarCloud is correctly reporting “Using hardcoded IP addresses is security-sensitive” as a security hotspot for these tests, but I would like to suppress these findings for files tests/test_*.py.

According to the docs I found two ways to achieve this, but I am struggeling to implement them:

  1. Administration -> General Settings -> Analysis Scope -> Ignore Issues on Multiple Criteria
    Issue persisting: How do I identify the Rule Key for the given rule?

  2. Define a new profile in Administration -> Quality Profiles
    Issue persisting: I can’t create a new profile. I only have drop down boxes to chose a profile, but they only contain the defautl profile “Sonar way”.

Any hints wold be appreciated.

Thx,
stdtom

Hi Stdtom,

Welcome to the community support!

For 1.

You can find a rule key when you go to the organization level.

You can see it yourself on my public org for instance.

So click on your org then select the tab “Rules” then use the search below “Filters”, then the rule key is displayed on the right of the rule title when you click on the rule list, here it’s python:S1313

For 2:

You can create a profile by copy only.
You can pick one existing then you can update it as you wish.

Please check the how section of the quality profile doc.

Thanks for using our products.

Best.