AssertJNumberRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$).*as compiler argument.
Table of contents
NumberAssertIsPositive
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NumberAssertIsPositive")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$NumberAssertIsPositive).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsPositive() {
return ImmutableSet.of(
- assertThat((byte) 1).isGreaterThan((byte) 0),
- assertThat((byte) 2).isGreaterThanOrEqualTo((byte) 1),
- assertThat((short) 1).isGreaterThan((short) 0),
- assertThat((short) 2).isGreaterThanOrEqualTo((short) 1),
- assertThat(1).isGreaterThan(0),
- assertThat(2).isGreaterThanOrEqualTo(1),
- assertThat(1L).isGreaterThan(0),
- assertThat(2L).isGreaterThanOrEqualTo(1),
- assertThat(1.0f).isGreaterThan(0),
- assertThat(1.0).isGreaterThan(0),
- assertThat(BigInteger.ONE).isGreaterThan(BigInteger.ZERO),
- assertThat(BigInteger.TWO).isGreaterThanOrEqualTo(BigInteger.valueOf(1)),
- assertThat(BigDecimal.ONE).isGreaterThan(BigDecimal.ZERO));
+ assertThat((byte) 1).isPositive(),
+ assertThat((byte) 2).isPositive(),
+ assertThat((short) 1).isPositive(),
+ assertThat((short) 2).isPositive(),
+ assertThat(1).isPositive(),
+ assertThat(2).isPositive(),
+ assertThat(1L).isPositive(),
+ assertThat(2L).isPositive(),
+ assertThat(1.0f).isPositive(),
+ assertThat(1.0).isPositive(),
+ assertThat(BigInteger.ONE).isPositive(),
+ assertThat(BigInteger.TWO).isPositive(),
+ assertThat(BigDecimal.ONE).isPositive());
}NumberAssertIsNotPositive
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NumberAssertIsNotPositive")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$NumberAssertIsNotPositive).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotPositive() {
return ImmutableSet.of(
- assertThat((byte) 1).isLessThanOrEqualTo((byte) 0),
- assertThat((byte) 2).isLessThan((byte) 1),
- assertThat((short) 1).isLessThanOrEqualTo((short) 0),
- assertThat((short) 2).isLessThan((short) 1),
- assertThat(1).isLessThanOrEqualTo(0),
- assertThat(2).isLessThan(1),
- assertThat(1L).isLessThanOrEqualTo(0),
- assertThat(2L).isLessThan(1),
- assertThat(1.0f).isLessThanOrEqualTo(0),
- assertThat(1.0).isLessThanOrEqualTo(0),
- assertThat(BigInteger.ONE).isLessThanOrEqualTo(BigInteger.ZERO),
- assertThat(BigInteger.TWO).isLessThan(BigInteger.valueOf(1)),
- assertThat(BigDecimal.ONE).isLessThanOrEqualTo(BigDecimal.ZERO));
+ assertThat((byte) 1).isNotPositive(),
+ assertThat((byte) 2).isNotPositive(),
+ assertThat((short) 1).isNotPositive(),
+ assertThat((short) 2).isNotPositive(),
+ assertThat(1).isNotPositive(),
+ assertThat(2).isNotPositive(),
+ assertThat(1L).isNotPositive(),
+ assertThat(2L).isNotPositive(),
+ assertThat(1.0f).isNotPositive(),
+ assertThat(1.0).isNotPositive(),
+ assertThat(BigInteger.ONE).isNotPositive(),
+ assertThat(BigInteger.TWO).isNotPositive(),
+ assertThat(BigDecimal.ONE).isNotPositive());
}NumberAssertIsNegative
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NumberAssertIsNegative")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$NumberAssertIsNegative).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNegative() {
return ImmutableSet.of(
- assertThat((byte) -1).isLessThan((byte) 0),
- assertThat((byte) -2).isLessThanOrEqualTo((byte) -1),
- assertThat((short) -1).isLessThan((short) 0),
- assertThat((short) -2).isLessThanOrEqualTo((short) -1),
- assertThat(-1).isLessThan(0),
- assertThat(-2).isLessThanOrEqualTo(-1),
- assertThat(-1L).isLessThan(0),
- assertThat(-2L).isLessThanOrEqualTo(-1),
- assertThat(-1.0f).isLessThan(0),
- assertThat(-1.0).isLessThan(0),
- assertThat(BigInteger.valueOf(-1)).isLessThan(BigInteger.ZERO),
- assertThat(BigInteger.valueOf(-2)).isLessThanOrEqualTo(BigInteger.valueOf(-1)),
- assertThat(BigDecimal.valueOf(-1)).isLessThan(BigDecimal.ZERO));
+ assertThat((byte) -1).isNegative(),
+ assertThat((byte) -2).isNegative(),
+ assertThat((short) -1).isNegative(),
+ assertThat((short) -2).isNegative(),
+ assertThat(-1).isNegative(),
+ assertThat(-2).isNegative(),
+ assertThat(-1L).isNegative(),
+ assertThat(-2L).isNegative(),
+ assertThat(-1.0f).isNegative(),
+ assertThat(-1.0).isNegative(),
+ assertThat(BigInteger.valueOf(-1)).isNegative(),
+ assertThat(BigInteger.valueOf(-2)).isNegative(),
+ assertThat(BigDecimal.valueOf(-1)).isNegative());
}NumberAssertIsNotNegative
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NumberAssertIsNotNegative")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$NumberAssertIsNotNegative).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testNumberAssertIsNotNegative() {
return ImmutableSet.of(
- assertThat((byte) 1).isGreaterThanOrEqualTo((byte) 0),
- assertThat((byte) 2).isGreaterThan((byte) -1),
- assertThat((short) 1).isGreaterThanOrEqualTo((short) 0),
- assertThat((short) 2).isGreaterThan((short) -1),
- assertThat(1).isGreaterThanOrEqualTo(0),
- assertThat(2).isGreaterThan(-1),
- assertThat(1L).isGreaterThanOrEqualTo(0),
- assertThat(2L).isGreaterThan(-1),
- assertThat(1.0f).isGreaterThanOrEqualTo(0),
- assertThat(1.0).isGreaterThanOrEqualTo(0),
- assertThat(BigInteger.ONE).isGreaterThanOrEqualTo(BigInteger.ZERO),
- assertThat(BigInteger.TWO).isGreaterThan(BigInteger.valueOf(-1)),
- assertThat(BigDecimal.ONE).isGreaterThanOrEqualTo(BigDecimal.ZERO));
+ assertThat((byte) 1).isNotNegative(),
+ assertThat((byte) 2).isNotNegative(),
+ assertThat((short) 1).isNotNegative(),
+ assertThat((short) 2).isNotNegative(),
+ assertThat(1).isNotNegative(),
+ assertThat(2).isNotNegative(),
+ assertThat(1L).isNotNegative(),
+ assertThat(2L).isNotNegative(),
+ assertThat(1.0f).isNotNegative(),
+ assertThat(1.0).isNotNegative(),
+ assertThat(BigInteger.ONE).isNotNegative(),
+ assertThat(BigInteger.TWO).isNotNegative(),
+ assertThat(BigDecimal.ONE).isNotNegative());
}AssertThatIsOdd
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsOdd")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$AssertThatIsOdd).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testAssertThatIsOdd() {
return ImmutableSet.of(
- assertThat((char) 1 % 2).isEqualTo(1),
- assertThat(1 % 2).isEqualTo(1),
- assertThat(1L % 2).isEqualTo(1));
+ assertThat((char) 1 % 2).isEqualTo(1), assertThat(1).isOdd(), assertThat(1L).isOdd());
}AssertThatIsEven
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("AssertThatIsEven")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!AssertJNumberRules\$AssertThatIsEven).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<NumberAssert<?, ?>> testAssertThatIsEven() {
return ImmutableSet.of(
- assertThat((char) 1 % 2).isEqualTo(0),
- assertThat(1 % 2).isEqualTo(0),
- assertThat(1L % 2).isEqualTo(0));
+ assertThat((char) 1 % 2).isEqualTo(0), assertThat(1).isEven(), assertThat(1L).isEven());
}