AssertJEnumerableRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. EnumerableAssertIsEmpty
  2. EnumerableAssertIsNotEmpty
  3. EnumerableAssertHasSameSizeAs

EnumerableAssertIsEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 void testEnumerableAssertIsEmpty() {
-    assertThat(ImmutableSet.of()).hasSize(0);
-    assertThat(ImmutableSet.of()).hasSizeLessThanOrEqualTo(0);
-    assertThat(ImmutableSet.of()).hasSizeLessThan(1);
+    assertThat(ImmutableSet.of()).isEmpty();
+    assertThat(ImmutableSet.of()).isEmpty();
+    assertThat(ImmutableSet.of()).isEmpty();
   }

EnumerableAssertIsNotEmpty

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<EnumerableAssert<?, Character>> testEnumerableAssertIsNotEmpty() {
-    return ImmutableSet.of(
-        assertThat("foo").hasSizeGreaterThan(0), assertThat("bar").hasSizeGreaterThanOrEqualTo(1));
+    return ImmutableSet.of(assertThat("foo").isNotEmpty(), assertThat("bar").isNotEmpty());
   }

EnumerableAssertHasSameSizeAs

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<EnumerableAssert<?, Integer>> testEnumerableAssertHasSameSizeAs() {
     return ImmutableSet.of(
-        assertThat(ImmutableSet.of(1)).hasSize(Iterables.size(ImmutableSet.of(2))),
-        assertThat(ImmutableSet.of(3)).hasSize(ImmutableSet.of(4).size()),
-        assertThat(ImmutableSet.of(5)).hasSize(new Integer[0].length));
+        assertThat(ImmutableSet.of(1)).hasSameSizeAs(ImmutableSet.of(2)),
+        assertThat(ImmutableSet.of(3)).hasSameSizeAs(ImmutableSet.of(4)),
+        assertThat(ImmutableSet.of(5)).hasSameSizeAs(new Integer[0]));
   }

Copyright © 2017-2024 Picnic Technologies BV