I would like to be guided on an appropriate cognitive complexity metric

Hi Team,
I would like to be guided on an appropriate cognitive complexity metric. For example, 30 or 50.
Environment:

  • Domain web applications such as ERP, MES, …
  • Language: Java

And is it possible to configure Cognitive complexity metric of a quality gate against function level rather than file level?

Many thanks,
Terry

Hey there!

I think this post will help you out:

In summary: It’s typically not a good idea to use Cognitive Complexity as a Quality Gate condition, because the Quality Gate only looks at the project-level metric.

Meanwhile, configuring a rule like Cognitive Complexity of methods should not be too high will catch functions that become too complex.

IIWY, I’d simply drop those Quality Gate conditions. Your rules will flag all the methods that need work.

1 Like