which_grepl_linter: Require usage of grep over which(grepl(.))

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


jimhester/lintr documentation built on April 24, 2024, 8:21 a.m.