RefasterAnyOfUsage
SUGGESTION
Simplification
Summary
Refaster#anyOf
should be passed at least two parameters
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("RefasterAnyOfUsage")
to the enclosing element.Disable this pattern completely by adding
-Xep:RefasterAnyOfUsage:OFF
as compiler argument. Learn more.
Samples
Replacement
Shows the difference in example code before and after the bug pattern is applied.
import com.google.errorprone.refaster.Refaster;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
class A {
@BeforeTemplate
String before(String str) {
Refaster.anyOf();
- return Refaster.anyOf(str);
+ return str;
}
}
Identification
Shows code lines which will (not) be flagged by this bug pattern.
A //BUG: Diagnostic contains:
comment is placed above any violating line.
import com.google.errorprone.refaster.Refaster;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
class A {
@BeforeTemplate
String before(String str) {
// BUG: Diagnostic contains:
Refaster.anyOf();
// BUG: Diagnostic contains:
return Refaster.anyOf(str);
}
@BeforeTemplate
Object before2(String str, Object obj) {
return Refaster.anyOf(str, obj);
}
}