lintr
lintr copied to clipboard
New lint: `pkg_namespace_usage_linter`
As a package maintainer I would like to know whether my declared imports in the DESCRIPTION file are actually used in the code.
I managed to find a great third-party package checkglobals that does similar thing and this is a dummy script executed on one of those packages
x_deps_in_desc <- desc::desc_get_deps() |> subset(x = _, type %in% pkgdepends::as_pkg_dependencies("hard")$direct) |> _$package
x_deps_in_code <- as.data.frame(checkglobals::check_pkg()) |> _$package |> unique()
setdiff(x_deps_in_desc, x_deps_in_code) # this should be empty
#> [1] "R" "GenomeInfoDb" "GenomicRanges" "scda"
#> [5] "teal.logger" "teal.reporter"
search() # just to show no side effects
#> [1] ".GlobalEnv" "package:stats" "package:graphics"
#> [4] "package:grDevices" "package:utils" "package:datasets"
#> [7] "package:methods" "Autoloads" "tools:callr"
#> [10] "package:base"
This obviously does not follow how lints are written but I can move it forward. More importantly, I would like to ask how does it fit lintr
as a whole? This feels more like a validation on the package level as opposed to individual scripts? How to report issues as I cannot point to the script line of code that is wrong but rather DESCRIPTION file.
I am interested in hearing your thoughts on that. The bottom line is that I can create my own GHAction for that but from my perspective I would like to avoid creating so many testing functionalities and I would like to reuse an open engine of lintr
if possible.
(CC @m7pr)