Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sonar project properties Exclude rule squid:S1191

I have a Java project and it will be submitted in Gitlab. In the code present in Gitlab, SonarQube will be used for its analysis. Currently the project is showing Code Smells with detail Classes from "sun.*" packages should not be used.

How do I include the exclusion of this rule when my Maven Project is analysed by SonarQube?

What I go to know is that we have to put this in sonar-project.properties. But I am not able to find what tag should be used for that.

like image 718
Aakash Goyal Avatar asked Sep 20 '25 12:09

Aakash Goyal


1 Answers

In Maven projects, pom.xml is the main configuration file. If we add below lines in that, the rule S1191 will not be applied. And this is in tight coupling with the project, which is what was required. So, no need to configure any SonarQube instance, rather specify below lines in pom.xml under properties tag. That will work.

<sonar.issue.ignore.multicriteria>e1</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S1191</sonar.issue.ignore.multicriteria.e1.ruleKey>
<sonar.issue.ignore.multicriteria.e1.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
like image 178
Aakash Goyal Avatar answered Sep 23 '25 05:09

Aakash Goyal