Skip to contents

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()

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()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[which_grepl_linter] grep(pattern, x) is better than which(grepl(pattern, x)).

# okay
lint(
  text = "which(grepl('^a', x) | grepl('^b', x))",
  linters = which_grepl_linter()
)