AssertJObjectRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$).*as compiler argument.
Table of contents
AssertThatIsInstanceOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsInstanceOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsInstanceOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatIsInstanceOf() {
- return assertThat("foo" instanceof String).isTrue();
+ return assertThat("foo").isInstanceOf(String.class);
}AssertThatIsInstanceOf2
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsInstanceOf2")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsInstanceOf2).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatIsInstanceOf2() {
- return assertThat(String.class.isInstance("foo")).isTrue();
+ return assertThat("foo").isInstanceOf(String.class);
}AssertThatIsNotInstanceOf
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsNotInstanceOf")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsNotInstanceOf).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatIsNotInstanceOf() {
- return assertThat("foo" instanceof String).isFalse();
+ return assertThat("foo").isNotInstanceOf(String.class);
}AssertThatIsIsEqualTo
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsIsEqualTo")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsIsEqualTo).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatIsIsEqualTo() {
- return assertThat("foo".equals("bar")).isTrue();
+ return assertThat("foo").isEqualTo("bar");
}AssertThatIsIsNotEqualTo
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsIsNotEqualTo")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsIsNotEqualTo).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatIsIsNotEqualTo() {
- return assertThat("foo".equals("bar")).isFalse();
+ return assertThat("foo").isNotEqualTo("bar");
}AssertThatHasToString
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatHasToString")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatHasToString).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatHasToString() {
- return assertThat(new Object().toString()).isEqualTo("foo");
+ return assertThat(new Object()).hasToString("foo");
}AssertThatIsSameAs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsSameAs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsSameAs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsSameAs() {
- return ImmutableSet.of(assertThat("foo" == "bar").isTrue(), assertThat(0 != 1).isFalse());
+ return ImmutableSet.of(assertThat("foo").isSameAs("bar"), assertThat(0).isSameAs(1));
}AssertThatIsNotSameAs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsNotSameAs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsNotSameAs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotSameAs() {
- return ImmutableSet.of(assertThat("foo" == "bar").isFalse(), assertThat(0 != 1).isTrue());
+ return ImmutableSet.of(assertThat("foo").isNotSameAs("bar"), assertThat(0).isNotSameAs(1));
}AssertThatIsNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsNull")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsNull).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testAssertThatIsNull() {
- assertThat("foo" == null).isTrue();
- assertThat("bar" != null).isFalse();
+ assertThat("foo").isNull();
+ assertThat("bar").isNull();
}AssertThatIsNotNull
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsNotNull")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatIsNotNull).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotNull() {
- return ImmutableSet.of(assertThat("foo" == null).isFalse(), assertThat("bar" != null).isTrue());
+ return ImmutableSet.of(assertThat("foo").isNotNull(), assertThat("bar").isNotNull());
}AssertThatHasSameHashCodeAs
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatHasSameHashCodeAs")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJObjectRules\$AssertThatHasSameHashCodeAs).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
AbstractAssert<?, ?> testAssertThatHasSameHashCodeAs() {
- return assertThat("foo".hashCode()).isEqualTo("bar".hashCode());
+ return assertThat("foo").hasSameHashCodeAs("bar");
}