condition_call_linter: Recommend usage of 'call. = FALSE' in conditions

View source: R/condition_call_linter.R

condition_call_linterR Documentation

Recommend usage of call. = FALSE in conditions

Description

This linter, with the default display_call = FALSE, enforces the recommendation of the tidyverse design guide regarding displaying error calls.

Usage

condition_call_linter(display_call = FALSE)

Arguments

display_call

Logical specifying expected behavior regarding call. argument in conditions.

  • NA forces providing ⁠call. =⁠ but ignores its value (this can be used in cases where you expect a mix of call. = FALSE and call. = TRUE)

  • TRUE lints call. = FALSE

  • FALSE forces call. = FALSE (lints call. = TRUE or missing ⁠call. =⁠ value)

Tags

best_practices, configurable, style, tidy_design

See Also

Examples

# will produce lints
lint(
  text = "stop('test')",
  linters = condition_call_linter()
)

lint(
  text = "stop('test', call. = TRUE)",
  linters = condition_call_linter()
)

lint(
  text = "stop('test', call. = FALSE)",
  linters = condition_call_linter(display_call = TRUE)
)

lint(
  text = "stop('this is a', 'test', call. = FALSE)",
  linters = condition_call_linter(display_call = TRUE)
)

# okay
lint(
  text = "stop('test', call. = FALSE)",
  linters = condition_call_linter()
)

lint(
  text = "stop('this is a', 'test', call. = FALSE)",
  linters = condition_call_linter()
)

lint(
  text = "stop('test', call. = TRUE)",
  linters = condition_call_linter(display_call = TRUE)
)


r-lib/lintr documentation built on Dec. 20, 2024, 7:24 p.m.