mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
[Java. Tests. JUnit] IDEA-318937 False positive 'Java | Test frameworks | Misordered 'assertEquals()' arguments'.
GitOrigin-RevId: e50be17593b3dffec389a314b3c9e4849ccedd6e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3b3c2ecaed
commit
751962686d
@@ -78,7 +78,7 @@ public class MisorderedAssertEqualsArgumentsInspection extends BaseInspection {
|
||||
return AssertHint.create(expression, methodName -> methodNames.contains(methodName) ? 2 : null);
|
||||
}
|
||||
|
||||
static boolean looksLikeExpectedArgument(PsiExpression expression) {
|
||||
static boolean looksLikeExpectedArgument(PsiExpression expression, ParameterPosition parameterPosition) {
|
||||
if (expression == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -134,6 +134,11 @@ public class MisorderedAssertEqualsArgumentsInspection extends BaseInspection {
|
||||
}
|
||||
expressions.add(definition);
|
||||
}
|
||||
else if (target instanceof PsiMethod method && parameterPosition == ParameterPosition.ACTUAL) {
|
||||
if (!"expected".equals(method.getName())) {
|
||||
expectedArgument.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
if (!(target instanceof PsiCompiledElement)) {
|
||||
expectedArgument.set(Boolean.FALSE);
|
||||
}
|
||||
@@ -157,10 +162,16 @@ public class MisorderedAssertEqualsArgumentsInspection extends BaseInspection {
|
||||
if (hint == null) {
|
||||
return;
|
||||
}
|
||||
if (looksLikeExpectedArgument(hint.getExpected()) || !looksLikeExpectedArgument(hint.getActual())) {
|
||||
if (looksLikeExpectedArgument(hint.getExpected(), ParameterPosition.EXPECTED) ||
|
||||
!looksLikeExpectedArgument(hint.getActual(), ParameterPosition.ACTUAL)) {
|
||||
return;
|
||||
}
|
||||
registerMethodCallError(expression);
|
||||
}
|
||||
}
|
||||
|
||||
private enum ParameterPosition {
|
||||
EXPECTED,
|
||||
ACTUAL
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user