Create a linter that flags specific function calls. This is a simplified version that doesn't require XPath knowledge.
Usage
forbid_functions(
functions,
message = NULL,
alternatives = NULL,
type = c("warning", "error", "style")
)Examples
if (FALSE) { # \dontrun{
# Ban attach()
no_attach <- forbid_functions(
"attach",
"Don't use {function}(). Use with() instead."
)
# With alternatives
no_sapply <- forbid_functions(
"sapply",
alternatives = "vapply"
)
# Multiple functions
no_deprecated <- forbid_functions(
c("sapply", "mapply", "tapply"),
"Function {function}() is discouraged."
)
} # }