@Test public void ternary_operator() { assertThat(complexity("v = if (x) 42 else 43;").value()).isEqualTo(1); assertThat(complexity("v = if (x) 42 else if (y) 43 else 44;").value()).isEqualTo(3); assertThat(complexity("v = if (x) (if (y) 42 else 43) else 44;").value()).isEqualTo(3); assertThat(complexity("v = if (x) 42 else (if (y) 43 else 44);").value()).isEqualTo(3); assertThat(complexity("v = if (x) (if (y) 42 else 43) else (if (y) 44 else 45);").value()).isEqualTo(5); assertThat(complexity("v = if (x) if (y) if (z) 42 else 43 else 44 else 45;").value()).isEqualTo(6); assertThat(complexity("v = if (x) (if (y) (if (z) 42 else 43) else 44) else 45;").value()).isEqualTo(6); }
public int value() { int total = 0; for (Increment increment : increments) { total += increment.nestingLevel + 1; } return total; }
CognitiveComplexity { public int value() { int total = 0; for (Increment increment : increments) { total += increment.nestingLevel + 1; } return total; } }
CognitiveComplexity { public int value() { int total = 0; for (Increment increment : increments) { total += increment.nestingLevel + 1; } return total; } CognitiveComplexity(Tree root); }
CognitiveComplexity { public int value() { int total = 0; for (Increment increment : increments) { total += increment.nestingLevel + 1; } return total; } CognitiveComplexity(Tree root); int value(); List<Increment> increments(); }
CognitiveComplexity { public int value() { int total = 0; for (Increment increment : increments) { total += increment.nestingLevel + 1; } return total; } CognitiveComplexity(Tree root); int value(); List<Increment> increments();  }