Configure Sonar sonar.issue.ignore.multicriteria through maven

13,387

After stepping through the code the format is:

<properties>
        <sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
        <sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S00100</sonar.issue.ignore.multicriteria.e1.ruleKey>
        <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*Steps.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
        <sonar.issue.ignore.multicriteria.e2.ruleKey>squid:S1118</sonar.issue.ignore.multicriteria.e2.ruleKey>
        <sonar.issue.ignore.multicriteria.e2.resourceKey>**/PropertyPlaceholderConfig.java</sonar.issue.ignore.multicriteria.e2.resourceKey>
</properties>

The keys e1,e2 can be chosen arbitrarily as long as they are used with .ruleKey and .resourceKey in the depending properties.

The same works for sonar.issue.ignore.block:

 <sonar.issue.ignore.block>e1</sonar.issue.ignore.block>
 <sonar.issue.ignore.block.e1.beginBlockRegexp>@SonarIgnore</sonar.issue.ignore.block.e1.beginBlockRegexp>
 <sonar.issue.ignore.block.e1.endBlockRegexp></sonar.issue.ignore.block.e1.endBlockRegexp>
Share:
13,387

Related videos on Youtube

revau.lt
Author by

revau.lt

Updated on June 15, 2022

Comments

  • revau.lt
    revau.lt 11 months

    I'm using a local instance of Sonar without a centralized infrastructure. In order to keep the configuration of my project in the pom.xml, I want to configure the project through maven and not through the Sonar UI. For me this has the advantage of keeping things in one place and other developers don't have to configure their local Sonar instance, just unpack and play.

    The doc on howto configure the sonar.exclusions property through maven is readily available but the format for sonar.issue.ignore.multicriteria is unclear.

    How can you configure sonar.issue.ignore.multicriteria through maven?

  • Michael Piefel
    Michael Piefel about 8 years
    Probably a typo. I removed it. Sonarqube does not seem to accept more than one path there.
  • dokaspar
    dokaspar almost 6 years
    did you intentionally leave the endBlockRegexp part empty?
  • PAA
    PAA almost 4 years
    It looks like sonar.exclusions doesn't exclude the multiple paths like **/enums/**,**/entity/**,**/constant/**
  • Isaiah4110
    Isaiah4110 about 3 years
    Please check this answer out, the above answer won’t work for common rules. Hope that helps someone. stackoverflow.com/a/60570763/1766402

Related