Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
The only valid code quality metric is WTFs/minute ;) – delnan Mar 8 '11 at 19:27
Your last prediction (small x large projects) probably depends on the platform and the amount of boilerplate code one must write to get a minimal project running. Using the raw Win32 API the amount of boilerplate to real code is high for small projects, for example. This inflates the number of line of code. You could select a few random open source projects and do a scatter plot of CC x LC. Maybe you can find something useful out of it. – Vitor Py Mar 8 '11 at 20:33
The ratio you are suggesting is interesting IMO but I want to suggest to replace lines of code (LOC) with Function Points (FP) or Use Case points (UCP) and see what you get. – M.Sameer Mar 19 '11 at 18:15
up vote 5 down vote accepted


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.

share|improve this answer
I disagree. Cyclomatic Complexity (CC) is clearly correlated with Logical Lines of Code (LLOC). The bigger your project is, the higher its complexity is. This is obvious. But CC/LLOC has no correlation with the size of a project (I have seen concrete examples). This ratio depends on three things : language and framework used, project functional complexity and code style. If the two firsts elements can't be changed easily, the third one can be a clear indication of code quality. – Alexandre Butynski Sep 9 '15 at 16:35

There is a metric of cyclomatic complexity per source statements - it's called cyclomatic complexity density. This metric can be used to estimate the maintenance time and effort required for software projects.

share|improve this answer

Sorry but I disagree with this statement:

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

A ratio is clearly not the same as an individual metric. Based on empirical data, Hatton claims that CC is proportional to XLOC with a constant ratio of about 0.25 (see slide 17) for his specific data set. Hence whether your XLOC is 60 or 400, your CC:XLOC ratio will be about 0.25 (ignoring statistical deviations at higher numbers). So the ratio is not predictive whatsoever.

share|improve this answer
surely you are more likely to get statistic deviation with small numbers – jk. Sep 15 '11 at 8:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.