Uast, Lint: Update and fix tests

This commit is contained in:
Yan Zhulanow
2016-04-06 19:53:11 +03:00
parent 21a2115501
commit c13c24becc
34 changed files with 1073 additions and 289 deletions
@@ -82,7 +82,7 @@ public class CipherGetInstanceDetector extends Detector implements UastScanner {
UExpression expression = argumentList.get(0);
if (expression instanceof ULiteralExpression) {
ULiteralExpression argument = (ULiteralExpression)expression;
String parameter = argument.asString();
String parameter = argument.renderString();
checkParameter(context, node, argument, parameter, false);
} else if (expression instanceof UResolvable) {
UDeclaration declaration = ((UResolvable)expression).resolve(context);
@@ -211,16 +211,22 @@ public class JavaPerformanceDetector extends Detector implements UastScanner {
}
if (mCheckValueOf) {
UType type = UastErrorType.INSTANCE;
if (typeName == null) {
typeName = classReference.getIdentifier();
UDeclaration resolvedDeclaration = classReference.resolve(mContext);
if (resolvedDeclaration instanceof UClass) {
type = ((UClass) resolvedDeclaration).getDefaultType();
typeName = type.getName();
}
}
if ((typeName.equals(INTEGER)
|| typeName.equals(BOOLEAN)
|| typeName.equals(FLOAT)
|| typeName.equals(CHARACTER)
|| typeName.equals(LONG)
|| typeName.equals(DOUBLE)
|| typeName.equals(BYTE))
if ((type.isInt()
|| type.isBoolean()
|| type.isFloat()
|| type.isChar()
|| type.isLong()
|| type.isDouble()
|| type.isShort()
|| type.isByte())
&& node.getValueArgumentCount() == 1) {
String argument = node.getValueArguments().get(0).renderString();
mContext.report(USE_VALUE_OF, node, mContext.getLocation(node), getUseValueOfErrorMessage(