Here is a function for checking if we have unused dependencies in a package.
Throwing it here in circus might be a good home for it.
find_unused_dependencies <- function(
dependencies = c("Depends", "Imports", "LinkingTo"),
include_supp_files = FALSE,
path = getwd(),
root = NULL,
...,
progress = TRUE,
errors = c("reported", "fatal", "ignored"),
dev = FALSE
) {
deps <- renv::dependencies(path = path, root = root, ...,
progress = progress, errors = errors, dev = dev)
if (isFALSE(include_supp_files)) {
deps <- dplyr::filter(
deps,
stringr::str_detect(Source, "DESCRIPTION") |
stringr::str_detect(Source, "/R/")
)
}
deps <- dplyr::filter(deps, Package != "R")
deps_desc <- data.frame(Package = remotes::local_package_deps(
pkgdir = path,
dependencies = dependencies
))
deps_used <- dplyr::filter(deps, ! stringr::str_detect(Source, "DESCRIPTION"))
deps_orphan <- dplyr::anti_join(deps_desc, deps_used, by = "Package")
return(deps_orphan)
}
find_unused_dependencies()
# Finding R package dependencies ... Done!
# Package
# 1 poorman
dependencies says which dependencies fields to check. See ?remotes::local_package_deps.
include_supp_files: If FALSE, only check for dependencies in DESCRIPTION and files in /R/ (excluding tests, vignettes, /WIP/, README, etc.). If TRUE, all files are checked.
Originally posted by @bwiernik in easystats/correlation#192 (comment)
Here is a function for checking if we have unused dependencies in a package.
Throwing it here in circus might be a good home for it.
dependenciessays which dependencies fields to check. See?remotes::local_package_deps.include_supp_files: IfFALSE, only check for dependencies inDESCRIPTIONand files in/R/(excluding tests, vignettes,/WIP/, README, etc.). IfTRUE, all files are checked.Originally posted by @bwiernik in easystats/correlation#192 (comment)