TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - C Coding Standard
Search

SR:  13#2Checked automatically with code checker

This rule is Obsolete
Synopsis:Functions shall be restricted to have a maximum static path count prescribed in the appropriate compliance table as measured by a recommended tool unless there is specific sign-off according to local procedures to the effect that this does not prejudice the reliability of the code and does not inhibit satisfactory test coverage.
Language:C
Severity Level:5
Category:MONITORING OF COMPLEXITY


Description:
A large body of evidence exists to suggest that restriction of complexity leads tomore maintainable and reliable code, for example, (McCabe, 1976), (Nejmeh, 1988), (Hatton & Hopkins, 1989) and (Fenton, 1991). The problem is to define acceptable measures of complexity. The above measures are based on population studies of C and functional components with larger values than these will lie in the bottom 10-20% of C code from a wide variety of environments. These measures may change in future following population analysis of existing PMS code to set trigger points appropriate to PMS development.Static path count is rather less obvious so is illustrated by the following example taken from the reference manual for QA C:

Example:

if ( )
{
} /* block 1, paths 1 */
else if ( )
{
    if ( )
    {
    } /* block 2, paths 1 */
    else
    {
    } /* block 3, paths 1 */
    /* block 4, paths block2+block3 = 2 */
    switch ( )
    {
    case 1 : break;
    case 2 : break;
    case 3 : break;
    case 4 : break;
    default: break;
    } /* block 5, paths = 5 */
} /* block 6, paths block4*block5 = 10 */
else
{
    if ( )
    {
    } /* block 7, paths 1 */
    else
    {
    } /* block 8, paths 1 */
} /* block 9, paths block7+block8 = 2 */
/* block 10, paths block1+block6+block9 = 13 */
if ( )
{
} /* block 11, paths 1 */
else
{
} /* block 12, paths 1 */
/* block 13, paths block11+block12 = 2 */
/* outer block, paths block10*block13 = 26 */

Hence the total static path count through this piece of code is 26. Each condition is treated as disjoint and no attention is paid to gotos, returns or other interruptions of control flow.

Note that the true path count through a function obeys the inequality: Number of decisions + 1 <= true path count <= static path count