PreconditionsRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$).*as compiler argument.
Table of contents
CheckArgumentNot
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckArgumentNot")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckArgumentNot).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckArgumentNot() {
- if ("foo".isEmpty()) {
- throw new IllegalArgumentException();
- }
- if (!"bar".isEmpty()) {
- throw new IllegalArgumentException();
- }
+ checkArgument(!"foo".isEmpty());
+ checkArgument("bar".isEmpty());
}CheckArgumentNotWithString
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckArgumentNotWithString")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckArgumentNotWithString).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckArgumentNotWithString() {
- if ("foo".isEmpty()) {
- throw new IllegalArgumentException("bar");
- }
- if (!"baz".isEmpty()) {
- throw new IllegalArgumentException("qux");
- }
+ checkArgument(!"foo".isEmpty(), "bar");
+ checkArgument("baz".isEmpty(), "qux");
}CheckElementIndex
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckElementIndex")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckElementIndex).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckElementIndex() {
- if (1 < 0 || 1 >= 2) {
- throw new IndexOutOfBoundsException("foo");
- }
+ checkElementIndex(1, 2, "foo");
}RequireNonNullExpression
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullExpression")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullExpression).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<String> testRequireNonNullExpression() {
- return ImmutableSet.of(checkNotNull("foo"), Optional.of("bar").orElse("baz"));
+ return ImmutableSet.of(requireNonNull("foo"), requireNonNull("bar"));
}RequireNonNullBlock
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullBlock")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullBlock).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testRequireNonNullBlock() {
- if ("foo" == null) {
- throw new NullPointerException();
- }
+ requireNonNull("foo");
}RequireNonNullWithStringExpression
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullWithStringExpression")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullWithStringExpression).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
String testRequireNonNullWithStringExpression() {
- return checkNotNull("foo", "bar");
+ return requireNonNull("foo", "bar");
}RequireNonNullWithStringBlock
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RequireNonNullWithStringBlock")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$RequireNonNullWithStringBlock).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testRequireNonNullWithStringBlock() {
- if ("foo" == null) {
- throw new NullPointerException("bar");
- }
+ requireNonNull("foo", "bar");
}CheckPositionIndex
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckPositionIndex")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckPositionIndex).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckPositionIndex() {
- if (1 < 0 || 1 > 2) {
- throw new IndexOutOfBoundsException();
- }
+ checkPositionIndex(1, 2);
}CheckPositionIndexWithString
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckPositionIndexWithString")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckPositionIndexWithString).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckPositionIndexWithString() {
- if (1 < 0 || 1 > 2) {
- throw new IndexOutOfBoundsException("foo");
- }
+ checkPositionIndex(1, 2, "foo");
}CheckStateNot
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckStateNot")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckStateNot).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckStateNot() {
- if ("foo".isEmpty()) {
- throw new IllegalStateException();
- }
+ checkState(!"foo".isEmpty());
}CheckStateNotWithString
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CheckStateNotWithString")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!PreconditionsRules\$CheckStateNotWithString).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
void testCheckStateNotWithString() {
- if ("foo".isEmpty()) {
- throw new IllegalStateException("bar");
- }
+ checkState(!"foo".isEmpty(), "bar");
}