which_grepl_linter {lintr} | R Documentation |
Require usage of grep over which(grepl(.))
Description
which(grepl(pattern, x))
is the same as grep(pattern, x)
, but harder
to read and requires two passes over the vector.
Usage
which_grepl_linter()
Tags
consistency, efficiency, readability, regex
See Also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "which(grepl('^a', x))",
linters = which_grepl_linter()
)
# okay
lint(
text = "which(grepl('^a', x) | grepl('^b', x))",
linters = which_grepl_linter()
)
[Package lintr version 3.2.0 Index]