Since we do not want to discourage comments in the code, we normally
interpret this rule in the following very specific way:
- Before counting function length, we make a copy of each file,
and format it in a standard way (e.g., K&R style). This is to avoid
dependencies on specific ways that different developers format
their code, and it is to prevent 'cheating' (e.g., by merging
multiple statements or declarations into one line).
The normalization of the code layout can be done with the Linux tool indent,
e.g. with the call "indent -kr file.c".
- Next, we strip all comments and blank lines from the normalized code.
This can be done with the tool ncsl, e.g. with the call "ncsl -s file.c > output"
- Next we measure the function length, counting from the function name to
the closing curly brace. (That is, every line that contains text is counted, including
declarations, curly braces, etc.)
A variation of this rule that is sometimes used is to limit not the full
function length, but only the length of each compound statement (if/then/else,
and for-, while-, and until-loop bodies).
In those cases, a slightly tighter bound would be recommended, using e.g. N=30.