Quality Gate rules on Cognitive Complexity

It would be great if we could set a Quality Gate thresholds on Cognitive Complexity for methods or classes.

Hi Mike,

There’s a rule to enforce Cognitive Complexity on methods that’s at Critical severity by default. You can enforce complexity as part of your Quality Gate by making sure it always fails if this rule is violated. To do this you’d need to tie the severity of the issue into your Quality Gate criteria, e.g. you could choose to enforce against “Critical issues > 0” or, if worried about the noise resulting from that, tailor the complexity rule to have a Blocker severity in your Quality Profile and then add a QG criterion for “Blocker issues > 0”.

Hope this helps.

Oh, this is a great workaround! Thanks. I will certainly do that in the interim (why didn’t I think of that? :smiley: )

However, this has a certain drawback as the quality gate failure will only say you have more than one blocker. And I personally believe Cognitive Complexity is not just like any other blocker. It would be great if you could see on the project status page that this particular rule got broken. Sends a completely different message, I think.