Search in sources :

Example 1 with CheckerContext

use of org.sonar.java.se.CheckerContext in project sonar-java by SonarSource.

the class DebugMethodYieldsOnInvocationsCheck method reportAll.

private void reportAll(CheckerContext context) {
    CheckerDispatcher checkerDispatcher = (CheckerDispatcher) context;
    methodInvocations.pop().stream().filter(mit -> mit.symbol().isMethodSymbol()).forEach(mit -> reportYields(mit, checkerDispatcher));
}
Also used : ProgramState(org.sonar.java.se.ProgramState) Priority(org.sonar.check.Priority) CheckerDispatcher(org.sonar.java.se.CheckerDispatcher) Set(java.util.Set) Tree(org.sonar.plugins.java.api.tree.Tree) Deque(java.util.Deque) JavaFileScannerContext(org.sonar.plugins.java.api.JavaFileScannerContext) ArrayList(java.util.ArrayList) CheckerContext(org.sonar.java.se.CheckerContext) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) List(java.util.List) CFG(org.sonar.java.cfg.CFG) Flow(org.sonar.java.se.Flow) SECheck(org.sonar.java.se.checks.SECheck) MemberSelectExpressionTree(org.sonar.plugins.java.api.tree.MemberSelectExpressionTree) DebugCheck(org.sonar.java.DebugCheck) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) Rule(org.sonar.check.Rule) LinkedList(java.util.LinkedList) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree) Collections(java.util.Collections) Symbol(org.sonar.plugins.java.api.semantic.Symbol) MethodTree(org.sonar.plugins.java.api.tree.MethodTree) CheckerDispatcher(org.sonar.java.se.CheckerDispatcher)

Example 2 with CheckerContext

use of org.sonar.java.se.CheckerContext in project sonar-java by SonarSource.

the class NonNullSetToNullCheck method checkEndOfExecutionPath.

@Override
public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) {
    if (methodTree.is(Tree.Kind.CONSTRUCTOR) && !isDefaultConstructorForJpa(methodTree) && !callsThisConstructor(methodTree) && !exitingWithException(context)) {
        ClassTree classTree = (ClassTree) methodTree.parent();
        classTree.members().stream().filter(m -> m.is(Tree.Kind.VARIABLE)).map(m -> (VariableTree) m).filter(v -> v.initializer() == null).forEach(v -> checkVariable(context, methodTree, v.symbol()));
    }
}
Also used : ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint) JavaSymbol(org.sonar.java.resolve.JavaSymbol) ProgramState(org.sonar.java.se.ProgramState) ExpressionUtils(org.sonar.java.model.ExpressionUtils) NullableAnnotationUtils.nonNullAnnotation(org.sonar.java.se.NullableAnnotationUtils.nonNullAnnotation) MessageFormat(java.text.MessageFormat) CheckerContext(org.sonar.java.se.CheckerContext) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) VariableTree(org.sonar.plugins.java.api.tree.VariableTree) ConstraintManager(org.sonar.java.se.constraint.ConstraintManager) Lists(com.google.common.collect.Lists) SymbolMetadata(org.sonar.plugins.java.api.semantic.SymbolMetadata) MemberSelectExpressionTree(org.sonar.plugins.java.api.tree.MemberSelectExpressionTree) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) Nullable(javax.annotation.Nullable) Arguments(org.sonar.plugins.java.api.tree.Arguments) ReturnStatementTree(org.sonar.plugins.java.api.tree.ReturnStatementTree) ExpressionStatementTree(org.sonar.plugins.java.api.tree.ExpressionStatementTree) StatementTree(org.sonar.plugins.java.api.tree.StatementTree) Tree(org.sonar.plugins.java.api.tree.Tree) MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) NewClassTree(org.sonar.plugins.java.api.tree.NewClassTree) List(java.util.List) Stream(java.util.stream.Stream) CFG(org.sonar.java.cfg.CFG) AssignmentExpressionTree(org.sonar.plugins.java.api.tree.AssignmentExpressionTree) ClassTree(org.sonar.plugins.java.api.tree.ClassTree) Rule(org.sonar.check.Rule) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree) Symbol(org.sonar.plugins.java.api.semantic.Symbol) MethodTree(org.sonar.plugins.java.api.tree.MethodTree) NewClassTree(org.sonar.plugins.java.api.tree.NewClassTree) ClassTree(org.sonar.plugins.java.api.tree.ClassTree)

Aggregations

List (java.util.List)2 Rule (org.sonar.check.Rule)2 CFG (org.sonar.java.cfg.CFG)2 CheckerContext (org.sonar.java.se.CheckerContext)2 ProgramState (org.sonar.java.se.ProgramState)2 Symbol (org.sonar.plugins.java.api.semantic.Symbol)2 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)2 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)2 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)2 MethodInvocationTree (org.sonar.plugins.java.api.tree.MethodInvocationTree)2 MethodTree (org.sonar.plugins.java.api.tree.MethodTree)2 Tree (org.sonar.plugins.java.api.tree.Tree)2 Lists (com.google.common.collect.Lists)1 MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1