AssertJIterableRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatIterableIsEmpty
  2. AssertThatIterableIsNotEmpty
  3. AssertThatIterableSize
  4. AssertThatIterableHasOneElementEqualTo

AssertThatIterableIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testAssertThatIterableIsEmpty() {
-  assertThat(ImmutableSet.of(1).iterator()).isExhausted();
-  assertThat(ImmutableSet.of(2).isEmpty()).isTrue();
+  assertThat(ImmutableSet.of(1)).isEmpty();
+  assertThat(ImmutableSet.of(2)).isEmpty();
 }

AssertThatIterableIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIterableIsNotEmpty() {
   return ImmutableSet.of(
-      assertThat(ImmutableSet.of(1).iterator()).hasNext(),
-      assertThat(ImmutableSet.of(2).isEmpty()).isFalse());
+      assertThat(ImmutableSet.of(1)).isNotEmpty(), assertThat(ImmutableSet.of(2)).isNotEmpty());
 }

AssertThatIterableSize

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractIntegerAssert<?>> testAssertThatIterableSize() {
   return ImmutableSet.of(
-      assertThat(Iterables.size(ImmutableSet.of(1))), assertThat(ImmutableSet.of(2).size()));
+      assertThat(ImmutableSet.of(1)).size(), assertThat(ImmutableSet.of(2)).size());
 }

AssertThatIterableHasOneElementEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIterableHasOneElementEqualTo() {
-  return assertThat(Iterables.getOnlyElement(ImmutableSet.of(new Object()))).isEqualTo("foo");
+  return assertThat(ImmutableSet.of(new Object())).containsExactly("foo");
 }

Copyright © 2017-2024 Picnic Technologies BV