View source: R/object_overwrite_linter.R
object_overwrite_linter | R Documentation |
base
R functionRe-using existing names creates a risk of subtle error best avoided. Avoiding this practice also encourages using better, more descriptive names.
object_overwrite_linter(
packages = c("base", "stats", "utils", "tools", "methods", "graphics", "grDevices"),
allow_names = character()
)
packages |
Character vector of packages to search for names that should be avoided. Defaults to the most common default packages: base, stats, utils, tools, methods, graphics, and grDevices. |
allow_names |
Character vector of object names to ignore, i.e., which
are allowed to collide with exports from |
best_practices, configurable, executing, readability, robustness
linters for a complete list of linters available in lintr.
# will produce lints
code <- "function(x) {\n data <- x\n data\n}"
writeLines(code)
lint(
text = code,
linters = object_overwrite_linter()
)
code <- "function(x) {\n lint <- 'fun'\n lint\n}"
writeLines(code)
lint(
text = code,
linters = object_overwrite_linter(packages = "lintr")
)
# okay
code <- "function(x) {\n data('mtcars')\n}"
writeLines(code)
lint(
text = code,
linters = object_overwrite_linter()
)
code <- "function(x) {\n data <- x\n data\n}"
writeLines(code)
lint(
text = code,
linters = object_overwrite_linter(packages = "base")
)
# names in function signatures are ignored
lint(
text = "function(data) data <- subset(data, x > 0)",
linters = object_overwrite_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.