Require usage of startsWith() and endsWith() over grepl()/substr() versionsSource:
startsWith() is used to detect fixed initial substrings; it is more
readable and more efficient than equivalents using
substr(x, 1L, 3L) == "abc".
TRUE, usages with
grepl()are ignored. Some authors may prefer the
FALSEoutput conciseness offered by
grepl(), which doesn't have a direct equivalent with
Ditto for using
endsWith() to detect fixed terminal substrings.
Note that there is a difference in behavior between how
endsWith()) handle missing values. In particular, for
FALSE, while for
NA inputs have
That means the strict equivalent of
grepl("^abc", x) is
!is.na(x) & startsWith(x, "abc").
grepl() usages by default because the
!is.na() version is more explicit
with respect to
NA handling -- though documented, the way
missing inputs may be surprising to some readers.
linters for a complete list of linters available in lintr.