View source: R/duplicate_argument_linter.R
duplicate_argument_linter | R Documentation |
Check for duplicate arguments in function calls. Some cases are run-time errors
(e.g. mean(x = 1:5, x = 2:3)
), otherwise this linter is used to discourage
explicitly providing duplicate names to objects (e.g. c(a = 1, a = 2)
).
Duplicate-named objects are hard to work with programmatically and
should typically be avoided.
duplicate_argument_linter(except = c("mutate", "transmute"))
except |
A character vector of function names as exceptions. Defaults to
functions that allow sequential updates to variables, currently |
common_mistakes, configurable, correctness
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "list(x = 1, x = 2)",
linters = duplicate_argument_linter()
)
lint(
text = "fun(arg = 1, arg = 2)",
linters = duplicate_argument_linter()
)
# okay
lint(
text = "list(x = 1, x = 2)",
linters = duplicate_argument_linter(except = "list")
)
lint(
text = "df %>% dplyr::mutate(x = a + b, x = x + d)",
linters = duplicate_argument_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.