Recommend usage of call. = FALSE
in conditions
Source: R/condition_call_linter.R
condition_call_linter.Rd
This linter, with the default display_call = FALSE
, enforces the
recommendation of the tidyverse design guide regarding displaying error
calls.
Arguments
- display_call
Logical specifying expected behavior regarding
call.
argument in conditions.NA
forces providingcall. =
but ignores its value (this can be used in cases where you expect a mix ofcall. = FALSE
andcall. = TRUE
)TRUE
lintscall. = FALSE
FALSE
forcescall. = FALSE
(lintscall. = TRUE
or missingcall. =
value)
See also
linters for a complete list of linters available in lintr.
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.