ComplexityVisitor extends BaseTreeVisitor { public int getComplexity() { return complexity; }  static int complexity(Tree pyTree); @Override void visitFunctionDef(FunctionDef pyFunctionDefTree); @Override void visitForStatement(ForStatement pyForStatementTree); @Override void visitWhileStatement(WhileStatement pyWhileStatementTree); @Override void visitIfStatement(IfStatement pyIfStatementTree); @Override void visitConditionalExpression(ConditionalExpression pyConditionalExpressionTree); @Override void visitBinaryExpression(BinaryExpression pyBinaryExpressionTree); @Override void visitComprehensionIf(ComprehensionIf tree); int getComplexity();  }
@Test public void file() { PythonVisitorContext context = TestPythonVisitorRunner.createContext(new File("src/test/resources/metrics/complexity.py")); context.rootTree().accept(visitor); assertThat(visitor.getComplexity()).isEqualTo(8); }