public MethodWithUsedVariables(MethodTree method) { this.method = method; method.accept(this); }
private static boolean hasCallToSuperWithRunnable(MethodTree constructor) { SuperRunnableVisitor visitor = new SuperRunnableVisitor(); constructor.accept(visitor); return visitor.callSuperWithRunnable; }
private static List<ReturnStatementTree> extractReturnStatements(MethodTree methodTree) { ReturnExtractor visitor = new ReturnExtractor(); methodTree.accept(visitor); return visitor.returns; } }
private static List<ReturnStatementTree> extractReturnStatements(MethodTree methodTree) { ReturnExtractor visitor = new ReturnExtractor(); methodTree.accept(visitor); return visitor.returns; } }
protected List<VariableTree> findInjectorsInMethod(MethodTree methodTree) { FindVariableDeclarationVisitor varVisitor = new FindVariableDeclarationVisitor(CLASS_INJECTOR_NAME); methodTree.accept(varVisitor); return varVisitor.getDeclarations(); }
@Override public void visitNode(Tree tree) { MethodTree methodTree = (MethodTree) tree; if (hasSemantic() && isFinalizeDeclaration(methodTree)) { methodTree.accept(new AssignmentVisitor()); } }
@Override public void visitNode(Tree tree) { MethodTree methodTree = (MethodTree) tree; if (hasSemantic() && isCompareToDeclaration(methodTree)) { methodTree.accept(new ReturnStatementVisitor()); } }
@Override public void visitNode(Tree tree) { MethodTree methodTree = (MethodTree) tree; if (hasSemantic() && isCompareToDeclaration(methodTree)) { methodTree.accept(new ReturnStatementVisitor()); } }
protected boolean checkIfLoggedOut(MethodTree method, VariableTree injector) { Set<IdentifierTree> usagesOfSession = Sets.newHashSet(injector.symbol().usages()); CheckLoggedOutVisitor checkLoggedOutVisitor = new CheckLoggedOutVisitor(usagesOfSession); FinallyBlockVisitor finallyBlockVisitor = new FinallyBlockVisitor(checkLoggedOutVisitor); method.accept(finallyBlockVisitor); return checkLoggedOutVisitor.isLoggedOut(); }
protected boolean checkIfInjectorIsClosedInMethod(MethodTree method, VariableTree injector) { Set<IdentifierTree> usagesOfInjector = Sets.newHashSet(injector.symbol().usages()); CheckClosedVisitor checkClosedVisitor = new CheckClosedVisitor(usagesOfInjector); FinallyBlockVisitor finallyBlockVisitor = new FinallyBlockVisitor(checkClosedVisitor); method.accept(finallyBlockVisitor); return checkClosedVisitor.isClosed(); }
@Override public void visitNode(Tree tree) { if (!hasSemantic()) { return; } MethodTree method = (MethodTree) tree; if (method.block() != null && INPUT_STREAM_READ.matches(method)) { method.accept(new ReturnStatementVisitor()); } }
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 void visitNode(Tree tree) { if(!hasSemantic()) { return; } MethodTree methodTree = (MethodTree) tree; if (!isAnnotatedWithCheckForNull(methodTree) && returnsBoolean(methodTree)) { methodTree.accept(new ReturnStatementVisitor()); } }
@Override public void visitNode(Tree tree) { if (!hasSemantic()) { return; } MethodTree method = (MethodTree) tree; if (method.block() != null && INPUT_STREAM_READ.matches(method)) { method.accept(new ReturnStatementVisitor()); } }
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 void visitNode(Tree tree) { if(!hasSemantic()) { return; } MethodTree methodTree = (MethodTree) tree; if (!isAnnotatedWithCheckForNull(methodTree) && returnsBoolean(methodTree)) { methodTree.accept(new ReturnStatementVisitor()); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { MethodTree methodTree = ExpressionUtils.getEnclosingMethod(mit); String getInstanceArg = ConstantUtils.resolveAsStringConstant(mit.arguments().get(0)); if (methodTree != null && getInstanceArg != null) { MethodVisitor methodVisitor = new MethodVisitor(getInstanceArg); methodTree.accept(methodVisitor); } }
@Override protected void onMethodInvocationFound(MethodInvocationTree mit) { MethodTree methodTree = ExpressionUtils.getEnclosingMethod(mit); String getInstanceArg = ConstantUtils.resolveAsStringConstant(mit.arguments().get(0)); if (methodTree != null && getInstanceArg != null) { MethodVisitor methodVisitor = new MethodVisitor(getInstanceArg); methodTree.accept(methodVisitor); } }
@Override public void visitMethod(MethodTree method) { if (!method.is(Tree.Kind.CONSTRUCTOR) && returnsOptional(method)) { // check that the method is not annotated with @Nullable checkNullableAnnotation(method.modifiers(), "Methods with an \"Optional\" return type should not be \"@Nullable\"."); // check that the method does not return "null" method.accept(new ReturnNullVisitor()); } super.visitMethod(method); }
@Override public void visitMethod(MethodTree method) { if (!method.is(Tree.Kind.CONSTRUCTOR) && returnsOptional(method)) { // check that the method is not annotated with @Nullable checkNullableAnnotation(method.modifiers(), "Methods with an \"Optional\" return type should not be \"@Nullable\"."); // check that the method does not return "null" method.accept(new ReturnNullVisitor()); } super.visitMethod(method); }