Skip to content

Files

Latest commit

 

History

History
27 lines (19 loc) · 603 Bytes

consecutive_assertion_linter.md

File metadata and controls

27 lines (19 loc) · 603 Bytes

Pattern: Redundant consecutive calls to assertions

Issue: -

Description

stopifnot() accepts any number of tests, so sequences like stopifnot(x); stopifnot(y) are redundant. Ditto for tests using assertthat::assert_that() without specifying msg=.

Examples

# will produce lints
lint(
  text = "stopifnot(x); stopifnot(y)",
  linters = consecutive_assertion_linter()
)

# okay
lint(
  text = "stopifnot(x, y)",
  linters = consecutive_assertion_linter()
)

Further Reading