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) ========================================================== 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 7cdbf42a..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) + 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") @@ -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,}), (?