View source: R/unused_import_linter.R
unused_import_linter | R Documentation |
Check that imported packages are actually used
unused_import_linter(
allow_ns_usage = FALSE,
except_packages = c("bit64", "data.table", "tidyverse"),
interpret_glue = TRUE
)
allow_ns_usage |
Suppress lints for packages only used via namespace.
This is |
except_packages |
Character vector of packages that are ignored. These are usually attached for their side effects. |
interpret_glue |
If |
best_practices, common_mistakes, configurable, executing
linters for a complete list of linters available in lintr.
# will produce lints
code_lines <- "library(dplyr)\n1 + 1"
writeLines(code_lines)
lint(
text = code_lines,
linters = unused_import_linter()
)
code_lines <- "library(dplyr)\ndplyr::tibble(a = 1)"
writeLines(code_lines)
lint(
text = code_lines,
linters = unused_import_linter()
)
# okay
code_lines <- "library(dplyr)\ntibble(a = 1)"
writeLines(code_lines)
lint(
text = code_lines,
linters = unused_import_linter()
)
code_lines <- "library(dplyr)\ndplyr::tibble(a = 1)"
writeLines(code_lines)
lint(
text = code_lines,
linters = unused_import_linter(allow_ns_usage = TRUE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.