3 ms·
> "Complexity": Cyclomatic complexity is a near-worthless metric, especially in a language like PHP. It's easy to convert a series of 10 if statements into one
by voidr 10y ago
> "Complexity": Cyclomatic complexity is a near-worthless metric, especially in a language like PHP. It's easy to convert a series of 10 if statements into one while loop by leveraging call_user_func and deterministic method names. The resulting while statement is infinitely more complex than the if statements and reduces the benefits of using an IDE. So unless your CC algorithm treats this kind of programming as wildly complex, then it's not giving you a true complexity value (in fact, it's actually lying to you).
Just because you have a way of cheating it, doesn't make it worthless.
I agree that cyclomatic complexity is good, but it's not enough on it's own, that's why you have other metrics, rules and manual reviews.