Learn R Programming

lintr (version 3.2.0)

stopifnot_all_linter: Block usage of all() within stopifnot()

Description

stopifnot(A) actually checks all(A) "under the hood" if A is a vector, and produces a better error message than stopifnot(all(A)) does.

Usage

stopifnot_all_linter()

Arguments

Tags

best_practices, readability

See Also

linters for a complete list of linters available in lintr.

Examples

Run this code
# will produce lints
lint(
  text = "stopifnot(all(x > 0))",
  linters = stopifnot_all_linter()
)

lint(
  text = "stopifnot(y > 3, all(x < 0))",
  linters = stopifnot_all_linter()
)

# okay
lint(
  text = "stopifnot(is.null(x) || all(x > 0))",
  linters = stopifnot_all_linter()
)

lint(
  text = "assert_that(all(x > 0))",
  linters = stopifnot_all_linter()
)

Run the code above in your browser using DataLab