From 0b6bf91d9e0d59d165f3d1b608bae538de501b2a Mon Sep 17 00:00:00 2001 From: almac2022 Date: Thu, 1 Oct 2026 07:44:46 -0700 Subject: [PATCH] Clear the two standing R CMD check NOTEs Import the .data and .env pronouns from rlang, which code used unqualified, and move sf from Imports to Suggests: no R code calls it, and cd_crop() only checks inherits(aoi, "sf") before terra::vect(), which loads sf itself. Tests that read their AOI with sf::st_read() now skip without sf. Fixes #111 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj --- DESCRIPTION | 2 +- NAMESPACE | 2 ++ R/cd-package.R | 1 + tests/testthat/test-cd_crop.R | 3 +++ tests/testthat/test-cd_extract.R | 5 +++++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 79f3f5c..586b4af 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,6 +33,7 @@ Suggests: Kendall, knitr, rmarkdown, + sf, testthat (>= 3.0.0), tidyterra, withr, @@ -44,7 +45,6 @@ Imports: jsonlite, rappdirs, rlang, - sf, stringr, terra, tibble diff --git a/NAMESPACE b/NAMESPACE index 7b9540f..46cc800 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,3 +24,5 @@ export(cd_stac_catalog) export(cd_summary) export(cd_trend) export(cd_variables) +importFrom(rlang,.data) +importFrom(rlang,.env) diff --git a/R/cd-package.R b/R/cd-package.R index 0cc9deb..baa5ada 100644 --- a/R/cd-package.R +++ b/R/cd-package.R @@ -1,2 +1,3 @@ #' @keywords internal +#' @importFrom rlang .data .env "_PACKAGE" diff --git a/tests/testthat/test-cd_crop.R b/tests/testthat/test-cd_crop.R index d81c1d0..3a0d8a1 100644 --- a/tests/testthat/test-cd_crop.R +++ b/tests/testthat/test-cd_crop.R @@ -1,4 +1,5 @@ test_that("cd_crop returns cropped SpatRaster from sf AOI", { + skip_if_not_installed("sf") href <- system.file("extdata", "example_climate.tif", package = "cd") aoi <- sf::st_read( system.file("extdata", "example_aoi.gpkg", package = "cd"), @@ -23,6 +24,7 @@ test_that("cd_crop accepts SpatVector AOI", { }) test_that("cd_crop preserves band names", { + skip_if_not_installed("sf") href <- system.file("extdata", "example_climate.tif", package = "cd") aoi <- sf::st_read( system.file("extdata", "example_aoi.gpkg", package = "cd"), @@ -34,6 +36,7 @@ test_that("cd_crop preserves band names", { }) test_that("cd_crop with cache = TRUE passes a local href straight through", { + skip_if_not_installed("sf") href <- system.file("extdata", "example_climate.tif", package = "cd") aoi <- sf::st_read( system.file("extdata", "example_aoi.gpkg", package = "cd"), diff --git a/tests/testthat/test-cd_extract.R b/tests/testthat/test-cd_extract.R index 3eb56d8..85dea0b 100644 --- a/tests/testthat/test-cd_extract.R +++ b/tests/testthat/test-cd_extract.R @@ -1,4 +1,5 @@ test_that("cd_extract returns expected structure", { + skip_if_not_installed("sf") catalog <- cd_catalog( system.file("extdata", "example_catalog.json", package = "cd") ) @@ -17,6 +18,7 @@ test_that("cd_extract returns expected structure", { }) test_that("cd_extract values are numeric and non-NA", { + skip_if_not_installed("sf") catalog <- cd_catalog( system.file("extdata", "example_catalog.json", package = "cd") ) @@ -31,6 +33,7 @@ test_that("cd_extract values are numeric and non-NA", { }) test_that("cd_extract filters by years", { + skip_if_not_installed("sf") catalog <- cd_catalog( system.file("extdata", "example_catalog.json", package = "cd") ) @@ -45,6 +48,7 @@ test_that("cd_extract filters by years", { }) test_that("cd_extract cache = TRUE matches cache = FALSE for local COGs", { + skip_if_not_installed("sf") catalog <- cd_catalog( system.file("extdata", "example_catalog.json", package = "cd") ) @@ -59,6 +63,7 @@ test_that("cd_extract cache = TRUE matches cache = FALSE for local COGs", { }) test_that("cd_extract filters by variables", { + skip_if_not_installed("sf") catalog <- cd_catalog( system.file("extdata", "example_catalog.json", package = "cd") )