AssertJDurationRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. AssertThatHasNanos
  2. AssertThatHasMillis
  3. AssertThatHasSeconds
  4. AssertThatHasMinutes
  5. AssertThatHasHours
  6. AssertThatHasDays
  7. AssertThatIsZero
  8. AssertThatIsPositive
  9. AssertThatIsNegative

AssertThatHasNanos

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasNanos() {
-  return assertThat(Duration.ZERO.toNanos()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasNanos(0L);
 }

AssertThatHasMillis

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasMillis() {
-  return assertThat(Duration.ZERO.toMillis()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasMillis(0L);
 }

AssertThatHasSeconds

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasSeconds() {
-  return assertThat(Duration.ZERO.toSeconds()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasSeconds(0L);
 }

AssertThatHasMinutes

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasMinutes() {
-  return assertThat(Duration.ZERO.toMinutes()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasMinutes(0L);
 }

AssertThatHasHours

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasHours() {
-  return assertThat(Duration.ZERO.toHours()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasHours(0L);
 }

AssertThatHasDays

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractAssert<?, ?> testAssertThatHasDays() {
-  return assertThat(Duration.ZERO.toDays()).isEqualTo(0L);
+  return assertThat(Duration.ZERO).hasDays(0L);
 }

AssertThatIsZero

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsZero() {
   return ImmutableSet.of(
-      assertThat(Duration.ofMillis(0).isZero()).isTrue(),
-      assertThat(Duration.ofMillis(1)).isEqualTo(Duration.ZERO));
+      assertThat(Duration.ofMillis(0)).isZero(), assertThat(Duration.ofMillis(1)).isZero());
 }

AssertThatIsPositive

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 AbstractDurationAssert<?> testAssertThatIsPositive() {
-  return assertThat(Duration.ofMillis(0)).isGreaterThan(Duration.ZERO);
+  return assertThat(Duration.ofMillis(0)).isPositive();
 }

AssertThatIsNegative

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNegative() {
   return ImmutableSet.of(
-      assertThat(Duration.ofMillis(0).isNegative()).isTrue(),
-      assertThat(Duration.ofMillis(1)).isLessThan(Duration.ZERO));
+      assertThat(Duration.ofMillis(0)).isNegative(),
+      assertThat(Duration.ofMillis(1)).isNegative());
 }

Copyright © 2017-2024 Picnic Technologies BV