Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable specific sonarqube rule for all java files in a project

Tags:

sonarqube

I am running sonarqube analysis for one of my java project and it is reporting a lot of violations and majority of the violations reported are for the maximum number of parents a class can have squid:MaximumInheritanceDepth

This class has 6 parents which is greater than 5 authorized

I have more than 100 classes in the project and I do not want to add @SuppressWarning annotation for each of the classes.

Is there a way I can disable this rule for all the Java files in my project?

like image 280
Prasann Avatar asked Mar 09 '23 07:03

Prasann


1 Answers

One option is to analyze this project with a copy of that profile from which you've removed this rule.

Another is to create a another profile, inherit the rules from your existing profile and update the parameter value on this particular rule, bumping the value to 6 (or 7 or ...)

A third option is to use exclusions to effectively turn that rule off for the files in your project.

Go to Project Administration > General Settings > Analysis Scope > Ignore Issues on Multiple Criteria and fill in the rule key (squid:MaximumInheritanceDepth) and file pattern (**/*.java) and that should do the trick.

like image 104
G. Ann - SonarSource Team Avatar answered Apr 08 '23 23:04

G. Ann - SonarSource Team