Yuval Simhon
Yuval Simhon

Reputation: 1459

SonarQube define "Ignore Issues on Multiple Criteria" in maven build

Is it supported by sonar-maven-plugin to set the "Ignore Issues on Multiple Criteria" to Narrow the focus as -Dsonar.issue.ignore.multicriteria for the sonar-maven-plugin run command?


Any working example is welcomed.

Upvotes: 2

Views: 3362

Answers (2)

Isaiah4110
Isaiah4110

Reputation: 10090

An additional note for people ending up on this answer. 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 wont work. The language specific rules can be passed line arguments and thats why the "squid:S1845" 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

Upvotes: 0

Eitan Volach
Eitan Volach

Reputation: 56

I have created similar setup in my project, as we needed to set the exclusions from the maven command (same as you), and not via the sonar gui (Sonar documentation only refers to exclusions via sonar's gui) Here's what we did in our project:

"-Dcommon.sonar.issue.ignore.multicriteria=e1,e2 " +
"-Dcommon.sonar.issue.ignore.multicriteria.e1.ruleKey=squid:S1845 " +
"-Dcommon.sonar.issue.ignore.multicriteria.e1.resourceKey=**/input/**/*.java " +
"-Dcommon.sonar.issue.ignore.multicriteria.e2.ruleKey=squid:S1845 " +
"-Dcommon.sonar.issue.ignore.multicriteria.e2.resourceKey=**/datatypes/**/*.java"

We also had these additional exclusions, i thought would be of assistance to the public:

"-Dsonar.issue.ignore.allfile=r1,r2 " +
"-Dsonar.issue.ignore.allfile.r1.fileRegexp=@Input\\(.*\\) " +
"-Dsonar.issue.ignore.allfile.r2.fileRegexp=@Output\\(.*\\)"

Upvotes: 3

Related Questions