diff --git a/README.md b/README.md index 5635f06..0865711 100644 --- a/README.md +++ b/README.md @@ -642,6 +642,9 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo ## Changelog +#### V1.7 (unreleased) +- Fixed a lapsuus in AssertThatFileExpression also transforming ```.listFiles()``` with a filter argument. + #### V1.6 (30-Sep-19) - 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. diff --git a/build.gradle b/build.gradle index 346be50..1cb6205 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group 'de.platon42' -version '1.6' +version '1.7' repositories { mavenCentral() @@ -35,7 +35,7 @@ compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } intellij { - version '2019.2.3' + version '2019.2.4' // pluginName 'Concise AssertJ Optimizing Nitpicker (Cajon)' updateSinceUntilBuild false plugins = ['java'] @@ -43,16 +43,9 @@ intellij { patchPluginXml { changeNotes """ -
Full changelog available at Github project site.
""" diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatFileExpressionInspection.kt b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatFileExpressionInspection.kt index ab86679..cac70e6 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatFileExpressionInspection.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatFileExpressionInspection.kt @@ -17,56 +17,56 @@ class AssertThatFileExpressionInspection : AbstractMoveOutInspection() { private val MAPPINGS = listOf( MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canRead"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canRead").parameterCount(0), "canRead", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canWrite"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canWrite").parameterCount(0), "canWrite", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "exists"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "exists").parameterCount(0), "exists", "doesNotExist", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isAbsolute"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isAbsolute").parameterCount(0), "isAbsolute", "isRelative", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isDirectory"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isDirectory").parameterCount(0), "isDirectory", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isFile"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "isFile").parameterCount(0), "isFile", expectBoolean = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getName"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getName").parameterCount(0), "hasName", expectedMatcher = CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING) ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParent", "getParentFile"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParent", "getParentFile").parameterCount(0), "hasNoParent", expectNullNonNull = true ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParent"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParent").parameterCount(0), "hasParent", expectedMatcher = CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING) ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParentFile"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getParentFile").parameterCount(0), "hasParent", expectedMatcher = IS_EQUAL_TO_OBJECT ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0), "isEmptyDirectory", expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_EMPTY) .parameterCount(0)!! ), MoveOutMapping( - CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles"), + CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0), "isNotEmptyDirectory", expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_NOT_EMPTY) .parameterCount(0)!! diff --git a/src/test/resources/inspections/FileExpression/FileExpressionAfter.java b/src/test/resources/inspections/FileExpression/FileExpressionAfter.java index 7df21fc..9433649 100644 --- a/src/test/resources/inspections/FileExpression/FileExpressionAfter.java +++ b/src/test/resources/inspections/FileExpression/FileExpressionAfter.java @@ -80,6 +80,11 @@ public class FileExpression { assertThat(file).isEmptyDirectory(); assertThat(file).isNotEmptyDirectory(); + assertThat(file.listFiles(f -> f.canExecute())).isNull(); + assertThat(file.listFiles(f -> f.canExecute())).isNullOrEmpty(); + assertThat(file.listFiles(f -> f.canExecute())).isEmpty(); + assertThat(file.listFiles(f -> f.canExecute())).isNotEmpty(); + assertThat(file.list()).isNull(); assertThat(file.list()).isNullOrEmpty(); assertThat(file).isEmptyDirectory(); diff --git a/src/test/resources/inspections/FileExpression/FileExpressionBefore.java b/src/test/resources/inspections/FileExpression/FileExpressionBefore.java index 1af703f..88176ce 100644 --- a/src/test/resources/inspections/FileExpression/FileExpressionBefore.java +++ b/src/test/resources/inspections/FileExpression/FileExpressionBefore.java @@ -80,6 +80,11 @@ public class FileExpression { assertThat(file.listFiles()).isEmpty(); assertThat(file.listFiles()).isNotEmpty(); + assertThat(file.listFiles(f -> f.canExecute())).isNull(); + assertThat(file.listFiles(f -> f.canExecute())).isNullOrEmpty(); + assertThat(file.listFiles(f -> f.canExecute())).isEmpty(); + assertThat(file.listFiles(f -> f.canExecute())).isNotEmpty(); + assertThat(file.list()).isNull(); assertThat(file.list()).isNullOrEmpty(); assertThat(file.list()).isEmpty();