list_comparison_linter: Block usage of comparison operators with known-list()...

View source: R/list_comparison_linter.R

list_comparison_linterR Documentation

Block usage of comparison operators with known-list() functions like lapply

Description

Usage like lapply(x, sum) > 10 is awkward because the list must first be coerced to a vector for comparison. A function like vapply() should be preferred.

Usage

list_comparison_linter()

Tags

best_practices, common_mistakes

See Also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "lapply(x, sum) > 10",
  linters = list_comparison_linter()
)

# okay
lint(
  text = "unlist(lapply(x, sum)) > 10",
  linters = list_comparison_linter()
)


r-lib/lintr documentation built on Dec. 20, 2024, 7:24 p.m.