Cognitive complexity is 0

Cognitive complexity is 0 which does not make sense

Hey, I am working on an uni project and one of the requirements for our code is to have a cognitive complexity lower than 50, which assumes good readability of the code. Sonar Cloud gives us a cognitive complexity of 0. However, we have some if clauses, ternary operators and for loops, which should increase the complexity. Has anyone already run into this issue? Thanks in advance


Welcome to the community!

You’re saying your project-level Cognitive Complexity Metric


Is 0?

If so, that implies that your code isn’t being properly recognized / parsed / analyzed.

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.



Thanks for your quick answer.

I think this might be the problem…


Quite possibly. :sweat_smile:

What language are we dealing with here? JavaScript? Are you using the standard file extension?

Are you executing analysis from project root so that a recursive search from that point down would find the source files?