Fixed a lapsuus in AssertThatFileExpression also transforming listFiles() with a filter argument.
This commit is contained in:
parent
2f0d855d1e
commit
8d03b3734c
@ -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.
|
||||
|
15
build.gradle
15
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 """
|
||||
<h4>V1.6 (30-Sep-19)</h4>
|
||||
<h4>V1.7 (unreleased)</h4>
|
||||
<ul>
|
||||
<li>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.
|
||||
<li>Fixed a bug in AssertThatBinaryExpression inspection for assertThat(null != expression) and related
|
||||
that would not correctly invert the condition on transformation.
|
||||
<li>Added new AssertThatFileExpression to move out many common methods from inside the
|
||||
assertThat() expression (exists(), getName(), getParent() and many more).
|
||||
<li>Added several transformations to AssertThatStringExpression inspection.
|
||||
Specifically, uses of matches(), compareToIgnoreCase(), indexOf(), and trim().
|
||||
<li>Fixed a lapsuus in AssertThatFileExpression also transforming listFiles() with a filter argument.
|
||||
</ul>
|
||||
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
|
||||
"""
|
||||
|
@ -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)!!
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user