Reading the interesting post Should You Ship This Code Before Reducing Technical Debt?!, I got in touch with a graph that caught my attention. It was from another interesting post McCabe Cyclomatic Complexity: the proof in the pudding.
It’s made on historical analysis of tens of thousands of source code files and shows the correlation of Cyclomatic Complexity (CC) values at the file level (x-axis) against the probability of faults being found in those files (y-axis).
Now some considerations / questions:
- I need a better metric: I want to measure something that can say that if I stay under this threshold (say 11 for CC), the probability of faults is less than 1%
- I was taught that CC < 4 is OK, CC between 4 and 10 is bad, CC > 10 is unacceptable … what’s up???
- With a CC between 1 and 35 the probab of fault is pretty constant (and incredibly HIGH!) so should we target our apps to have a CC of 35 or 11?
- Is Cyclomatic Complexity useful to predict anything?