View source: R/undesirable_function_linter.R
undesirable_function_linter | R Documentation |
Report the use of undesirable functions (e.g. base::return()
, base::options()
, or
base::sapply()
) and suggest an alternative.
undesirable_function_linter(
fun = default_undesirable_functions,
symbol_is_undesirable = TRUE
)
fun |
Named character vector. |
symbol_is_undesirable |
Whether to consider the use of an undesirable function name as a symbol undesirable or not. |
best_practices, configurable, efficiency, robustness, style
linters for a complete list of linters available in lintr.
# defaults for which functions are considered undesirable
names(default_undesirable_functions)
# will produce lints
lint(
text = "sapply(x, mean)",
linters = undesirable_function_linter()
)
lint(
text = "log10(x)",
linters = undesirable_function_linter(fun = c("log10" = NA))
)
lint(
text = "log10(x)",
linters = undesirable_function_linter(fun = c("log10" = "use log()"))
)
lint(
text = 'dir <- "path/to/a/directory"',
linters = undesirable_function_linter(fun = c("dir" = NA))
)
# okay
lint(
text = "vapply(x, mean, FUN.VALUE = numeric(1))",
linters = undesirable_function_linter()
)
lint(
text = "log(x, base = 10)",
linters = undesirable_function_linter(fun = c("log10" = "use log()"))
)
lint(
text = 'dir <- "path/to/a/directory"',
linters = undesirable_function_linter(fun = c("dir" = NA), symbol_is_undesirable = FALSE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.