outer_negation_linter {lintr} | R Documentation |
Require usage of !any(x)
over all(!x)
, !all(x)
over any(!x)
Description
any(!x)
is logically equivalent to !any(x)
; ditto for the equivalence of
all(!x)
and !any(x)
. Negating after aggregation only requires inverting
one logical value, and is typically more readable.
Usage
outer_negation_linter()
Tags
best_practices, efficiency, readability
See Also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "all(!x)",
linters = outer_negation_linter()
)
lint(
text = "any(!x)",
linters = outer_negation_linter()
)
# okay
lint(
text = "!any(x)",
linters = outer_negation_linter()
)
lint(
text = "!all(x)",
linters = outer_negation_linter()
)
[Package lintr version 3.1.2 Index]