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

AssertJCharSequenceRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatCharSequenceIsEmpty
  2. AssertThatCharSequenceIsNotEmpty
  3. AssertThatCharSequenceHasSize

AssertThatCharSequenceIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatCharSequenceIsEmpty() {
-    assertThat("foo".length()).isEqualTo(0L);
-    assertThat("foo".length()).isNotPositive();
+    assertThat("foo").isEmpty();
+    assertThat("foo").isEmpty();
   }

AssertThatCharSequenceIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatCharSequenceIsNotEmpty() {
-    return ImmutableSet.of(
-        assertThat("foo".length()).isNotEqualTo(0), assertThat("bar".length()).isPositive());
+    return ImmutableSet.of(assertThat("foo").isNotEmpty(), assertThat("bar").isNotEmpty());
   }

AssertThatCharSequenceHasSize

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatCharSequenceHasSize() {
-    return assertThat("foo".length()).isEqualTo(3);
+    return assertThat("foo").hasSize(3);
   }

Copyright © 2017-2023 Picnic Technologies BV