AssertJIterableRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$).*as compiler argument.
Table of contents
AssertThatIsEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsEmpty")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatIsEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatIsEmpty() {
- assertThat(ImmutableSet.of(1).iterator()).isExhausted();
- assertThat(ImmutableSet.of(2).isEmpty()).isTrue();
+ assertThat(ImmutableSet.of(1)).isEmpty();
+ assertThat(ImmutableSet.of(2)).isEmpty();
}AssertThatIsNotEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsNotEmpty")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatIsNotEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotEmpty() {
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());
}AssertThatSize
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatSize")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatSize).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractIntegerAssert<?>> testAssertThatSize() {
return ImmutableSet.of(
- assertThat(Iterables.size(ImmutableSet.of(1))), assertThat(ImmutableSet.of(2).size()));
+ assertThat(ImmutableSet.of(1)).size(), assertThat(ImmutableSet.of(2)).size());
}AssertThatContains
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatContains")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatContains).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatContains() {
- return assertThat(ImmutableSet.of(1).contains(1)).isTrue();
+ return assertThat(ImmutableSet.of(1)).contains(1);
}AssertThatDoesNotContain
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatDoesNotContain")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatDoesNotContain).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatDoesNotContain() {
- return assertThat(ImmutableSet.of(1).contains(1)).isFalse();
+ return assertThat(ImmutableSet.of(1)).doesNotContain(1);
}AssertThatContainsAll
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatContainsAll")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatContainsAll).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatContainsAll() {
- return assertThat(ImmutableSet.of(1).containsAll(ImmutableSet.of(2))).isTrue();
+ return assertThat(ImmutableSet.of(1)).containsAll(ImmutableSet.of(2));
}AssertThatContainsExactly
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatContainsExactly")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJIterableRules\$AssertThatContainsExactly).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatContainsExactly() {
- return assertThat(Iterables.getOnlyElement(ImmutableSet.of(new Object()))).isEqualTo("foo");
+ return assertThat(ImmutableSet.of(new Object())).containsExactly("foo");
}