From 68b72faeae4624d0452f3d79117e3d27be51a04d Mon Sep 17 00:00:00 2001 From: Jared Knowles Date: Tue, 28 Apr 2026 10:47:56 -0400 Subject: [PATCH] refactor(search): rename cog_gov_search() first argument to name Pre-rename in preparation for basket mode. All existing callers in this package and cog_explorer/ pass the first argument positionally, so this rename is non-breaking. No deprecation alias added per design spec (no external consumers; package is pre-release v0.1.0). @param roxygen also updated to match the new formal; man/cog_gov_search.Rd regenerated via devtools::document(). --- R/search.R | 12 ++++++------ man/cog_gov_search.Rd | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/search.R b/R/search.R index 01557b1..02ac2c2 100644 --- a/R/search.R +++ b/R/search.R @@ -7,7 +7,7 @@ #' name into one or more `canonical_govid` values before calling #' [cog_spending()] / [cog_revenue()] / etc. #' -#' @param pattern Character regex matched case-insensitively against +#' @param name Character regex matched case-insensitively against #' `gov_name`. `NULL` (default) means no name filter. #' @param state Either a 2-letter USPS abbreviation (e.g. `"FL"`), a FIPS #' integer (e.g. `12`), or `NULL`. @@ -18,7 +18,7 @@ #' @return Tibble from `canonical_fips_xwalk` sorted by `population_acs` #' descending (`NULL`s last). #' @export -cog_gov_search <- function(pattern = NULL, state = NULL, type = NULL) { +cog_gov_search <- function(name = NULL, state = NULL, type = NULL) { if (!is.null(type) && .is_excluded_type(type)) { cli::cli_inform(c( i = "v0.1 covers gov_types 0-3 (state/county/city/township) only.", @@ -29,13 +29,13 @@ cog_gov_search <- function(pattern = NULL, state = NULL, type = NULL) { con <- .ensure_session() preds <- character(0) - if (!is.null(pattern)) { - if (!is.character(pattern) || length(pattern) != 1L) { - cli::cli_abort("`pattern` must be a length-1 character string.") + if (!is.null(name)) { + if (!is.character(name) || length(name) != 1L) { + cli::cli_abort("`name` must be a length-1 character string.") } preds <- c(preds, sprintf("regexp_matches(gov_name, %s, 'i')", - .sql_lit_chr(pattern))) + .sql_lit_chr(name))) } if (!is.null(state)) { st_fips <- .coerce_state_to_fips(state) diff --git a/man/cog_gov_search.Rd b/man/cog_gov_search.Rd index 05f24ee..0d2a0e6 100644 --- a/man/cog_gov_search.Rd +++ b/man/cog_gov_search.Rd @@ -4,10 +4,10 @@ \alias{cog_gov_search} \title{Search for governments by name, state, and/or type} \usage{ -cog_gov_search(pattern = NULL, state = NULL, type = NULL) +cog_gov_search(name = NULL, state = NULL, type = NULL) } \arguments{ -\item{pattern}{Character regex matched case-insensitively against +\item{name}{Character regex matched case-insensitively against `gov_name`. `NULL` (default) means no name filter.} \item{state}{Either a 2-letter USPS abbreviation (e.g. `"FL"`), a FIPS