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
Colin
(Colin)
June 21, 2024, 9:48am
2
Hey there!
I think this post will help you out:
Hi,
Quality Gates use Measures, so what you’re really after is the difference between Rules and Measures. Generally (there are some grandfathered exceptions) Measure-related Rules (i.e. a rule with a threshold parameter) act at the method level and below. Measures that you can see outside of Issues (i.e. in the Measures page) are file-level and above.
When you set a Quality Gate parameter on Cognitive Complexity, you said that for the entire project, there should only be a total - across all m…
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