Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Sonar, how to prevent checking some rules in some packages?

Tags:

java

sonarqube

We have an Android/Blackberry project with a common part. That part, obviously, is written to compile to both Android and Blackberry targets, and, consequently, cannot use some of the newer Java features (e.g., Integer.valueOf). I'd like to skip some of the rules specifically for that part. Is there a way to do this?

like image 275
Fixpoint Avatar asked Jul 15 '11 14:07

Fixpoint


People also ask

How do you exclude rules in SonarQube?

You can have SonarQube ignore issues on certain components and against certain coding rules. Go to Project Settings > General Settings > Analysis Scope > Issues. Note that the properties below can only be set through the web interface because they are multi-valued.

How do you customize Sonar rules?

There are three ways to add coding rules to SonarQube: Writing a SonarQube plugin in Java that uses SonarQube APIs to add new rules. Adding XPath rules directly through the SonarQube web interface. Importing Generic Issue Reports generated by an independently run tool.


1 Answers

If you separate the common part to an own project you can add a new Quality Profile in Sonar (where you deactivated these rules) and assign it to your common project.

Apart from that you can use the

// NOSONAR

comment to supress a warning on a single line (see FAQ).

like image 149
FrVaBe Avatar answered Oct 23 '22 01:10

FrVaBe