Skip to main content Link Search Menu Expand Document (external link)

AssertJStringRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AbstractStringAssertStringIsEmpty
  2. AssertThatStringIsEmpty
  3. AbstractStringAssertStringIsNotEmpty
  4. AssertThatStringIsNotEmpty
  5. AssertThatMatches
  6. AssertThatDoesNotMatch

AbstractStringAssertStringIsEmpty

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AbstractStringAssertStringIsEmpty)) as compiler argument.

Samples

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

 void testAbstractStringAssertStringIsEmpty() {
-    assertThat("foo").isEqualTo("");
+    assertThat("foo").isEmpty();
   }

AssertThatStringIsEmpty

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AssertThatStringIsEmpty)) as compiler argument.

Samples

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

 void testAssertThatStringIsEmpty() {
-    assertThat("foo".isEmpty()).isTrue();
+    assertThat("foo").isEmpty();
   }

AbstractStringAssertStringIsNotEmpty

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AbstractStringAssertStringIsNotEmpty)) as compiler argument.

Samples

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

 AbstractStringAssert<?> testAbstractStringAssertStringIsNotEmpty() {
-    return assertThat("foo").isNotEqualTo("");
+    return assertThat("foo").isNotEmpty();
   }

AssertThatStringIsNotEmpty

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AssertThatStringIsNotEmpty)) as compiler argument.

Samples

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

 AbstractAssert<?, ?> testAssertThatStringIsNotEmpty() {
-    return assertThat("foo".isEmpty()).isFalse();
+    return assertThat("foo").isNotEmpty();
   }

AssertThatMatches

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AssertThatMatches)) as compiler argument.

Samples

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

 AbstractAssert<?, ?> testAssertThatMatches() {
-    return assertThat("foo".matches(".*")).isTrue();
+    return assertThat("foo").matches(".*");
   }

AssertThatDoesNotMatch

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(AssertJStringRules\.AssertThatDoesNotMatch)) as compiler argument.

Samples

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

 AbstractAssert<?, ?> testAssertThatDoesNotMatch() {
-    return assertThat("foo".matches(".*")).isFalse();
+    return assertThat("foo").doesNotMatch(".*");
   }

Copyright © 2017-2023 Picnic Technologies BV