@Test public void cognitiveComplexity() throws Exception { scan("" + "class A { fun foo() { if(1 != 1) 1; } }" + "fun function() {" + " if (1 != 1) {" + " if (1 != 1) {" + " 1" + " }" + " };" + " class B {" + " fun bar(int a) {" + " match(a) {" + " 1 -> doSomething();" + " 2 -> doSomething();" + " else -> if (1 != 1) doSomething();" + " }" + " }" + " };" + "}"); assertThat(visitor.cognitiveComplexity()).isEqualTo(7); }
public int cognitiveComplexity() { return cognitiveComplexity; }
MetricVisitor extends TreeVisitor<InputFileContext> { public int cognitiveComplexity() { return cognitiveComplexity; } }
MetricVisitor extends TreeVisitor<InputFileContext> { public int cognitiveComplexity() { return cognitiveComplexity; } MetricVisitor(FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter); }
MetricVisitor extends TreeVisitor<InputFileContext> { public int cognitiveComplexity() { return cognitiveComplexity; } MetricVisitor(FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter); static boolean isNosonarComment(Comment comment); Set<Integer> linesOfCode(); Set<Integer> commentLines(); Set<Integer> nosonarLines(); Set<Integer> executableLines(); int numberOfFunctions(); int numberOfClasses(); int cognitiveComplexity(); }
MetricVisitor extends TreeVisitor<InputFileContext> { public int cognitiveComplexity() { return cognitiveComplexity; } MetricVisitor(FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter); static boolean isNosonarComment(Comment comment); Set<Integer> linesOfCode(); Set<Integer> commentLines(); Set<Integer> nosonarLines(); Set<Integer> executableLines(); int numberOfFunctions(); int numberOfClasses(); int cognitiveComplexity(); static final String NOSONAR_PREFIX; }