private void visit(Tree tree) { boolean isSubscribed = isSubscribed(tree); if(isSubscribed) { visitNode(tree); } visitChildren(tree); if(isSubscribed) { leaveNode(tree); } }
/** {@inheritDoc} */ @Override public void createFileViolation(CodeCheck check, String message, Object... messageParameters) { createLineViolation(check, message, -1, messageParameters); }
protected void scanTree(Tree tree) { nodesToVisit = nodesToVisit(); visitToken = isVisitingTokens(); visitTrivia = isVisitingTrivia(); visit(tree); }
private static int getNumberOfLines(Tree tree) { return new LinesOfCodeVisitor().linesOfCode(tree); } }
protected void scanTree(Tree tree) { nodesToVisit = nodesToVisit(); visit(tree); }
private static boolean isPublicApi(ClassTree classTree) { return isPublicApi(null, classTree); }
public static Result methodComplexity(MethodTree methodTree) { if (shouldAnalyzeMethod(methodTree)) { CognitiveComplexityVisitor visitor = new CognitiveComplexityVisitor(); methodTree.accept(visitor); return new Result(visitor.complexity, visitor.locations); } return Result.empty(); }
@Override public int getComplexity(Tree tree) { return complexityVisitor.scan(tree); }
private void popTillSourceProject() { while (!(peekSourceCode() instanceof SourceProject)) { popSourceCode(); } }
public DefaultJavaFileScannerContext(CompilationUnitTree tree, SourceFile sourceFile, File file, SemanticModel semanticModel, boolean analyseAccessors) { this.tree = tree; this.sourceFile = sourceFile; this.file = file; this.semanticModel = semanticModel; this.complexityVisitor = new ComplexityVisitor(analyseAccessors); }
@Override public List<Tree> getComplexityNodes(Tree tree) { return complexityVisitor.getNodes(tree); }
public Measurer(Project project, SensorContext context, boolean separateAccessorsFromMethods) { this.project = project; this.sensorContext = context; this.separateAccessorsFromMethods = separateAccessorsFromMethods; accessorVisitor = new AccessorVisitor(); }
private void highlight(Tree tree, TypeOfText typeOfText) { highlight(tree, tree, typeOfText); }
private void increaseComplexityByOne(Tree tree) { increaseComplexity(tree, 1); }
public void setFile(File file) { popTillSourceProject(); this.file = file; }
public static Result methodComplexity(MethodTree methodTree) { if (shouldAnalyzeMethod(methodTree)) { CognitiveComplexityVisitor visitor = new CognitiveComplexityVisitor(); methodTree.accept(visitor); return new Result(visitor.complexity, visitor.locations); } return Result.empty(); }
@Override public int getMethodComplexity(ClassTree enclosingClass, MethodTree methodTree) { return complexityVisitor.scan(enclosingClass, methodTree); }
@Override public List<Tree> getComplexityNodes(Tree tree) { return complexityVisitor.getNodes(tree); }
private PublicApiChecker(boolean separateAccessorsFromMethods) { this.separateAccessorsFromMethods = separateAccessorsFromMethods; this.accessorVisitor = new AccessorVisitor(); }
@Override public List<Tree> getMethodComplexityNodes(ClassTree enclosingClass, MethodTree methodTree) { return complexityVisitor.scan(enclosingClass, methodTree); }