vector_logic_linter {lintr}R Documentation

Enforce usage of scalar logical operators in conditional statements

Description

Usage of & in conditional statements is error-prone and inefficient. condition in if (condition) expr must always be length-1, in which case && is to be preferred. Ditto for | vs. ||.

Usage

vector_logic_linter()

Details

This linter covers inputs to ⁠if()⁠ and ⁠while()⁠ conditions and to testthat::expect_true() and testthat::expect_false().

Tags

best_practices, default, efficiency

See Also

linters for a complete list of linters available in lintr.
https://style.tidyverse.org/syntax.html#if-statements


[Package lintr version 3.0.0 Index]