Alternate names: PreconditionsExpensiveString
Lenient format strings, such as those accepted by Preconditions
, are often
constructed lazily. The message is rarely needed, so it should either be cheap
to construct or constructed only when needed. This check ensures that these
messages are not constructed using expensive methods that are evaluated eagerly.
Prefer this:
checkNotNull(foo, "hello %s", name);
instead of this:
checkNotNull(foo, String.format("hello %s", name));
Suppress false positives by adding the suppression annotation @SuppressWarnings("ExpensiveLenientFormatString")
to the enclosing element.