View source: R/undesirable_operator_linter.R
undesirable_operator_linter | R Documentation |
Report the use of undesirable operators, e.g. :::
or
<<-
and suggest an alternative.
undesirable_operator_linter(
op = default_undesirable_operators,
call_is_undesirable = TRUE
)
op |
Named character vector. |
call_is_undesirable |
Logical, default |
best_practices, configurable, robustness, style
linters for a complete list of linters available in lintr.
# defaults for which functions are considered undesirable
names(default_undesirable_operators)
# will produce lints
lint(
text = "a <<- log(10)",
linters = undesirable_operator_linter()
)
lint(
text = "mtcars$wt",
linters = undesirable_operator_linter(op = c("$" = "As an alternative, use the `[[` accessor."))
)
lint(
text = "`:::`(utils, hasName)",
linters = undesirable_operator_linter()
)
# okay
lint(
text = "a <- log(10)",
linters = undesirable_operator_linter()
)
lint(
text = 'mtcars[["wt"]]',
linters = undesirable_operator_linter(op = c("$" = NA))
)
lint(
text = 'mtcars[["wt"]]',
linters = undesirable_operator_linter(op = c("$" = "As an alternative, use the `[[` accessor."))
)
lint(
text = "`:::`(utils, hasName)",
linters = undesirable_operator_linter(call_is_undesirable = FALSE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.