diff --git a/README.md b/README.md index b508f40..09253b2 100644 --- a/README.md +++ b/README.md @@ -564,6 +564,10 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo ## Changelog +#### V1.6 (unreleased) +- Really fixed AssertThatGuavaOptional inspections to avoid conversions from ```.get()``` to ```.contains()``` + for array types. Sigh. Shouldn't be working >12h a day and then do some more stuff at home. + #### V1.5 (24-Sep-19) - Fix for AssertThatCollectionOrMap inspection sometimes causing an index out of bounds exception. - AssertThatGuavaOptional inspections will now avoid conversions from ```.get()``` to ```.contains()``` diff --git a/build.gradle b/build.gradle index 8e40a03..e59ae61 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group 'de.platon42' -version '1.5' +version '1.6' repositories { mavenCentral() @@ -43,16 +43,10 @@ intellij { patchPluginXml { changeNotes """ -
Full changelog available at Github project site.
""" diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatCollectionOrMapExpressionInspection.kt b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatCollectionOrMapExpressionInspection.kt index 155feee..51c9d0e 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatCollectionOrMapExpressionInspection.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatCollectionOrMapExpressionInspection.kt @@ -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)", diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt index 66ba8ca..ec42c1d 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt @@ -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 -> diff --git a/src/test/resources/inspections/GuavaOptional/GuavaOptionalAfter.java b/src/test/resources/inspections/GuavaOptional/GuavaOptionalAfter.java index 73fe5e3..54dae6b 100644 --- a/src/test/resources/inspections/GuavaOptional/GuavaOptionalAfter.java +++ b/src/test/resources/inspections/GuavaOptional/GuavaOptionalAfter.java @@ -73,6 +73,8 @@ public class GuavaOptional { assertThat(opt.orNull()).as("foo").isEqualTo(null).isNotNull(); + assertThat(Optional.of(new byte[] { 2, 3 }).get()).isEqualTo(new byte[] { 2, 3 }); // not working with assertj-guava 3.2.1 + org.junit.Assert.assertThat(opt, null); fail("oh no!"); } diff --git a/src/test/resources/inspections/GuavaOptional/GuavaOptionalBefore.java b/src/test/resources/inspections/GuavaOptional/GuavaOptionalBefore.java index 941955d..b91f641 100644 --- a/src/test/resources/inspections/GuavaOptional/GuavaOptionalBefore.java +++ b/src/test/resources/inspections/GuavaOptional/GuavaOptionalBefore.java @@ -73,6 +73,8 @@ public class GuavaOptional { assertThat(opt.orNull()).as("foo").isEqualTo(null).isNotNull(); + assertThat(Optional.of(new byte[] { 2, 3 }).get()).isEqualTo(new byte[] { 2, 3 }); // not working with assertj-guava 3.2.1 + org.junit.Assert.assertThat(opt, null); fail("oh no!"); }