[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Fundamentally, this program counts non-comment source lines and examines elements of parenthesized expressions. This score is multiplied by a nesting scoring factor for each layer of code nesting.
A parenthesized expression is scanned for operators. If they are all
arithmetic operators, or all arithmetic and one relational operator,
the score is zero. If all the operators are boolean and
s or
they are all or
s, then the score is one. An assignment
operator with arithmetic operators also scores one. If you mix
relational operators and all and
s or all or
s, the score
is the number of boolean elements. If you mix and
s and
or
s at the same parenthetical level, the two counts are
multiplied, unless the boolean element count is higher.
Fundamentally, do not use multiple relational or boolean operators at
the same parenthetical level, unless they are all boolean and
s
or they are all boolean or
s. If you use boolean operators and
relational operators in one expression, you are charged one statement
for each boolean element.
After scoring each statement and any parenthesized expressions, the
score is multiplied by any encompassing controlled block and added to
the score of that block. A “controlled block” is a curly-braced
collection of statements controlled by one of the statement
controlling statements do
, for
, else
, if
,
switch
, or while
. Stand alone blocks for scoping local
variables do not trigger the multiplier.
You may trace the scores of parenthesized expressions and code blocks (see section trace output file). You will see the raw score of the code block or expression.
The final score is the outermost score divided by the “scaling factor”, See section complexity scaling factor.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Bruce Korb on May 15, 2011 using texi2html 1.82.