re: Coding Concepts! Cyclomatic Complexity VIEW POST

re: Hi Dustin, nested branches are definitely classed as more complex, have a look at your examples run through the Code Metrics extension in VSCode. T...

Nesting does hurt readability, as the CQSE post you linked to mentions.

However, the first example has fewer routes because of the nesting. If a is False, there's only one route to take, regardless of the value of b.

It's about all potential routes through. Rather than specific routes. If you wanted to get 100% code coverage you would need to cover every possible route, this is what the complexity of trying to convey.

I'm not sure what you mean by potential vs. specific routes.

I think you're trying to say that it's either in the if or else statement. So there are two specific routes through. But those two routes vary massively depending on which it goes into. The metric doesn't gauge which is more likely or weight them accordingly. I agree It's definitely not perfect, the reverse piece in the additional reading section defines it's pitfalls well.

code of conduct - report abuse