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

Category: Control Flow

Synopsis:Rules about Program Flow


Description:
This chapter concerns control flow through control statements, such as if, for, while, do, switch and goto.

Coding Rules

NameCheckedSynopsis
CFL#001 Checked automatically with code checker Statements following a case label shall be terminated by a statement that exits the switch statement
CFL#002 Checked automatically with code checker All switch statements shall have a default label as the last case label
CFL#003 Checked automatically with code checker An else sub-statement of an if statement shall not be an if statement without an else part
CFL#004 Checked automatically with code checker Do not use goto
CFL#005 Checked automatically with code checker Do not access a modified object more than once in an expression
CFL#006 Checked automatically with code checker Do not apply sizeof to an expression with side-effects
CFL#007 Checked automatically with code checker Do not change a loop variable inside a for loop block
CFL#008 Checked automatically with code checker Always use inclusive lower limits and exclusive upper limits
CFL#009 Checked automatically with code checker Never use continue in a nested loop
CFL#010 Checked automatically with code checker Never use break to exit a loop
CFL#011 Checked automatically with code checker The test condition in control statements shall be a non-assignment expression
CFL#012 Update loop variables close to where the loop condition is specified
CFL#013 Checked automatically with code checker All flow control primitives (if, else, while, for, do, switch) shall be followed by a block, even if it is empty
CFL#014 Checked automatically with code checker Do not return from unexpected locations
CFL#015 Checked automatically with code checker The definition of a void function shall not end with a return statement
CFL#016 Checked automatically with code checker Do not have overly complex functions
CFL#017 Checked automatically with code checker Do not make explicit comparisons to true or false
CFL#018 Checked automatically with code checker Use range-based for loops instead of iterators
CFL#019 Checked automatically with code checker Use explicit parentheses when using multiple different operators in an expression
CFL#020 Checked automatically with code checker Control should not reach the end of a non-void function without returning a value
CFL#021 Checked automatically with code checker Use prefix instead of postfix versions of ++ and -- operators for non-simple types
CFL#022 Checked automatically with code checker Apply sizeof to an object rather than to its type
CFL#023 Do not use selection statements (if, switch) instead of a simple assignment or initialization
CFL#024 Checked automatically with code checker A statement must have a side-effect, i.e., it must do something.