Does it make sense to compute cyclomatic complexity/lines of code ratio

code metricscomplexitycyclomatic-complexitymaintainability

In general, maintainability index relies on many factors. For example, in Visual Studio, it rely on cyclomatic complexity, depth of inheritance, class coupling and lines of code; those four values must be as low as possible.

At the same time, I've never seen, neither in code metrics tools, nor in books, the comparison between only cyclomatic complexity (CC) and lines of code (LC).

Does it make sense to compute such ratio? What information does it give about the code? In other words, is it better to decrease more the CC than the LC to have a lower ratio?

What I notice is that for small projects, the ratio CC/LC is low (⅓ and lower). In other words, LC is high, and CC is low. In large projects, CC/LC is in most cases bigger than ½. Why?

Best Answer

From http://en.wikipedia.org/wiki/Cyclomatic_complexity

Les Hatton claimed recently (Keynote at TAIC-PART 2008, Windsor, UK, Sept 2008) that McCabe Cyclomatic Complexity has the same prediction ability as lines of code.[11]

The ratio has about the same prediction ability as either used separately.

Related Topic