[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.17 complexity Description

The weight of each statement is the number of lines the statement uses. This value is multiplied by the nested logic weighting (2.0 by default) for each layer of logic. For example, this snippet:

 
if (foo) {
  if (bar) {
    bumble; baz;
  }
}

will score 11. This score is then scaled to approximate pmccabe results by dividing by 20 and rounding. This scores "1" at the end. pmccabe scores higher on simple procedures and complexity scores higher with more deeply nested logic.

The scoring can be tweaked by adjusting the --nesting-penalty and --scale-ing factors. The default values were calibrated by comparing the average results of millions of lines of code with the results of pmccabe.

For the purposes of this program, a procedure is identified by a name followed by a parenthesized expression and then an opening curly brace. It ends with a closing curly brace in column 1.


This document was generated by Bruce Korb on May 15, 2011 using texi2html 1.82.