Deactivating a rule in SonarQube

Version Information

Sonarqube Version: * Developer Edition * Version 9.2.4 (build 50792)
We have implemented PR analysis on TFS Checkins.

what are you trying to achieve

Now recently, in c#, the sonarqube is blocking one of PR analysis due to Congnitive Complexity. For the time being, we need to disable this rule, until we clear our code.

Rule Name: Cognitive Complexity of methods should not be too high
The rule is in C# > http://[SonarqubeServer]/coding_rules?rule_key=csharpsquid%3AS3776

When I am going into the RULES > filtering on C#, and searching for above mentioned rule, I can’t seem to DEACTIVATE it.

Also, I have tried EXTENDING the rule, still, I can’t seem to neither DeActivate nor OVERRIDE that rule.

What have you tried so far to achieve this

  • Tried searching on Google to disable the Rule, but didn’t find any way to disable the build in rule.
  • Tried extending the Quality Profile and neither can I disable, nor can I override this rule.

Would really love the experts of Sonarqube to shed some light on this issue.

Hi,

Welcome to the community!

As you see in the interface, you can’t deactivate rules in child/inherited profiles.

Fortunately, Quality Profile updates aren’t what I recommend in your situation. Instead, just mark the one problematic issue “Won’t Fix”. That should free up your PR for merge.

 
HTH,
Ann

Thanks G Ann Campbell,
Is this the permanent solution? Until how many times, this approach would allow our PR to be freed.

What if a similar issue is highlighted somewhere else? By the way, this issue is coming up in many different other places in my code repo.

Hi,

For a question of a single issue, marking it Won’t Fix is probably best. But if you feel the rule simply isn’t appropriate for your situation in general, then deactivating it is indeed the best way to go. You’ll need to create a copy of the profile, set it as your default, and deactivate the rule in the copy.

 
HTH,
Ann

Hi,

FYI, we’re on track to deliver the ability to deactivate rules in an inherited profile in SonarQube 10.3, ETA early November. :tada:

 
Ann

Hi.
We have just upgraded to Version 10.3 (build 82913) and are not really happy with the rule java:S6813. we wanted to deactivte this rule in our inherited profile (From "Java Sonar’ way). It seems not to be possible.
Any ideas to deactivte except copying a complete ruleset?
thanks michael

Hi michael,

Welcome to the community!

There’s a global setting you have to toggle. Go to Administration & scroll to the bottom.

 
Ann

1 Like

I don’t see this option on enterprise 9.9.5 is this setting gone?

Hi,

You’ll need to upgrade to the latest version.

I’m closing this thread since it’s nearing a year old.

 
Ann