beckhoff TE1200 — 4.4.1.13 Complexity (McCabe)

Configuration | Metrics c : INT := 100; // statements in the declaration are not counted END_VAR IF bVar THEN //if statement: +1 nTest := 0; // +1 END_IF WHILE nTest = 1 DO //while statement: +1 ; // empty statements do not add to the statement count END_WHILE FOR c := 0 TO 10 BY 2 DO //for statement: +1 i := i+i; // +1 END_FOR {text 'simple text pragma'} //pragmas are not counted nTest := 2; //+1 The sample has six statements. 4.4.1.12 Percentage of comment | Percentage of comment 4.4.1.13 Complexity (McCabe) | Complexity (McCabe) The following samples show how complexity is calculated according to McCabe. Sample:

IF statement // every POU has an initial cyclomatic complexity of 1, since it has at least 1 branch IF b1 THEN // +1 for the THEN branch ; ELSIF b2 THEN // +1 for the THEN branch of the IF inside the ELSE ; ELSE IF b3 OR b4 THEN // +1 for the THEN branch ; END_IF END_IF The code snippet has a cyclomatic complexity of 4. Sample: CASE statement TE1200 99 Version: 2.11.1 Title short form Comments Categories Maintainability Definition Percentage of comments in the source code This number is calculated using the following formula:

Percentage = 100 * / Further information Multiple consecutive spaces in the source code are counted as one space, which prevents a high weighting of indented source code. A percentage of 0 is returned for empty objects (no source code and no comments). The statements also include declaration statements, for example. Title short form McCabe Categories Testability Definition Number of binary branches in the control flow of the POU (for example, the number of branches for IF and CASE statements and loops) Further information McCabe's cyclomatic complexity is a measure of the readability and testability of source code.

It is calculated by counting the number of binary branches in the control flow of the POU. Cyclomatic complexity penalizes high branching because high branching increases the number of test cases required for high test coverage. Recommended upper limit 10