AssertJFileRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$).* as compiler argument.

Table of contents
  1. AssertThatExists
  2. AssertThatDoesNotExist
  3. AssertThatIsFile
  4. AssertThatIsDirectory
  5. AssertThatIsAbsolute
  6. AssertThatIsRelative
  7. AssertThatIsReadable
  8. AssertThatIsWritable
  9. AssertThatIsExecutable
  10. AssertThatHasFileName
  11. AssertThatHasParentFile
  12. AssertThatHasParentString
  13. AssertThatHasNoParent
  14. AssertThatHasExtension

AssertThatExists

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatExists") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatExists).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatExists() {
-  return assertThat(new File("foo").exists()).isTrue();
+  return assertThat(new File("foo")).exists();
 }

AssertThatDoesNotExist

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatDoesNotExist") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatDoesNotExist).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatDoesNotExist() {
-  return assertThat(new File("foo").exists()).isFalse();
+  return assertThat(new File("foo")).doesNotExist();
 }

AssertThatIsFile

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsFile") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsFile).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsFile() {
-  return assertThat(new File("foo").isFile()).isTrue();
+  return assertThat(new File("foo")).isFile();
 }

AssertThatIsDirectory

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsDirectory") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsDirectory).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsDirectory() {
-  return assertThat(new File("foo").isDirectory()).isTrue();
+  return assertThat(new File("foo")).isDirectory();
 }

AssertThatIsAbsolute

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsAbsolute") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsAbsolute).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsAbsolute() {
-  return assertThat(new File("foo").isAbsolute()).isTrue();
+  return assertThat(new File("foo")).isAbsolute();
 }

AssertThatIsRelative

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsRelative") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsRelative).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsRelative() {
-  return assertThat(new File("foo").isAbsolute()).isFalse();
+  return assertThat(new File("foo")).isRelative();
 }

AssertThatIsReadable

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsReadable") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsReadable).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsReadable() {
-  return assertThat(new File("foo").canRead()).isTrue();
+  return assertThat(new File("foo")).isReadable();
 }

AssertThatIsWritable

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsWritable") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsWritable).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsWritable() {
-  return assertThat(new File("foo").canWrite()).isTrue();
+  return assertThat(new File("foo")).isWritable();
 }

AssertThatIsExecutable

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatIsExecutable") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatIsExecutable).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatIsExecutable() {
-  return assertThat(new File("foo").canExecute()).isTrue();
+  return assertThat(new File("foo")).isExecutable();
 }

AssertThatHasFileName

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatHasFileName") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatHasFileName).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractAssert<?, ?> testAssertThatHasFileName() {
-  return assertThat(new File("foo").getName()).isEqualTo("bar");
+  return assertThat(new File("foo")).hasFileName("bar");
 }

AssertThatHasParentFile

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatHasParentFile") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatHasParentFile).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractFileAssert<?> testAssertThatHasParentFile() {
-  return assertThat(new File("foo").getParentFile()).isEqualTo(new File("bar"));
+  return assertThat(new File("foo")).hasParent(new File("bar"));
 }

AssertThatHasParentString

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatHasParentString") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatHasParentString).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 AbstractFileAssert<?> testAssertThatHasParentString() {
-  return assertThat(new File("foo").getParentFile()).hasFileName("bar");
+  return assertThat(new File("foo")).hasParent("bar");
 }

AssertThatHasNoParent

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatHasNoParent") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatHasNoParent).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 void testAssertThatHasNoParent() {
-  assertThat(new File("foo").getParent()).isNull();
+  assertThat(new File("foo")).hasNoParent();
 }

AssertThatHasExtension

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThatHasExtension") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!AssertJFileRules\$AssertThatHasExtension).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatHasExtension() {
   return ImmutableSet.of(
-      assertThat(new File("foo").getName()).endsWith('.' + "bar"),
-      assertThat(new File("baz").toString()).endsWith('.' + "qux"),
-      assertThat(new File("quux").getName()).endsWith("." + toString()),
-      assertThat(new File("corge").toString()).endsWith("." + getClass().toString()));
+      assertThat(new File("foo")).hasExtension("bar"),
+      assertThat(new File("baz")).hasExtension("qux"),
+      assertThat(new File("quux")).hasExtension(toString()),
+      assertThat(new File("corge")).hasExtension(getClass().toString()));
 }

Copyright © 2017-2025 Picnic Technologies BV