conjunct_test_linter {lintr}R Documentation

Force && conditions in expect_true(), expect_false() to be written separately

Description

For readability of test outputs, testing only one thing per call to testthat::expect_true() is preferable, i.e., ⁠expect_true(A); expect_true(B)⁠ is better than expect_true(A && B), and ⁠expect_false(A); expect_false(B)⁠ is better than expect_false(A || B).

Usage

conjunct_test_linter(allow_named_stopifnot = TRUE)

Arguments

allow_named_stopifnot

Logical, TRUE by default. If FALSE, "named" calls to stopifnot(), available since R 4.0.0 to provide helpful messages for test failures, are also linted.

Details

Similar reasoning applies to && usage inside stopifnot() and assertthat::assert_that() calls.

Tags

best_practices, package_development, readability

See Also

linters for a complete list of linters available in lintr.


[Package lintr version 3.0.1 Index]