Closed ghost closed 8 years ago
Cyclomatic complexity is an established concept; it is concerned with branches, and it doesn't know how they're represented textually in a language. https://en.wikipedia.org/wiki/Cyclomatic_complexity
@weberc2 OK, I see. Though, usefulness of this metrics looks questionable to me. Somebody will definitely have to implement a tool that just enforces flat code, nothing more and nothing less.
It may be a good idea to reopen this issue. As it stands, the metric calculated by gocyclo is a) of highly questionable value and b) unrelated to cyclomatic complexity.
Yep. The project claims to compute cyclomatic complexity, but in fact it does not
Hello, @fzipp.
I think highly nested construction should not give the same amount of points as the first-level one. Flat code is less complex than nested, isn't it? For illustration, here is a code fragment that has complexity of 11:
Pretty simple and straight-forward function, isn't it? Now here is another one that is "less complex" (level is 10):
For me, personally, this doesn't look like a less complex function. What do you think?
My opinion is complexity should grow geometrically with every level of nesting. But requirements for flat code may be loosed up.