### Question:
MetricVisitor extends TreeVisitor<InputFileContext> { public int numberOfClasses() { return numberOfClasses; } 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; }### Answer:
@Test public void classes() throws Exception { scan("" + "x + 1;\n" + "x = true || false;"); assertThat(visitor.numberOfClasses()).isEqualTo(0); scan("" + "class C {}\n" + "fun function() {}\n" + "class D { int val x = 0; }\n" + "class E {\n" + " fun doSomething(int x) {}\n" + "}"); assertThat(visitor.numberOfClasses()).isEqualTo(3); }