refactor(notes): simplify aggregate-fallback predicate in .notes_column
The plan-supplied predicate combined three redundant checks (is.null + any + %in% TRUE). Element-wise behavior was correct via scalar recycling, but the form was confusing — a code-quality reviewer misread it as a multi-row false-positive bug. Simplify to mirror the parts[[2]] structure: gate on column presence, then element-wise %in% TRUE check. Equivalent semantics, fewer ways to misread.
This commit is contained in:
+6
-4
@@ -189,11 +189,13 @@ cog_spending <- function(govid, years, category = NULL,
|
|||||||
if (n == 0L) return(character(0))
|
if (n == 0L) return(character(0))
|
||||||
parts <- vector("list", 2L)
|
parts <- vector("list", 2L)
|
||||||
agg <- result[["aggregate_fallback"]]
|
agg <- result[["aggregate_fallback"]]
|
||||||
parts[[1]] <- ifelse(
|
parts[[1]] <- if (!is.null(agg)) {
|
||||||
!is.null(agg) & isTRUE(any(agg, na.rm = TRUE)) & agg %in% TRUE,
|
ifelse(agg %in% TRUE,
|
||||||
"Aggregate fallback applied; see cog_explain()",
|
"Aggregate fallback applied; see cog_explain()",
|
||||||
NA_character_
|
NA_character_)
|
||||||
)
|
} else {
|
||||||
|
rep(NA_character_, n)
|
||||||
|
}
|
||||||
ps <- result[["pop_source"]]
|
ps <- result[["pop_source"]]
|
||||||
parts[[2]] <- if (!is.null(ps)) {
|
parts[[2]] <- if (!is.null(ps)) {
|
||||||
ifelse(ps == "unavailable",
|
ifelse(ps == "unavailable",
|
||||||
|
|||||||
Reference in New Issue
Block a user