From f3323e0f334dee23b44fa2667f1f82bc2f63186b Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Tue, 11 Jul 2023 18:29:13 -0500 Subject: [PATCH 01/13] revdep --- cran-comments.md | 35 ++++++++++++++++++++++------------- revdep/README.md | 32 ++++++++++++++++---------------- revdep/cran.md | 2 +- revdep/problems.md | 15 ++++++++------- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 951ab699..a4e1b4d7 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -9,13 +9,13 @@ Test environments ----------------------------------------------- 1. Local Ubuntu, R 4.2.2 -2. Local Win10, R 4.2.3 patched +2. Local Win11, R 4.3.1 patched 3. R-hub - 1. [Ubuntu Linux 20.04 LTS, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-aa1d5ab8d07d453db1f07927d1ad23f4) + 1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-aa1d5ab8d07d453db1f07927d1ad23f4) 2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a56bc6477bbb48d2a4aa5d1872481dac) - 3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-34917c524b674b82860b920d177844f1) -4. [win-builder](https://win-builder.r-project.org/eG6x3HZ9ITqN), development version. -5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 20.04 LTS + 3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a8833d5bd66847c38c3890470eb2d97a) +4. [win-builder](https://win-builder.r-project.org/BS3KTA59FLDi/), development version. +5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 22.04 LTS R CMD check results ----------------------------------------------- @@ -27,29 +27,38 @@ R CMD check results * * * - * -* There is one NOTE that is only found on R-hub Windows (Server 2022, R-devel 64-bit): +* There is twos NOTEs across the R-hub builds: ```txt * checking for detritus in the temp directory ... NOTE Found the following files/directories: 'lastMiKTeXException' - As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored. ``` - -* There is one NOTE that is only found on the R-hub Fedora: + As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored. ```txt * checking HTML version of manual ... NOTE Skipping checking HTML validation: no command 'tidy' found ``` - Based on [this discussion](https://groups.google.com/g/r-sig-mac/c/7u_ivEj4zhM?pli=1), it sounds like a problem with the testing environment, and not the package code. + Based on [this discussion](https://groups.google.com/g/r-sig-mac/c/7u_ivEj4zhM?pli=1) + and [this SO answer](https://stackoverflow.com/a/75007979/1082435), + it sounds like a problem with the testing environment and not the package code. Downstream dependencies ----------------------------------------------- -No downstream packages are affected. The package that depends/imports/suggests REDCapR passes checks with `revdepcheck::revdep_check()`. Results: +Packages that depend/import/suggest REDCapR pass checks with `revdepcheck::revdep_check()`. +I talked to the tidyREDCap developer last month, and he says the problem is unrelated to REDCapR. + +package | E | W | N +------- | - | - | - +codified 0.3.0 | E: 0 | W: 0 | N: 0 +REDCapDM 0.7.0 | E: 0 | W: 0 | N: 1 +REDCapCAST 23.6.2 | E: 0 | W: 0 | N: 0 +REDCapTidieR 0.4.0 | E: 1 | W: 0 | N: 0 +tidyREDCap 1.1.1 | E: 0 +1 | W: 0 | N: 0 +ReviewR 2.3.8 | E: 0 | W: 0 | N: 1 -* [ReviewR](https://CRAN.R-project.org/package=ReviewR) +Results: diff --git a/revdep/README.md b/revdep/README.md index 8db6dd9f..22a8cf49 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -2,17 +2,17 @@ |field |value | |:--------|:------------------------------------------------| -|version |R version 4.2.3 Patched (2023-03-29 r84127 ucrt) | -|os |Windows 10 x64 (build 22621) | +|version |R version 4.3.1 Patched (2023-07-06 r84647 ucrt) | +|os |Windows 11 x64 (build 22621) | |system |x86_64, mingw32 | |ui |RStudio | |language |(EN) | |collate |English_United States.utf8 | |ctype |English_United States.utf8 | |tz |America/Chicago | -|date |2023-04-21 | -|rstudio |2023.03.0+386 Cherry Blossom (desktop) | -|pandoc |NA | +|date |2023-07-11 | +|rstudio |2023.06.1+524 Mountain Hydrangea (desktop) | +|pandoc |3.1.5 @ C:\PROGRA~1\Pandoc\pandoc.exe | # Dependencies @@ -23,19 +23,19 @@ |backports |1.4.1 |1.4.1 | | |bit |4.0.5 |4.0.5 | | |bit64 |4.0.5 |4.0.5 | | -|checkmate |2.1.0 |2.1.0 | | +|checkmate |2.2.0 |2.2.0 | | |cli |3.6.1 |3.6.1 | | |clipr |0.8.0 |0.8.0 | | -|cpp11 |0.4.3 |0.4.3 | | +|cpp11 |0.4.4 |0.4.4 | | |crayon |1.5.2 |1.5.2 | | -|curl |5.0.0 |5.0.0 | | +|curl |5.0.1 |5.0.1 | | |dplyr |1.1.2 |1.1.2 | | |fansi |1.0.4 |1.0.4 | | |generics |0.1.3 |0.1.3 | | |glue |1.6.2 |1.6.2 | | |hms |1.1.3 |1.1.3 | | -|httr |1.4.5 |1.4.5 | | -|jsonlite |1.8.4 |1.8.4 | | +|httr |1.4.6 |1.4.6 | | +|jsonlite |1.8.7 |1.8.7 | | |lifecycle |1.0.3 |1.0.3 | | |magrittr |2.0.3 |2.0.3 | | |mime |0.12 |0.12 | | @@ -47,17 +47,17 @@ |purrr |1.0.1 |1.0.1 | | |R6 |2.5.1 |2.5.1 | | |readr |2.1.4 |2.1.4 | | -|rlang |1.1.0 |1.1.0 | | +|rlang |1.1.1 |1.1.1 | | |stringi |1.7.12 |1.7.12 | | |stringr |1.5.0 |1.5.0 | | -|sys |3.4.1 |3.4.1 | | +|sys |3.4.2 |3.4.2 | | |tibble |3.2.1 |3.2.1 | | |tidyr |1.3.0 |1.3.0 | | |tidyselect |1.2.0 |1.2.0 | | -|tzdb |0.3.0 |0.3.0 | | +|tzdb |0.4.0 |0.4.0 | | |utf8 |1.2.3 |1.2.3 | | -|vctrs |0.6.2 |0.6.2 | | -|vroom |1.6.1 |1.6.1 | | +|vctrs |0.6.3 |0.6.3 | | +|vroom |1.6.3 |1.6.3 | | |withr |2.5.0 |2.5.0 | | # Revdeps @@ -66,5 +66,5 @@ |package |version |error |warning |note | |:----------|:-------|:------|:-------|:----| -|[tidyREDCap](problems.md#tidyredcap)|1.1.0 |__+1__ | | | +|[tidyREDCap](problems.md#tidyredcap)|1.1.1 |__+1__ | | | diff --git a/revdep/cran.md b/revdep/cran.md index b2f0ae3d..d26ba484 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,6 +1,6 @@ ## revdepcheck results -We checked 5 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 6 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. * We saw 1 new problems * We failed to check 0 packages diff --git a/revdep/problems.md b/revdep/problems.md index 3b9e3355..0ddeaf2c 100644 --- a/revdep/problems.md +++ b/revdep/problems.md @@ -2,11 +2,11 @@
-* Version: 1.1.0 -* GitHub: -* Source code: -* Date/Publication: 2023-02-18 18:10:02 UTC -* Number of recursive dependencies: 82 +* Version: 1.1.1 +* GitHub: https://github.com/RaymondBalise/tidyREDCap +* Source code: https://github.com/cran/tidyREDCap +* Date/Publication: 2023-05-29 16:30:02 UTC +* Number of recursive dependencies: 88 Run `revdepcheck::revdep_details(, "tidyREDCap")` for more info @@ -31,8 +31,9 @@ Run `revdepcheck::revdep_details(, "tidyREDCap")` for more info 16. └─vctrs:::stop_names(...) 17. └─vctrs:::stop_vctrs(...) 18. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call) - - [ FAIL 1 | WARN 0 | SKIP 0 | PASS 4 ] + + [ FAIL 1 | WARN 8 | SKIP 0 | PASS 13 ] Error: Test failures Execution halted ``` + From 58aa4dd2f00df61818fcc0c8162db408f24829ee Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Tue, 11 Jul 2023 18:57:59 -0500 Subject: [PATCH 02/13] Update cran-comments.md ref #479 --- cran-comments.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index a4e1b4d7..66299fc1 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -11,8 +11,8 @@ Test environments 1. Local Ubuntu, R 4.2.2 2. Local Win11, R 4.3.1 patched 3. R-hub - 1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-aa1d5ab8d07d453db1f07927d1ad23f4) - 2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a56bc6477bbb48d2a4aa5d1872481dac) + 1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-ca31dc0eef2e4d6f82ea439a64125d94) + 2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-04e47bc289634445aeafd374a16db8d3) 3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a8833d5bd66847c38c3890470eb2d97a) 4. [win-builder](https://win-builder.r-project.org/BS3KTA59FLDi/), development version. 5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 22.04 LTS @@ -22,13 +22,7 @@ R CMD check results * No ERRORs or WARNINGs on any builds. -* A NOTE is returned for a few websites. All are accessible by browser. - * is a site accessible only to REDCap administrators - * - * - * - -* There is twos NOTEs across the R-hub builds: +* There are two NOTEs across the R-hub builds: ```txt * checking for detritus in the temp directory ... NOTE From 1417f8e367a29d756473d8626f5194a44b312b6b Mon Sep 17 00:00:00 2001 From: Blair Cooper Date: Wed, 12 Jul 2023 21:05:02 -0700 Subject: [PATCH 03/13] Handle leading space in REDCap checkbox options fixes #495 - Modifed pattern_checkboxes regular expression to allow for case where there is no space before the pipe character in the Lookbehind and Lookahead expressions, and do lazy expansion of the label capture group to avoid picking up a space a the end of a label. - Created test case to verify correct handling when a checkbox option has a leading space. --- R/metadata-utilities.R | 2 +- tests/testthat/test-metadata-utilities.R | 34 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/R/metadata-utilities.R b/R/metadata-utilities.R index 7cdbf42a..56a8e8bb 100644 --- a/R/metadata-utilities.R +++ b/R/metadata-utilities.R @@ -114,7 +114,7 @@ regex_named_captures <- function(pattern, text, perl = TRUE) { checkbox_choices <- function(select_choices) { checkmate::assert_character(select_choices, any.missing=FALSE, len=1, min.chars=1) - pattern_checkboxes <- "(?<=\\A| \\| )(?\\d{1,}), (?
From 56f11f9fa4352081dc6a6452292cfc709669986c Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 15:21:18 -0500 Subject: [PATCH 06/13] avoid nesting `paste()` inside `stop()` I want to wrap lines inside `sprintf()` ref #497 --- R/redcap-metadata-coltypes.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/redcap-metadata-coltypes.R b/R/redcap-metadata-coltypes.R index fb212f09..3f6eaf7f 100644 --- a/R/redcap-metadata-coltypes.R +++ b/R/redcap-metadata-coltypes.R @@ -306,7 +306,7 @@ redcap_metadata_internal <- function( if (is.na(d_proj$has_repeating_instruments_or_events[1])) { # nocov start # Don't test coverage for this block b/c it only executes for old versions of REDCap - stop( + error_message <- sprintf( paste( "The REDCap instance at %s failed to report if the", @@ -314,7 +314,7 @@ redcap_metadata_internal <- function( ), redcap_uri ) - ) + stop(error_message) } # nocov end if (d_proj$has_repeating_instruments_or_events[1]) { From abb9100dafa78fa1474f15403656641625f5905f Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 15:34:41 -0500 Subject: [PATCH 07/13] replace native pipes for now --- R/validate.R | 12 ++++++------ tests/testthat/test-arm-export.R | 2 +- tests/testthat/test-event-read.R | 2 +- tests/testthat/test-project-info-read.R | 6 +++--- tests/testthat/test-validate-no-logical.R | 14 +++++++------- tests/testthat/test-validate-repeat.R | 2 +- tests/testthat/test-validate.R | 14 +++++++------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/R/validate.R b/R/validate.R index 18c4341d..5518a600 100644 --- a/R/validate.R +++ b/R/validate.R @@ -272,8 +272,8 @@ validate_record_id_name <- function( suggestion = character(0) ) } else if (stop_on_error) { - "The field called `%s` is not found in the dataset.\nAdjust the value passed to the `record_id_name` if this isn't the correct named used by your specific REDCap project." |> - sprintf(record_id_name) |> + "The field called `%s` is not found in the dataset.\nAdjust the value passed to the `record_id_name` if this isn't the correct named used by your specific REDCap project." %>% + sprintf(record_id_name) %>% stop() } else { tibble::tibble( @@ -335,11 +335,11 @@ validate_uniqueness <- function(d, record_id_name = "record_id", stop_on_error = variables <- intersect(colnames(d), plumbing) d_replicates <- - d |> + d %>% dplyr::count( !!!rlang::parse_exprs(variables), name = "count_of_records" - ) |> + ) %>% dplyr::filter(1L < count_of_records) if (nrow(d_replicates) == 0L) { @@ -359,8 +359,8 @@ validate_uniqueness <- function(d, record_id_name = "record_id", stop_on_error = paste(d_replicates, collapse = "\n") # nocov } - "There are %i record(s) that violate the uniqueness requirement:\n%s" |> - sprintf(nrow(d_replicates), m) |> + "There are %i record(s) that violate the uniqueness requirement:\n%s" %>% + sprintf(nrow(d_replicates), m) %>% stop() } else { indices <- paste(which(colnames(d) == variables), collapse = ", ") diff --git a/tests/testthat/test-arm-export.R b/tests/testthat/test-arm-export.R index b64d88eb..fe824484 100644 --- a/tests/testthat/test-arm-export.R +++ b/tests/testthat/test-arm-export.R @@ -9,7 +9,7 @@ read_arms <- function(path) { arm_num = readr::col_integer(), name = readr::col_character() ) - full_path |> + full_path %>% readr::read_csv(col_types = col_types) %>% dplyr::select( arm_number = "arm_num", diff --git a/tests/testthat/test-event-read.R b/tests/testthat/test-event-read.R index ee17647e..85fd4477 100644 --- a/tests/testthat/test-event-read.R +++ b/tests/testthat/test-event-read.R @@ -13,7 +13,7 @@ retrieve_expected_events <- function(path) { event_id = readr::col_integer() ) - full_path |> + full_path %>% readr::read_csv(col_types = col_types) } diff --git a/tests/testthat/test-project-info-read.R b/tests/testthat/test-project-info-read.R index f3cb761f..f50e467f 100644 --- a/tests/testthat/test-project-info-read.R +++ b/tests/testthat/test-project-info-read.R @@ -48,13 +48,13 @@ test_that("all-test-projects", { server_locale <- readr::locale(tz = "America/Chicago") returned_object <- - system.file("misc/example.credentials", package = "REDCapR") |> + system.file("misc/example.credentials", package = "REDCapR") %>% readr::read_csv( comment = "#", col_select = c(redcap_uri, token), col_types = readr::cols(.default = readr::col_character()), - ) |> - dplyr::filter(32L == nchar(token)) |> + ) %>% + dplyr::filter(32L == nchar(token)) %>% purrr::pmap_dfr( REDCapR::redcap_project_info_read, locale = server_locale, diff --git a/tests/testthat/test-validate-no-logical.R b/tests/testthat/test-validate-no-logical.R index 8fbcd1e5..1d80ecef 100644 --- a/tests/testthat/test-validate-no-logical.R +++ b/tests/testthat/test-validate-no-logical.R @@ -43,9 +43,9 @@ test_that("repeat-instance: no column", { # test_that("repeat-instance: good integer", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> -# readr::read_csv(show_col_types = FALSE) |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% +# readr::read_csv(show_col_types = FALSE) %>% # dplyr::mutate( # redcap_repeat_instance = as.integer(redcap_repeat_instance), # ) @@ -55,8 +55,8 @@ test_that("repeat-instance: no column", { # }) # test_that("repeat-instance: bad double", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # ds_1 <- validate_repeat_instance(d) @@ -74,8 +74,8 @@ test_that("repeat-instance: no column", { # # test_that("repeat-instance: bad double -stop on error", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # expect_error( diff --git a/tests/testthat/test-validate-repeat.R b/tests/testthat/test-validate-repeat.R index 36f7b96e..1f4c5830 100644 --- a/tests/testthat/test-validate-repeat.R +++ b/tests/testthat/test-validate-repeat.R @@ -7,7 +7,7 @@ test_that("validate_repeat_instance: no column", { test_that("validate_repeat_instance: good", { d <- - mtcars |> + mtcars %>% dplyr::mutate( redcap_repeat_instance = sample(1:100, size = 32, replace = TRUE) ) diff --git a/tests/testthat/test-validate.R b/tests/testthat/test-validate.R index 921f1543..a0762c20 100644 --- a/tests/testthat/test-validate.R +++ b/tests/testthat/test-validate.R @@ -49,9 +49,9 @@ test_that("not a data.frame", { # test_that("repeat-instance: good integer", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> -# readr::read_csv(show_col_types = FALSE) |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% +# readr::read_csv(show_col_types = FALSE) %>% # dplyr::mutate( # redcap_repeat_instance = as.integer(redcap_repeat_instance), # ) @@ -61,8 +61,8 @@ test_that("not a data.frame", { # }) # test_that("repeat-instance: bad double", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # ds_1 <- validate_repeat_instance(d) @@ -80,8 +80,8 @@ test_that("not a data.frame", { # # test_that("repeat-instance: bad double -stop on error", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # expect_error( From 633a6565318972848182669c969cef2295d43635 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 23:30:30 -0500 Subject: [PATCH 08/13] only one element can be passed to `perl` kinda related to #495 --- R/metadata-utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/metadata-utilities.R b/R/metadata-utilities.R index 56a8e8bb..7e2942b0 100644 --- a/R/metadata-utilities.R +++ b/R/metadata-utilities.R @@ -86,7 +86,7 @@ regex_named_captures <- function(pattern, text, perl = TRUE) { checkmate::assert_character(pattern, any.missing=FALSE, min.chars=0L, len=1) checkmate::assert_character(text , any.missing=FALSE, min.chars=0L, len=1) - checkmate::assert_logical( perl , any.missing=FALSE) + checkmate::assert_logical( perl , any.missing=FALSE , len=1) match <- gregexpr(pattern, text, perl = perl)[[1]] capture_names <- attr(match, "capture.names") From a6c1f0668ef6890980688db739b1927dad769e74 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 23:33:42 -0500 Subject: [PATCH 09/13] include @BlairCooper's issue in the news ref #495 --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index bd86d2d8..f5877ae2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -89,6 +89,7 @@ This will help extract forms from longitudinal & repeating projects. * `validate_repeat_instance()` * `validate_no_logical()` * `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493) +* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495) Version 1.1.0 (released 2022-08-10) ========================================================== From 70fafd7883d48d3f21fa6b4a90b616bf773de5f3 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 23:33:58 -0500 Subject: [PATCH 10/13] tidy --- tests/testthat/test-read-errors.R | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tests/testthat/test-read-errors.R b/tests/testthat/test-read-errors.R index cfa9637e..a292e91f 100644 --- a/tests/testthat/test-read-errors.R +++ b/tests/testthat/test-read-errors.R @@ -9,29 +9,17 @@ test_that("One Shot: Bad Uri -Not HTTPS", { # expected_message_501 <- "The requested method is not implemented." expect_error( - # returned_object <- - redcap_read_oneshot( - redcap_uri = "http://bbmc.ouhsc.edu/redcap/api/", # Not HTTPS - token = credential$token - ) + redcap_read_oneshot( + redcap_uri = "http://bbmc.ouhsc.edu/redcap/api/", # Not HTTPS + token = credential$token + ) ) - - # expect_equal(returned_object$data, expected=data.frame(), label="An empty data.frame should be returned.") - # expect_true(returned_object$status_code %in% c(411L, 501L)) - # expect_true(returned_object$raw_text %in% c(expected_message_411, expected_message_501)) - # # expect_equal(returned_object$raw_text, expected=expected_message) - # expect_equal(returned_object$records_collapsed, "") - # expect_equal(returned_object$fields_collapsed, "") - # expect_false(returned_object$success) }) test_that("One Shot: Bad Uri -wrong address", { testthat::skip_on_cran() expected_message <- "\n\n404 Not Found\n\n

Not Found

\n

The requested URL was not found on this server.

\n\n" - # expected_outcome_message <- "The initial call failed with the code: 404." - # expected_outcome_message <- "The requested URL was not found on this server." - returned_object <- redcap_read_oneshot( redcap_uri = "https://bbmc.ouhsc.edu/redcap/apiFFFFFFFFFFFFFF/", # Wrong url From 3c217b922b0b5efc27e0cb41f91f9521a73970d8 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Fri, 14 Jul 2023 07:50:53 -0500 Subject: [PATCH 11/13] some styler suggestions ref #498 --- R/constant.R | 2 +- R/create-batch-glossary.R | 4 ++-- R/kernel-api.R | 17 ++++++++--------- R/metadata-utilities.R | 6 +++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/R/constant.R b/R/constant.R index 272e41fc..438213f0 100644 --- a/R/constant.R +++ b/R/constant.R @@ -23,7 +23,7 @@ #' #' The current constants relate to the 'complete' variable at the #' end of each form. -#' * `form_incomplete`: 0L (*i.e.*, an integer) +#' * `form_incomplete`: 0L (_i.e._, an integer) #' * `form_unverified`: 1L #' * `form_complete`: 2L #' diff --git a/R/create-batch-glossary.R b/R/create-batch-glossary.R index b79df31c..27551e15 100644 --- a/R/create-batch-glossary.R +++ b/R/create-batch-glossary.R @@ -71,12 +71,12 @@ create_batch_glossary <- function(row_count, batch_size) { start_index <- as.integer(base::seq.int(from=1L, to=row_count, by=batch_size)) - ds_batch <- + ds_batch <- tibble::tibble( id = seq_along(start_index), start_index = start_index ) - ds_batch$stop_index <- + ds_batch$stop_index <- base::mapply( function(i) { base::ifelse( diff --git a/R/kernel-api.R b/R/kernel-api.R index 5e0374cb..2f6e4dfa 100644 --- a/R/kernel-api.R +++ b/R/kernel-api.R @@ -41,16 +41,16 @@ #' token <- "9A81268476645C4E5F03428B8AC3AA7B" #' post_body <- list( #' token = token, -#' content = 'project', -#' format = 'csv' +#' content = "project", +#' format = "csv" #' ) #' \dontrun{ #' kernel <- REDCapR:::kernel_api(uri, post_body, config_options) #' #' # Consume the results in a few different ways. #' kernel$result -#' read.csv(text=kernel$raw_text) -#' as.list(read.csv(text=kernel$raw_text)) +#' read.csv(text = kernel$raw_text) +#' as.list(read.csv(text = kernel$raw_text)) #' } kernel_api <- function( @@ -83,9 +83,9 @@ kernel_api <- function( httr::user_agent("OuhscBbmc/REDCapR") ) - status_code <- response$status - success <- (status_code == 200L) - raw_text <- httr::content( + status_code <- response$status + success <- (status_code == 200L) + raw_text <- httr::content( x = response, as = "text", encoding = encoding, # UTF-8 is the default parameter value @@ -104,7 +104,7 @@ kernel_api <- function( any(grepl(regex_cannot_connect, raw_text)) #|| # any(grepl(regex_empty , raw_text)) ) { - success <- FALSE # nocov + success <- FALSE # nocov } return(list( @@ -114,7 +114,6 @@ kernel_api <- function( elapsed_seconds = elapsed_seconds, result = response, result_headers = response$headers, - regex_empty = regex_empty )) } diff --git a/R/metadata-utilities.R b/R/metadata-utilities.R index 7e2942b0..6e22a21b 100644 --- a/R/metadata-utilities.R +++ b/R/metadata-utilities.R @@ -84,9 +84,9 @@ #' @export regex_named_captures <- function(pattern, text, perl = TRUE) { - checkmate::assert_character(pattern, any.missing=FALSE, min.chars=0L, len=1) - checkmate::assert_character(text , any.missing=FALSE, min.chars=0L, len=1) - checkmate::assert_logical( perl , any.missing=FALSE , len=1) + checkmate::assert_character(pattern, any.missing = FALSE, min.chars=0L, len=1) + checkmate::assert_character(text , any.missing = FALSE, min.chars=0L, len=1) + checkmate::assert_logical( perl , any.missing = FALSE, min.chars=0L, len=1) match <- gregexpr(pattern, text, perl = perl)[[1]] capture_names <- attr(match, "capture.names") From 4dfe3738668ceccc7548dc6a7738bbcc660b0e62 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Fri, 14 Jul 2023 08:06:15 -0500 Subject: [PATCH 12/13] removed extra "min.chars" argument --- R/metadata-utilities.R | 6 +++--- man/kernel_api.Rd | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/metadata-utilities.R b/R/metadata-utilities.R index 6e22a21b..0d4a2f4b 100644 --- a/R/metadata-utilities.R +++ b/R/metadata-utilities.R @@ -84,9 +84,9 @@ #' @export regex_named_captures <- function(pattern, text, perl = TRUE) { - checkmate::assert_character(pattern, any.missing = FALSE, min.chars=0L, len=1) - checkmate::assert_character(text , any.missing = FALSE, min.chars=0L, len=1) - checkmate::assert_logical( perl , any.missing = FALSE, min.chars=0L, len=1) + checkmate::assert_character(pattern, any.missing = FALSE, len = 1, min.chars = 0L) + checkmate::assert_character(text , any.missing = FALSE, len = 1, min.chars = 0L) + checkmate::assert_logical( perl , any.missing = FALSE, len = 1 ) match <- gregexpr(pattern, text, perl = perl)[[1]] capture_names <- attr(match, "capture.names") diff --git a/man/kernel_api.Rd b/man/kernel_api.Rd index a54b3daa..a2b613b4 100644 --- a/man/kernel_api.Rd +++ b/man/kernel_api.Rd @@ -61,15 +61,15 @@ uri <- "https://bbmc.ouhsc.edu/redcap/api/" token <- "9A81268476645C4E5F03428B8AC3AA7B" post_body <- list( token = token, - content = 'project', - format = 'csv' + content = "project", + format = "csv" ) \dontrun{ kernel <- REDCapR:::kernel_api(uri, post_body, config_options) # Consume the results in a few different ways. kernel$result -read.csv(text=kernel$raw_text) -as.list(read.csv(text=kernel$raw_text)) +read.csv(text = kernel$raw_text) +as.list(read.csv(text = kernel$raw_text)) } } From 53bc3e16411c38c1de65c9950a8daf2352bc72b3 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Fri, 14 Jul 2023 13:25:37 -0500 Subject: [PATCH 13/13] update cran-comments ref #479 --- cran-comments.md | 17 ++++++++++------- revdep/README.md | 2 +- utility/refresh.R | 12 +++++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 66299fc1..a3c1cd59 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,7 @@ Description =============================================== -This submission is primarily to address a recent change in the REDCap server. +This submission is primarily to address a change in the REDCap server. A lot of packages additions in the meantime were building up. Thank you for taking the time to review my submission, and please tell me if there's something else I should do for CRAN. -Will Beasley @@ -11,10 +11,10 @@ Test environments 1. Local Ubuntu, R 4.2.2 2. Local Win11, R 4.3.1 patched 3. R-hub - 1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-ca31dc0eef2e4d6f82ea439a64125d94) - 2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-04e47bc289634445aeafd374a16db8d3) - 3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a8833d5bd66847c38c3890470eb2d97a) -4. [win-builder](https://win-builder.r-project.org/BS3KTA59FLDi/), development version. + 1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-746e237d11914129b4410114fbfa2c83) + 2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-e695d8a48601419e8059863cc80964b7) + 3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-c30d344462dc43a4b03e68a33be664d9) +4. [win-builder](https://win-builder.r-project.org/0u5J1JiksFZg/), development version. 5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 22.04 LTS R CMD check results @@ -43,8 +43,11 @@ R CMD check results Downstream dependencies ----------------------------------------------- -Packages that depend/import/suggest REDCapR pass checks with `revdepcheck::revdep_check()`. -I talked to the tidyREDCap developer last month, and he says the problem is unrelated to REDCapR. +With one exception, +packages that depend/import/suggest REDCapR pass checks with `revdepcheck::revdep_check()`. + +I worked with **tidyREDCap** team and they accepted a PR that fixes the problem: +. package | E | W | N ------- | - | - | - diff --git a/revdep/README.md b/revdep/README.md index 22a8cf49..71226c7c 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -10,7 +10,7 @@ |collate |English_United States.utf8 | |ctype |English_United States.utf8 | |tz |America/Chicago | -|date |2023-07-11 | +|date |2023-07-14 | |rstudio |2023.06.1+524 Mountain Hydrangea (desktop) | |pandoc |3.1.5 @ C:\PROGRA~1\Pandoc\pandoc.exe | diff --git a/utility/refresh.R b/utility/refresh.R index 4d883e2c..3b8da506 100644 --- a/utility/refresh.R +++ b/utility/refresh.R @@ -4,8 +4,6 @@ options(device = deviceType) #https://support.rstudio.org/help/discussions/probl spelling::spell_check_package() # spelling::update_wordlist() -lintr::lint_package() -# lintr::lint("R/redcap-metadata-coltypes.R") urlchecker::url_check(); urlchecker::url_update() devtools::document() @@ -13,6 +11,8 @@ devtools::check_man() #Should return NULL devtools::clean_vignettes() devtools::build_vignettes() +lintr::lint_package() +# lintr::lint("R/redcap-metadata-coltypes.R") checks_to_exclude <- c( "covr", "cyclocomp", @@ -29,6 +29,8 @@ goodpractice::results(gp) gp # If necessary: tinytex::tlmgr_install("makeindex") BiocCheck::BiocCheck() +# styler::style_pkg() +# styler::style_file("R/redcap-read-oneshot.R") devtools::document() pkgdown::clean_site() @@ -40,10 +42,9 @@ devtools::run_examples(); #dev.off() #This overwrites the NAMESPACE file too # devtools::run_examples(, "redcap_read.Rd") # pkgload::load_all() test_results_checked <- devtools::test() -test_results_checked <- devtools::test(filter = "read-batch-survey") test_results_checked <- devtools::test(filter = "^validate") -withr::local_envvar(ONLYREADTESTS = "true") -test_results_checked <- devtools::test(filter = "write-batch") +# withr::local_envvar(ONLYREADTESTS = "true") +# test_results_checked <- devtools::test(filter = "write-batch") # testthat::test_dir("./tests/") test_results_not_checked <- testthat::test_dir("./tests/manual/") @@ -55,6 +56,7 @@ devtools::check( # Equivalent of R-hub remote = TRUE, incoming = TRUE ) +rhub::list_validated_emails(); # rhub::validate_email() rhub::check_for_cran(email="wibeasley@hotmail.com") # devtools::check_win_devel() # CRAN submission policies encourage the development version # revdepcheck::revdep_check(num_workers = 4)