Cyclomatic Complexity

posted on 2005-07-22 at 23:55:24 by Joel Ross

I was introduced to the concept behind CC a while ago, as well as how to measure it, but I never saw any hard numbers about what was an acceptable complexity - until now. Bruce Mcleod has a very nice post that includes a table from Carnegie Mellon Software Engineering Institute about just that. Basically, if you're under 10, you're golden. Up to 20, you're OK. Up to 50 - that's complex. Over 50 and you're in trouble.

Bruce also points out something I missed. If you're into unit testing, measuring your CC gives you the minimum number of tests you'll need to fully exercise your code. That means to achieve 100% code coverage, you need at least as many tests as your project's total CC. Cool!

I was on a project that used some existing code, and I ran some metrics against it. Do you think it was bad that one of the methods had a Cyclomatic Complexity of 406?

Categories: Development