Turning Sonar Off for Certain Code

How can we ignore some SonarQube rules in Java?

As noted in the comments, all you have to do is remove the rules from your profile or edit them to lower their priority. You need the Global Administer Quality Profiles permission to do that. Once you're logged in with that permission, go to the Rules interface, search for a rule you want to deactivate, select the rule, click on it, and Deactivate it from the relevant profile.

Disable Sonar rule using pom.xml?

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.

Suppress Sonar's warning on import

Can you please try:

import com.sun.xml.ws.developer.JAXWSProperties; // NOSONAR 

Where is WSIMPORT after JDK11

The executables for WSIMPORT can be found at the main site https://javaee.github.io/metro-jax-ws/.

They're no longer part of JDK.



Related Topics



Leave a reply



Submit