Disable rule in sonar

前端 未结 5 1626
小蘑菇
小蘑菇 2020-12-06 04:30

I want to disable a rule from Sonar so it doesn\'t show the results in the web page. In my case I want to hide (or not capture) the results about trailing comments.

相关标签:
5条回答
  • 2020-12-06 04:59

    You have to remove this rule in the quality profile that you are using to analyse your project.

    Please refer to the documentation that describes all this: Quality Profiles in Sonar.

    0 讨论(0)
  • 2020-12-06 05:08

    Adding to @Vladmir's answer in a new answer as I am not able to comment. You can not modify the built-in profiles. If you don't see the option of Deavtivate, then copy the profile and set it as default. Now you will see the options to activate/deactivate.

    0 讨论(0)
  • 2020-12-06 05:10

    An additional note for people ending up on this thread. I tested this quite a lot and finally found that setting common rules (anything that starts with "common-xxxx") from scanner side (pom, command line etc) will be ignored and it wont work. The language specific rules can be passed line arguments and thats why the "squid:S00105" rule is getting ignored correctly. Here is the issue link on the SonarQube JIRA board and it says that it "wont be fixed".

    https://jira.sonarsource.com/browse/SONAR-8230

    Here is the link to my answer: https://stackoverflow.com/a/60570763/1766402 on how to set it from UI.

    0 讨论(0)
  • 2020-12-06 05:15

    The right way to do is to put something like this on sonar-project.properties file per project:

    sonar.issue.ignore.multicriteria=e1,e2
    # tab characters should not be used
    sonar.issue.ignore.multicriteria.e1.ruleKey=squid:S00105
    sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.java
    # right curly braces should be on a new line
    sonar.issue.ignore.multicriteria.e2.ruleKey=squid:RightCurlyBraceStartLineCheck
    sonar.issue.ignore.multicriteria.e2.resourceKey=**/*.java
    
    0 讨论(0)
  • 2020-12-06 05:19

    In web interface for particular rule just press Deactivate button:

    0 讨论(0)
提交回复
热议问题