Search code examples
mavensonarqubesonarcloud

Configure sonar.issue.ignore.multicriteria for multiple paths


I want to disable a SonarQube rule for multiple files at different paths. Also I want to make this configuration within the pom.xml and to through the Sonar UI.

I couldn't find any clue on how to do this. My best guess is that I have to create multiple rules:

<sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
<!-- disable rule on naming convention -->
<sonar.issue.ignore.multicriteria.e1.ruleKey>
    java:S117
</sonar.issue.ignore.multicriteria.e1.ruleKey>
<sonar.issue.ignore.multicriteria.e1.resourceKey>
    firstPath
</sonar.issue.ignore.multicriteria.e1.resourceKey>

<sonar.issue.ignore.multicriteria.e2.ruleKey>
    java:S117
</sonar.issue.ignore.multicriteria.e2.ruleKey>
<sonar.issue.ignore.multicriteria.e2.resourceKey>
    secondPath
</sonar.issue.ignore.multicriteria.e2.resourceKey>

I was wondering if there was a more compact way to do this. I was thinking of something like this:

<sonar.issue.ignore.multicriteria>e1</sonar.issue.ignore.multicriteria>
<!-- disable rule on naming convention -->
<sonar.issue.ignore.multicriteria.e1.ruleKey>
    java:S117
</sonar.issue.ignore.multicriteria.e1.ruleKey>
<sonar.issue.ignore.multicriteria.e1.resourceKey>
    firstPath, secondPath
</sonar.issue.ignore.multicriteria.e1.resourceKey>

However I have no idea if this syntax will be accepted or not. I guess I should try it, but I'd rather not since in order to test it I would need to push the change to my CI server.


Solution

  • This seems not to be supported according to config in answer https://stackoverflow.com/a/63632140/7251133

    I agree it would be really nice when lists would be allowed in rule and resource.