Skip to contents

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)

See also

Examples

# will produce lints
lint(
  text = "stop('test')",
  linters = condition_call_linter()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.

lint(
  text = "stop('test', call. = TRUE)",
  linters = condition_call_linter()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.

lint(
  text = "stop('test', call. = FALSE)",
  linters = condition_call_linter(display_call = TRUE)
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[condition_call_linter] Use stop(.) to display the call in an error message.

lint(
  text = "stop('this is a', 'test', call. = FALSE)",
  linters = condition_call_linter(display_call = TRUE)
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[condition_call_linter] Use stop(.) to display the call in an error message.

# 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)
)