View source: R/redundant_equals_linter.R
redundant_equals_linter | R Documentation |
==
, !=
on logical vectorsTesting x == TRUE
is redundant if x
is a logical vector. Wherever this is
used to improve readability, the solution should instead be to improve the
naming of the object to better indicate that its contents are logical. This
can be done using prefixes (is, has, can, etc.). For example, is_child
,
has_parent_supervision
, can_watch_horror_movie
clarify their logical
nature, while child
, parent_supervision
, watch_horror_movie
don't.
redundant_equals_linter()
best_practices, common_mistakes, efficiency, readability
linters for a complete list of linters available in lintr.
outer_negation_linter()
# will produce lints
lint(
text = "if (any(x == TRUE)) 1",
linters = redundant_equals_linter()
)
lint(
text = "if (any(x != FALSE)) 0",
linters = redundant_equals_linter()
)
# okay
lint(
text = "if (any(x)) 1",
linters = redundant_equals_linter()
)
lint(
text = "if (!all(x)) 0",
linters = redundant_equals_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.