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()
)
#> <text>:1:1: warning: [condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
#> stop('test')
#> ^~~~~~~~~~~~

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

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

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

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

lint(
  text = "stop('this is a', 'test', call. = FALSE)",
  linters = condition_call_linter()
)
#>  No lints found.

lint(
  text = "stop('test', call. = TRUE)",
  linters = condition_call_linter(display_call = TRUE)
)
#>  No lints found.