@Test public void nesting_with_classes() { assertThat(complexity("class A { if (x) a && b; }").value()).isEqualTo(2); assertThat(complexity("class A { fun foo() { if (x) a && b; } }").value()).isEqualTo(2); assertThat(complexity("class A { fun foo() { fun bar() { if (x) a && b; } } }").value()).isEqualTo(3); assertThat(complexity("class A { fun foo() { class B { fun bar() { if (x) a && b; } } } }").value()).isEqualTo(2); assertThat(complexity("class A { fun foo() { if (x) a && b; class B { fun bar() { if (x) a && b; } } } }").value()).isEqualTo(4); }
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();  }