"+type);}// test resulttype->longtype->Stringtype->Integertype->!unknownSymbol!type->!unknownSymbol!Why?..." />

sonar custom rule check java collection type is unknownSymbol

Collection type always return 'unknownSymbol' in a custom sonar check rule class.

//demo class

public class SaasConstantNameCheckCase {

private static final long serialVersionUID;

private final String title;

public static final Integer maxSize = 1111;// Noncompliant

private static List list = new ArrayList<>();

private static HashMap map = new HashMap<>();

}

// custom rule class

@Override

public void visitVariable(VariableTree tree) {

VariableSymbol symbol = (VariableSymbol) tree.symbol();

String type = symbol.type().name();

System.out.println("type->"+type);

}

// test result

type->long

type->String

type->Integer

type->!unknownSymbol!

type->!unknownSymbol!

Why?...

Read More »

By: StackOverFlow - Tuesday, 20 November

Related Posts