New R CMD CHECK Note in R 4.2.0 for Imports field

A new R CMD CHECK Note was introduced when I upgraded to R 4.2.0, but I could not find in the R changelog what happened. I am getting

❯ checking dependencies in R code ... NOTE
  Namespaces in Imports field not imported from:
    ‘DBI’ ‘RSQLite’ ‘assertthat’ ‘cli’ ‘dbplyr’ ‘rlang’ ‘stringr’ ‘tidyr’
    All declared Imports should be used.

I am using functions from these packages for the methods of my RC class. Previously, in R 4.1.3 this note did not appear. I am a little reluctant to add @import tags for all these packages. What is the current practice now for importing functions for RC methods?

It is probably because you create the class at install time, and the check does not consider code that runs at install time.

A workaround is to create a dummy function that refers to these packages:

dummy <- function() {
  cli::cli_alert
  stringr::str_replace
  ...
}

Silly, but this satisfies the check.

2 Likes

Thanks @Gabor I can use this dummy function, just wondering if anyone else has come across this and if there's going to be a long-term solution?

My dummy hack in R/utils.R:

#' @noRd
dummy <- function() {
  DBI::dbConnect
  RSQLite::dbConnect
  assertthat::assert_that
  cli::cli_alert
  dbplyr::sql
  hash::hash
  rlang::abort
  stringr::str_replace
  tidyr::pivot_longer
}

If anyone has a better solution please let me know!

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.