From d3e1817e4447ee372aebe4e271f8cf70d72e13eb Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 09:35:25 +0100 Subject: [PATCH 1/6] Add uuid, glue, and httr to R dependencies in workflow configuration - Updated extra-packages in R-CMD-check workflow - Included any::uuid for unique ID generation - Added any::glue for string interpolation support - Integrated any::httr for HTTP requests handling - Ensured compatibility with rcmdcheck - No other workflow steps modified --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 9d73893..560f2cc 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,7 +24,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck + extra-packages: any::rcmdcheck, any::uuid, any::glue, any::httr needs: check - uses: r-lib/actions/check-r-package@v2 \ No newline at end of file From 2ab29a124ae3a3e16c6cbcf1c3c3229a37e257bf Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 09:39:59 +0100 Subject: [PATCH 2/6] Move uuid from Suggests to Imports in DESCRIPTION file - Ensures uuid is a required dependency - Updates package dependency management - Improves consistency in DESCRIPTION - Maintains minimum version requirement for uuid - Keeps knitr and other dependencies unchanged - No changes to package functionality --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c6dd97..6dc239f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,10 +40,10 @@ Imports: tools, graphics, rlang, + uuid (>= 1.0-3), knitr (>= 1.19) Suggests: testthat (>= 3.0.0), - uuid (>= 1.0-3), writexl (>= 1.5.0), glue (>= 1.6.0), httr (>= 1.4.0), From 779cdbcd97fe370c09681fc1d84fd7cf7af4c8a3 Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 09:48:31 +0100 Subject: [PATCH 3/6] Add explicit R package installation step to workflow - Insert step to install httr and glue packages via Rscript - Ensure required packages are present before package check - Update workflow for improved package management - Maintain compatibility with r-lib/actions/check-r-package - No changes to other workflow steps or logic - Fix missing newline at end of file --- .github/workflows/R-CMD-check.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 560f2cc..ed2586b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -26,5 +26,10 @@ jobs: with: extra-packages: any::rcmdcheck, any::uuid, any::glue, any::httr needs: check + + - name: Install extra packages explicitly + run: | + install.packages(c("httr", "glue)) + shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 \ No newline at end of file From 47a36251958f4c2adbc68a233682771fc5003796 Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 10:03:37 +0100 Subject: [PATCH 4/6] Fix typo in R package installation command in workflow YAML file - Corrected missing quote in install.packages argument - Ensures both httr and glue are installed properly - Prevents Rscript execution errors in CI workflow --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ed2586b..0105463 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,7 +29,7 @@ jobs: - name: Install extra packages explicitly run: | - install.packages(c("httr", "glue)) + install.packages(c("httr", "glue")) shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 \ No newline at end of file From 26e024df4f989c8c23b8fbf7046783e112cc00f4 Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 10:17:13 +0100 Subject: [PATCH 5/6] Refactor package installation logic for httr and glue in createSeed and tests - Remove explicit httr and glue install from workflow YAML - Move package checks inside createSeed tryCatch block - Add skip_if_not_installed for httr and glue in testthat tests - Improve test reliability by skipping if dependencies are missing - Clean up redundant code in R/f_seed.R and test_f_seed.R --- .github/workflows/R-CMD-check.yaml | 7 +------ R/f_seed.R | 6 ++++-- tests/testthat/test_f_seed.R | 9 +++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 0105463..9d73893 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,12 +24,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck, any::uuid, any::glue, any::httr + extra-packages: any::rcmdcheck needs: check - - - name: Install extra packages explicitly - run: | - install.packages(c("httr", "glue")) - shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 \ No newline at end of file diff --git a/R/f_seed.R b/R/f_seed.R index 82b20c2..fa0b85b 100644 --- a/R/f_seed.R +++ b/R/f_seed.R @@ -85,8 +85,6 @@ #' @export #' createSeed <- function(numberOfValues = 1, minValue = 1000000, maxValue = 9999999, ...) { - .assertPackageIsInstalled("httr") - .assertPackageIsInstalled("glue") .assertIsSingleInteger(numberOfValues, "numberOfValues", validateType = FALSE) .assertIsInClosedInterval(numberOfValues, "numberOfValues", lower = 1, upper = 1000) .assertIsSingleInteger(minValue, "minValue", validateType = FALSE) @@ -97,8 +95,12 @@ createSeed <- function(numberOfValues = 1, minValue = 1000000, maxValue = 999999 stop(C_EXCEPTION_TYPE_CONFLICTING_ARGUMENTS, "'minValue' (", minValue, ") ", "must be smaller than argument 'maxValue'(", maxValue, ")") } + tryCatch( { + .assertPackageIsInstalled("httr") + .assertPackageIsInstalled("glue") + args <- list(...) if (length(args) > 0 && !is.null(args[["test_exception"]])) { stop(args[["test_exception"]]) diff --git a/tests/testthat/test_f_seed.R b/tests/testthat/test_f_seed.R index 751b2e9..a6dc603 100644 --- a/tests/testthat/test_f_seed.R +++ b/tests/testthat/test_f_seed.R @@ -21,6 +21,9 @@ # ------------------------------------------------------------------------------ test_that("For invalid input arguments 'createSeed' throws meaningful exceptions", { + testthat::skip_if_not_installed("httr") + testthat::skip_if_not_installed("glue") + expect_error(createSeed(numberOfValues = 0), "Argument out of bounds: 'numberOfValues' (0) is out of bounds [1; 1000]", fixed = TRUE) expect_error(createSeed(numberOfValues = 1, minValue = -1), @@ -32,6 +35,9 @@ test_that("For invalid input arguments 'createSeed' throws meaningful exceptions }) test_that("The results of 'createSeed' depend on the input arguments as expected", { + testthat::skip_if_not_installed("httr") + testthat::skip_if_not_installed("glue") + expect_length(createSeed(), 1) expect_length(createSeed(numberOfValues = 9), 9) @@ -41,6 +47,9 @@ test_that("The results of 'createSeed' depend on the input arguments as expected }) test_that("'createSeed' returns valid seed although network connection is missing", { + testthat::skip_if_not_installed("httr") + testthat::skip_if_not_installed("glue") + expect_warning(seed <- createSeed( minValue = 100000000, maxValue = 999999999, test_exception = "network error" From 2acd95428f147f2d3d25aecc7c3ec5839196503a Mon Sep 17 00:00:00 2001 From: Friedrich Pahlke Date: Tue, 25 Nov 2025 10:31:28 +0100 Subject: [PATCH 6/6] Update R files and ignore rules for documentation and code improvements - Add `_pkgdown.yml` and `.github` to `.Rbuildignore` - Document unused `...` argument in randomizer constructor - Fix factor level access in `f_random_stratum_builder` - Remove unused `@seealso` from `f_seed` documentation --- .Rbuildignore | 2 ++ R/class_random_block_size_randomizer.R | 1 + R/f_random_stratum_builder.R | 2 +- R/f_seed.R | 2 -- man/createSeed.Rd | 3 --- man/getRandomBlockSizeRandomizer.Rd | 2 ++ 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 889bcdc..b761d0a 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -28,3 +28,5 @@ NEWS\.tex .*_snaps.* ^Meta$ ^CNAME$ +^_pkgdown\.yml$ +^\.github$ diff --git a/R/class_random_block_size_randomizer.R b/R/class_random_block_size_randomizer.R index 4b92586..f2fb50e 100644 --- a/R/class_random_block_size_randomizer.R +++ b/R/class_random_block_size_randomizer.R @@ -30,6 +30,7 @@ #' #' @param blockSizes List of block size configurations, each mapping treatment arm IDs to sizes. #' @param seed Integer random seed used for reproducibility. +#' @param ... Additional arguments (currently unused). #' #' @return A `RandomBlockSizeRandomizer` reference class object. #' diff --git a/R/f_random_stratum_builder.R b/R/f_random_stratum_builder.R index 19db164..65d6f9a 100644 --- a/R/f_random_stratum_builder.R +++ b/R/f_random_stratum_builder.R @@ -55,7 +55,7 @@ createStratumId <- function(factorLevels) { ) } - factorLevel <- factorLevels.get(factorName) + factorLevel <- factorLevels[[factorName]] if (is.null(factorLevel) || nchar(trimws(factorLevel)) == 0) { stop("The specified factor level (#", counter, ") is invalid") } diff --git a/R/f_seed.R b/R/f_seed.R index fa0b85b..722fdac 100644 --- a/R/f_seed.R +++ b/R/f_seed.R @@ -78,8 +78,6 @@ #' is better than the pseudo-random number algorithms typically used #' in computer programs. For more information see \url{https://www.random.org}. #' -#' @seealso \link{getSimulatedTwoArmMeans} -#' #' @return an integer value or vector containing one or more seeds. #' #' @export diff --git a/man/createSeed.Rd b/man/createSeed.Rd index e3b9d91..5fa800d 100644 --- a/man/createSeed.Rd +++ b/man/createSeed.Rd @@ -27,6 +27,3 @@ The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs. For more information see \url{https://www.random.org}. } -\seealso{ -\link{getSimulatedTwoArmMeans} -} diff --git a/man/getRandomBlockSizeRandomizer.Rd b/man/getRandomBlockSizeRandomizer.Rd index 9d9fe13..9e4674c 100644 --- a/man/getRandomBlockSizeRandomizer.Rd +++ b/man/getRandomBlockSizeRandomizer.Rd @@ -9,6 +9,8 @@ getRandomBlockSizeRandomizer(blockSizes, ..., seed = NA_integer_) \arguments{ \item{blockSizes}{List of block size configurations, each mapping treatment arm IDs to sizes.} +\item{...}{Additional arguments (currently unused).} + \item{seed}{Integer random seed used for reproducibility.} } \value{