Increase allowed congnitive complexity

Please provide

  • Operating system: 11
  • Visual Studio version: 2022
  • SonarQube for Visual Studio plugin version: 9.2
  • Programming language you’re coding in: C#
  • Is connected mode used: No

And a thorough description of the problem / question:
SonarQube 9 is reporting issues such as:
Refactor this method to reduce its Cognitive Complexity from 27 to the 15 allowed.

How can I increase the ‘allowed’ value? Looking at the referenced code I would like it to be 30 before being flagged.

Hi,

You’ve got several steps to accomplish this:

  • Connect to your SonarQube server. This will apply in SonarQube for IDE the same rules that are applied server-side
  • Make sure your project is using a custom quality profile (either as the default or through direct assignment) on the server.
  • Update the threshold for that rule in your profile to your desired value. This should probably be done in discussion with your team and/or SonarQube admin.

 
HTH,
Ann

I’m not using SonarQube server, just the IDE extension.

Hi,

Take a look at settings.json section in the docs.

 
HTH,
Ann

Hi Ann. I don’t see anything about that in the docs. I asked the AI on your docs site too and it didn’t find anything either.

Hi,

You’ll need to expand the ‘Language-specific configuration’ section. I had hoped that the anchor I pointed you to would do that. :frowning:

 
Ann

I got it eventually. I didn’t see any information on the parameter name being “threshold” but my IDE suggested it and it worked.

1 Like