unused_import_linter {lintr} | R Documentation |
Check that imported packages are actually used
Description
Check that imported packages are actually used
Usage
unused_import_linter(
allow_ns_usage = FALSE,
except_packages = c("bit64", "data.table", "tidyverse"),
interpret_glue = TRUE
)
Arguments
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 |
Tags
best_practices, common_mistakes, configurable, executing
See Also
linters for a complete list of linters available in lintr.
Examples
# 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)
)
[Package lintr version 3.1.2 Index]