How to permanently ignore a false positive in SonarQube rule violation

SonarQ picture SonarQ · Sep 29, 2014 · Viewed 8.7k times · Source

How does a developer ( or for that matter any authorized user ) ignore a specific coding rule violation when Sonar throws it? Say a rule “Does not follow file naming convention ” pops up , is there a way I can declare it a false positive and click on some button which ensures that further instances of that coding rule violation are not displayed ?

If this is not possible, is there a document which explains how SonarQube applies rules to the code , so that I can manipulate the way it works to permanently dismiss a false positive . Thanks !

This question maybe an extension of the below question

In Sonar, how to prevent checking some rules in some packages?

Answer

Fabrice - SonarSource Team picture Fabrice - SonarSource Team · Sep 30, 2014

There are 2 points in your question:

  • You detect that a rule has generated a false positive issue on your code?

    • You can flag this issue as "false positive" in the Web UI, it will then be ignored in the next analyses

    • If this is a real false positive, then it is even a good idea to come on the SonarQube user mailling list to discuss this so that we can create a JIRA ticket to fix this

  • You find that a rule always generates issues that are not relevant in your context?

    • Those issues are not false positive at all, they are just irrelevant on your project

    • To fix this, you just have to deactivate the rule in the quality profile that is used for your project