-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing_package_linter #547
Conversation
@jimhester I'm wondering which makes more sense: check both |
I'd suggest to separate library / require / loadNamespace (which will error if a package is not installed) The latter three are often used in packages to conditionally use functionality. if (requireNamespace("data.table", quietly = TRUE)) {
# do data.table stuff, e.g.
.data <- data.table::as.data.table(.data)
} else {
# do data.frame stuff
.data <- as.data.frame(.data)
} |
@AshesITR I agree. So I won't check BTW, do you think the linting message of missing packages should be an error or warning? Do we have a clear definition about what should be error and warning? |
Currently the only error linter is the parse errors. |
|
Any idea why test jobs against old releases failed? |
|
Just looked into R 4.0.3s The implementation for deparse(x, backtick = FALSE) This is in R >= 4.0.0 |
A minimal compatibility fix would be adding this code: if (getRversion() < '4.0.0') {
# format.default handles names since R 4.0.0
format.name <- function(x) deparse(x, backtick = FALSE)
} But I'd prefer to use |
the merge unfortunately necessitates another document() :( |
pkg_names <- parse(text = pkg_names, keep.source = FALSE) | ||
pkg_names <- vapply(pkg_names, as.character, character(1L)) | ||
|
||
installed_packges <- .packages(all.available = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this lib.paths be an argument to this linter? or perhaps known_packages as an argument. would make it more flexible to check code statically in scenarios where the packages may not be installed or the linter is run with a funny PATH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #536
library
,require
,loadNamespace
,requireNamespace
)