public final class CycloMetric extends AbstractMetric implements ClassMetric, OperationMetric
CYCLO = e - n + 2p [2]. In practice it can be calculated by counting control flow
statements following the standard rules given below.
The standard version of the metric complies with McCabe's original definition:
if, case, catch, finally, do, while, for, break, continue) and
conditional expression (? : ). Notice switch cases count as one, but not the switch itself: the point is
that a switch should have the same complexity value as the equivalent series of if statements.
else and default don't count;
Version CycloMetric.Version.IGNORE_BOOLEAN_PATHS: Boolean operators are not counted, which means that empty
fall-through cases in switch statements are not counted as well.
References:
| Modifier and Type | Class and Description |
|---|---|
static class |
CycloMetric.Version
Variants of CYCLO.
|
| Constructor and Description |
|---|
CycloMetric() |
| Modifier and Type | Method and Description |
|---|---|
double |
computeFor(ASTClassOrInterfaceDeclaration node,
MetricVersion version)
Actually computes the value of a metric for an AST node.
|
double |
computeFor(ASTMethodOrConstructorDeclaration node,
MetricVersion version)
Actually computes the value of a metric for an AST node.
|
averageMetricOverOperations, findAllCalls, findOperations, getTopLevelPackageStats, highestMetricOverOperations, sumMetricOverOperations, supportspublic double computeFor(ASTClassOrInterfaceDeclaration node, MetricVersion version)
ClassMetriccomputeFor in interface ClassMetricnode - The node.version - The version of the metric.public double computeFor(ASTMethodOrConstructorDeclaration node, MetricVersion version)
OperationMetriccomputeFor in interface OperationMetricnode - The node.version - The version of the metric.Copyright © 2002–2017 PMD. All rights reserved.