AssertJInstantRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatIsAfter
  2. AssertThatIsBeforeOrEqualTo
  3. AssertThatIsBefore
  4. AssertThatIsAfterOrEqualTo
  5. AssertThatIsBetween
  6. AssertThatIsStrictlyBetween

AssertThatIsAfter

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsAfter() {
-  return assertThat(Instant.MIN.isAfter(Instant.MAX)).isTrue();
+  return assertThat(Instant.MIN).isAfter(Instant.MAX);
 }

AssertThatIsBeforeOrEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsBeforeOrEqualTo() {
-  return assertThat(Instant.MIN.isAfter(Instant.MAX)).isFalse();
+  return assertThat(Instant.MIN).isBeforeOrEqualTo(Instant.MAX);
 }

AssertThatIsBefore

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsBefore() {
-  return assertThat(Instant.MIN.isBefore(Instant.MAX)).isTrue();
+  return assertThat(Instant.MIN).isBefore(Instant.MAX);
 }

AssertThatIsAfterOrEqualTo

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatIsAfterOrEqualTo() {
-  return assertThat(Instant.MIN.isBefore(Instant.MAX)).isFalse();
+  return assertThat(Instant.MIN).isAfterOrEqualTo(Instant.MAX);
 }

AssertThatIsBetween

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractInstantAssert<?>> testAssertThatIsBetween() {
   return ImmutableSet.of(
-      assertThat(Instant.EPOCH).isAfterOrEqualTo(Instant.MIN).isBeforeOrEqualTo(Instant.MAX),
+      assertThat(Instant.EPOCH).isBetween(Instant.MIN, Instant.MAX),
       assertThat(Instant.ofEpochMilli(0))
-          .isBeforeOrEqualTo(Instant.ofEpochMilli(1))
-          .isAfterOrEqualTo(Instant.ofEpochMilli(2)));
+          .isBetween(Instant.ofEpochMilli(2), Instant.ofEpochMilli(1)));
 }

AssertThatIsStrictlyBetween

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractInstantAssert<?>> testAssertThatIsStrictlyBetween() {
   return ImmutableSet.of(
-      assertThat(Instant.EPOCH).isAfter(Instant.MIN).isBefore(Instant.MAX),
+      assertThat(Instant.EPOCH).isStrictlyBetween(Instant.MIN, Instant.MAX),
       assertThat(Instant.ofEpochMilli(0))
-          .isBefore(Instant.ofEpochMilli(1))
-          .isAfter(Instant.ofEpochMilli(2)));
+          .isStrictlyBetween(Instant.ofEpochMilli(2), Instant.ofEpochMilli(1)));
 }

Copyright © 2017-2024 Picnic Technologies BV