From 05d3ca941f28e892444b1d8d365eb86ca10718f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 07:29:04 +0000 Subject: [PATCH] Replace glue-style dynamic markup with paste0() construction {.field {variable}} and {.cls {variable}} patterns rely on glue evaluation which is not safe in a zero-dependency package. Replace all four occurrences with paste0("{.field ", var, "}") so the value is baked into the markup string before reaching message_()/stop_(). https://claude.ai/code/session_01XHWLohiSTdZvCutwD7ag2b --- R/sir.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/sir.R b/R/sir.R index 502bb1d92..5e217e9fa 100755 --- a/R/sir.R +++ b/R/sir.R @@ -835,7 +835,7 @@ as.sir.data.frame <- function(x, message_( "Assuming value", plural[1], " ", vector_and(col_values, quotes = TRUE), - " in column {.field {col_specimen}} reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1], + " in column ", paste0("{.field ", col_specimen, "}"), " reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1], ".\n Use `as.sir(uti = FALSE)` to prevent this." ) } @@ -974,7 +974,7 @@ as.sir.data.frame <- function(x, if (!all(x[, ab, drop = TRUE] %in% c("S", "SDD", "I", "R", "NI", NA), na.rm = TRUE)) { show_message <- TRUE if (isTRUE(info)) { - message_("Cleaning values in column {.field {ab}} (", + message_("Cleaning values in column ", paste0("{.field ", ab, "}"), " (", ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""), ab_name(ab_coerced, tolower = TRUE, info = info), ")... ", appendLF = FALSE, @@ -984,7 +984,7 @@ as.sir.data.frame <- function(x, } else if (!is.sir(x.bak[, ab, drop = TRUE])) { show_message <- TRUE if (isTRUE(info)) { - message_("Assigning class {.cls sir} to already clean column {.field {ab}} (", + message_("Assigning class {.cls sir} to already clean column ", paste0("{.field ", ab, "}"), " (", ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""), ab_name(ab_coerced, tolower = TRUE, language = NULL, info = info), ")... ", appendLF = FALSE, @@ -2232,7 +2232,7 @@ check_reference_data <- function(reference_data, .call_depth) { bad_col <- names(class_ref[class_sir != class_ref][1]) bad_cls <- gsub("<|>", "", class_ref[class_sir != class_ref][1]) exp_cls <- gsub("<|>", "", class_sir[class_sir != class_ref][1]) - stop_("{.arg reference_data} must be the same structure as the {.topic [clinical_breakpoints](AMR::clinical_breakpoints)} data set. Column {.field {bad_col}} is of class {.cls {bad_cls}}, but should be of class {.cls {exp_cls}}", call = .call_depth) + stop_("{.arg reference_data} must be the same structure as the {.topic [clinical_breakpoints](AMR::clinical_breakpoints)} data set. Column ", paste0("{.field ", bad_col, "}"), " is of class ", paste0("{.cls ", bad_cls, "}"), ", but should be of class ", paste0("{.cls ", exp_cls, "}"), call = .call_depth) } } }