Search code examples
spring-bootsonarqubesonarlint

Disable Sonar rule using pom.xml?


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.


Solution

  • 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.