IDEA-134841 (Inspection: Misordered 'assertEquals' does not consider null as a literal)

This commit is contained in:
Bas Leijdekkers
2014-12-29 13:26:42 +01:00
parent 42980624be
commit 2e01fac022
3 changed files with 4 additions and 1 deletions
@@ -188,7 +188,7 @@ public abstract class MisorderedAssertEqualsArgumentsInspectionBase extends Base
}
private boolean looksLikeExpectedArgument(PsiExpression expression) {
if (ExpressionUtils.computeConstantExpression(expression) != null) {
if (ExpressionUtils.computeConstantExpression(expression) != null || PsiType.NULL.equals(expression.getType())) {
return true;
}
if (expression instanceof PsiReferenceExpression) {
@@ -19,6 +19,8 @@ class Simple {
TimeUnit timeUnit = TimeUnit.HOURS;
Assert.<warning descr="Arguments to 'assertEquals()' in wrong order">assertEquals</warning>(timeUnit, TimeUnit.HOURS);
Assert.<warning descr="Arguments to 'assertEquals()' in wrong order">assertEquals</warning>(test, map);
Assert.<warning descr="Arguments to 'assertEquals()' in wrong order">assertEquals</warning><error descr="'assertEquals(java.lang.String, long, long)' in 'org.junit.Assert' cannot be applied to '(java.lang.String, java.lang.Object, null)'">("message", new Object(), null)</error>;
return null;
}
}
@@ -31,6 +31,7 @@ public class MisorderedAssertEqualsParametersInspectionTest extends LightInspect
"package org.junit;" +
"public class Assert {" +
" static public void assertEquals(long expected, long actual) {}" +
" static public void assertEquals(String message, long expected, long actual) {}" +
" static public void assertEquals(Object expected, Object actual){}" +
" static public void assertSame(Object expected, Object actual) {}" +
"}",