list_comparison_linter {lintr} | R 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()
)
[Package lintr version 3.2.0 Index]