Number of linearly independent paths in function body
This metric calculates the number of decision points in a function and adds one to the total. A decision point is a statement that causes your program to branch into two paths.
The recommended upper limit for this metric is 10. If the cyclomatic complexity is high, the code is both difficult to read and can cause more orange checks. Therefore, try to limit the value of this metric.
To enforce limits on metrics, see Compute Code Complexity Metrics.
The metric calculation uses the following rules to identify decision points:
An if statement is one decision point.
The statements for and while
count as one decision point, even when no condition is evaluated, for
example, in infinite loops.
Boolean combinations (&&, ||) do not count
as decision points.
case statements do not count as decision points
unless they are followed by a break statement. For
instance, this code has a cyclomatic complexity of two:
switch(num) {
case 0:
case 1:
case 2:
break;
case 3:
case 4:
}
The calculation is done after preprocessing:
Macros are expanded.
Conditional compilation is applied. The blocks hidden by preprocessing directives are ignored.
| Group: Function |
Acronym: VG |
| HIS Metric: Yes |