
Detect Lost Glue Brace in glue and cli Expressions
Source: R/14A_package_lost_glue_brace.R, R/14_detect_lost_glue_brace.R
detect_lost_glue_brace.RdCheck whether { and } are balanced in all glue() / glue_data()
and cli_*() string arguments within an R file. The file is parsed into
an AST, then each string literal that is an argument to a target function
is checked with a stack-based brace matcher. Any mismatches are reported
with line number and a visual caret (^^^^) marker under the problematic
region.
Usage
package_lost_glue_brace(path = NULL, test_included = TRUE, ...)
detect_lost_glue_brace(path = NULL, ...)Value
Invisibly returns TRUE if all expressions are balanced, FALSE
otherwise. Side-effect messages are emitted via cli::cli.
Functions
package_lost_glue_brace(): Scans all.Rfiles in an R package (and optionallytests/testthat/), aggregated with per-file reporting.
Examples
# \donttest{
file <- tempfile()
writeLines("glue(\"{a\")", file)
detect_lost_glue_brace(file)
#> glue("{a")
#> ^^
#> ✖ Found 1 line with mismatched braces: 1
# }