Search in sources :

Example 11 with LiteralTree

use of org.sonar.plugins.java.api.tree.LiteralTree in project sonar-java by SonarSource.

the class UnderscoreOnNumberCheck method visitNode.

@Override
public void visitNode(Tree tree) {
    LiteralTree literalTree = (LiteralTree) tree;
    String value = literalTree.value();
    if (!containsUnderscore(value) && !isSerialVersionUID(tree) && shouldUseUnderscore(value)) {
        reportIssue(literalTree, "Add underscores to this numeric value for readability");
    }
}
Also used : LiteralTree(org.sonar.plugins.java.api.tree.LiteralTree)

Example 12 with LiteralTree

use of org.sonar.plugins.java.api.tree.LiteralTree in project sonar-java by SonarSource.

the class WeakSSLContextCheck method visitNode.

@Override
public void visitNode(Tree tree) {
    if (hasSemantic()) {
        MethodInvocationTree mit = (MethodInvocationTree) tree;
        Arguments arguments = mit.arguments();
        if (SSLCONTEXT_GETINSTANCE_MATCHER.matches(mit)) {
            ExpressionTree firstArgument = arguments.get(0);
            if (firstArgument.is(Tree.Kind.STRING_LITERAL) && !STRONG_PROTOCOLS.contains(trimQuotes(((LiteralTree) firstArgument).value()))) {
                reportIssue(firstArgument, "Change this code to use a stronger protocol.");
            }
        }
    }
}
Also used : MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) Arguments(org.sonar.plugins.java.api.tree.Arguments) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) LiteralTree(org.sonar.plugins.java.api.tree.LiteralTree)

Aggregations

LiteralTree (org.sonar.plugins.java.api.tree.LiteralTree)12 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)7 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)4 MethodInvocationTree (org.sonar.plugins.java.api.tree.MethodInvocationTree)4 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)3 List (java.util.List)2 Map (java.util.Map)2 Rule (org.sonar.check.Rule)2 Symbol (org.sonar.plugins.java.api.semantic.Symbol)2 BinaryExpressionTree (org.sonar.plugins.java.api.tree.BinaryExpressionTree)2 Tree (org.sonar.plugins.java.api.tree.Tree)2 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 ImmutableList (com.google.common.collect.ImmutableList)1 Builder (com.google.common.collect.ImmutableList.Builder)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Multimap (com.google.common.collect.Multimap)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1