Class ComplexityCounter
java.lang.Object
org.ek9lang.compiler.phase5.ComplexityCounter
Designed to give a broad indication of complexity, this is not true pure Cyclometric Complexity.
But it works on a region or code structure approach, looking at anything that may contribute to code
being harder to read or taking more thought than just a simple sequence of statements.
It takes into account boolean expressions, exception blocks and case statement for example.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne popped region: its total complexity, and how much of that came from expressions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidincrementComplexity(int byValue) voidincrementComplexity(AtomicInteger byValue) voidincrementExpressionComplexity(int byValue) Record thatbyValueof the current region's complexity came from an EXPRESSION.booleanisEmpty()True if stack has no contents.peek()Take a look at the top of the stack.pop()Pop a region off the stack, returning BOTH its total complexity and the expression-complexity subtotal within it.push()Push a zero value on to this stack.push(int initialValue) Push a zero value on to this stack.
-
Constructor Details
-
ComplexityCounter
ComplexityCounter()
-
-
Method Details
-
push
Push a zero value on to this stack. -
push
Push a zero value on to this stack. -
peek
Take a look at the top of the stack. -
pop
Pop a region off the stack, returning BOTH its total complexity and the expression-complexity subtotal within it. Exception if empty.Returns both together on purpose: a separate
popExpressionComplexity()would be an ordering hazard at the one call site, and the two stacks must be popped as a unit. -
incrementComplexity
public void incrementComplexity() -
incrementComplexity
-
incrementComplexity
public void incrementComplexity(int byValue) -
incrementExpressionComplexity
public void incrementExpressionComplexity(int byValue) Record thatbyValueof the current region's complexity came from an EXPRESSION.Does NOT add to the total - the caller has already done that through
incrementComplexity(int). This only retains the breakdown, which was previously lost. -
isEmpty
public boolean isEmpty()True if stack has no contents.
-