4

I am using Spring Boot and Spring Jpa example and looking to disabled below Sonar rule through Maven mainly using pom.xml file. I don't have access or can't go and disable that rule in SonarQube as it's configured for the Org level.

Methods should not have too many parameters (squid:S00107)

I already went through web many times and did not find any promising solutions yet. This is what I look at : Configure Sonar to exclude files from Maven pom.xml too.

halfer
  • 19,824
  • 17
  • 99
  • 186
PAA
  • 1
  • 46
  • 174
  • 282
  • Has it to be specifically in the `pom` or can you do this in the code ? If you can, then look at this [question](https://stackoverflow.com/questions/10971968/turning-sonar-off-for-certain-code) – Arnaud Claudel Sep 04 '19 at 13:50
  • Thanks for great answer, however I will look to do it in pom.xml to have it in consolidated place as a common concerns. I have almost 80 Model classes and I cant keep adding the same at 80 places. Could you please guide further ? – PAA Sep 04 '19 at 13:55
  • I don't know a way to suppress globally a sonar rule. Another solution, a bit long but it's a one time effort: mark every sonar issue as `won't fix` in the report. – Arnaud Claudel Sep 04 '19 at 14:00
  • @ArnaudClaudel - How can we do that ? I suspect there must be a way to do it globally as Sonar is mature with maven. – Jeff Cook Sep 04 '19 at 14:01

1 Answers1

5

There seem to be a way of doing it but it may not be supported i.e.

<properties>
    <sonar.issue.ignore.multicriteria>e1</sonar.issue.ignore.multicriteria>
    <sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S00107</sonar.issue.ignore.multicriteria.e1.ruleKey>
    <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
</properties>

Refer to : https://community.sonarsource.com/t/documentation-about-ignore-issues-seems-to-be-wrong-or-outdated/3353

but they do state :

We recommend users to use the UI to configure this, for best experience. Consider the configuration via sonar-project.properties as an undocumented hack, not official supported that may or may not work reliably, use at your own risk.

leo
  • 3,528
  • 3
  • 20
  • 19
mkane
  • 880
  • 9
  • 16
  • nice, thank you, how about if i want to add multiple squid id? – aswzen Jun 18 '20 at 09:33
  • Not tried this but one would assume that you just add another comma separated entry i.e. 'e2' to sonar.issue.ignore.multicriteria and then just add the two new entries i.e. sonar.issue.ignore.multicriteria.e2.ruleKey and sonar.issue.ignore.multicriteria.e2.resourceKey with their independent values. – mkane Jun 19 '20 at 14:07