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".isEmpty()).isTrue();
-  assertThat("bar".length()).isEqualTo(0L);
-  assertThat("baz".length()).isNotPositive();
+  assertThat("foo").isEmpty();
+  assertThat("bar").isEmpty();
+  assertThat("baz").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".isEmpty()).isFalse(),
-      assertThat("bar".length()).isNotEqualTo(0),
-      assertThat("baz".length()).isPositive());
+      assertThat("foo").isNotEmpty(),
+      assertThat("bar").isNotEmpty(),
+      assertThat("baz").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-2024 Picnic Technologies BV