Skip to content
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

devtools::check() will miss package dependency if respective code only appears in function arguments #2456

Closed
ramiromagno opened this issue Aug 9, 2022 · 3 comments

Comments

@ramiromagno
Copy link

Using {devtools} version 2.4.4..

Assume a vanilla package (no Imports whatsoever in DESCRIPTION) with only one source R file with one function only:

#' Star wars dataset
#'
#' @param x A data frame.
#'
#' @export
star_wars <- function(x = dplyr::starwars) {
  print(x)
}

devtools::check() will be oblivious to the dependency on {dplyr}:

── R CMD check results ──────────────────────────────────────────────────────────────────────────── weird 0.1.0 ────
Duration: 7.9s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

R CMD check succeeded

If I try to include this dependency, then I get:

── R CMD check results ──────────────────────────────────────────────────────────────────────────── weird 0.1.0 ────
Duration: 7.8s

❯ checking dependencies in R code ... NOTE
  Namespace in Imports field not imported from: ‘dplyr’
    All declared Imports should be used.

0 errors ✔ | 0 warnings ✔ | 1 note ✖

@jennybc
Copy link
Member

jennybc commented Aug 9, 2022

What you are noticing is behaviour, admittedly sort of unexpected and quirky, of R CMD check, not of devtools::check(). So it's not something we will or can fix.

There are ways to suppress this NOTE, which I've recorded here (and this was a good nudge for us to include this content in the R Packages book):

hadley/r-pkgs#828

@jennybc jennybc closed this as completed Aug 9, 2022
@ramiromagno
Copy link
Author

Thanks Jenny!

@moodymudskipper
Copy link

FWIW I've reported it to r-devel and it's fixed in dev so should not be an issue from 4.3 onwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants