Skip to content

Commit c9696a6

Browse files
authored
Surface unused imports with check(cran = TRUE) (#2461)
* Surface unused imports with `check(cran = TRUE)` Closes #2459 * Add NEWS bullet
1 parent 37bfbd1 commit c9696a6

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# devtools (development version)
22

3+
* `check(cran = TRUE)` sets the env var
4+
`_R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_` to `FALSE`, in order to
5+
surface the `"Namespace in Imports field not imported from"` NOTE. This only
6+
applies to R >= 4.2, due to favorable changes in the behaviour of
7+
`R CMD check --as-cran` (#2459).
8+
39
* `check(check_dir = NULL)` is the new default, to align with the default
410
behaviour of the underlying `rcmdcheck::rcmdcheck()`.
511

R/check.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ can_document <- function(pkg) {
159159
#' @rdname check
160160
#' @param path Path to built package.
161161
#' @param cran if `TRUE` (the default), check using the same settings as CRAN
162-
#' uses.
162+
#' uses. Because this is a moving target and is not uniform across all of
163+
#' CRAN's machine, this is on a "best effort" basis. It is more complicated
164+
#' than simply setting `--as-cran`.
163165
#' @param remote Sets `_R_CHECK_CRAN_INCOMING_REMOTE_` env var. If `TRUE`,
164166
#' performs a number of CRAN incoming checks that require remote access.
165167
#' @param incoming Sets `_R_CHECK_CRAN_INCOMING_` env var. If `TRUE`, performs a
@@ -188,6 +190,10 @@ check_built <- function(path = NULL, cran = TRUE,
188190

189191
if (cran) {
190192
args <- c("--as-cran", args)
193+
env_vars <- c(
194+
"_R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_" = as.character(FALSE),
195+
env_vars
196+
)
191197
}
192198
if (run_dont_test) {
193199
args <- c("--run-donttest", args)

man/check.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)