Really fixed AssertThatGuavaOptional inspections to avoid conversions from .get() to .contains() for array types.

This commit is contained in:
2019-09-25 18:38:35 +02:00
parent e3444db213
commit 2b97494c17
6 changed files with 14 additions and 12 deletions
@@ -108,7 +108,7 @@ class AssertThatCollectionOrMapExpressionInspection : AbstractAssertJInspection(
expectedCallExpression,
assertThatArgument,
MethodNames.DOES_NOT_CONTAIN_KEY + "/" + MethodNames.CONTAINS_ENTRY
) { desc ->
) { _ ->
listOf(
MoveOutMethodCallExpressionQuickFix(
"Remove get() of actual expression and use assertThat().doesNotContainKey() instead (regular map)",
@@ -29,7 +29,7 @@ class AssertThatGuavaOptionalInspection : AbstractAssertJInspection() {
val actualExpression = staticMethodCall.firstArg as? PsiMethodCallExpression ?: return
val outmostMethodCall = statement.findOutmostMethodCall() ?: return
if (GUAVA_OPTIONAL_GET.test(actualExpression)) {
if (actualExpression.resolveMethod()?.returnType is PsiArrayType) return
if (actualExpression.type is PsiArrayType) return
val expectedCallExpression = staticMethodCall.gatherAssertionCalls().singleOrNull() ?: return
if (CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING).test(expectedCallExpression)) {
registerMoveOutMethod(holder, outmostMethodCall, actualExpression, MethodNames.CONTAINS) { desc, method ->