-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linter for glue strings #252
Comments
It does look like we'll have to do so optionally, here are some false positives in default packages:
|
https://github.com/MichaelChirico/potools/blob/master/R/specials_metadata.R |
@jimhester what would you recommend for detecting (I am fine disallowing any delimiters but |
You could just use a custom transformer with glue to collect the results of the parsing, e.g. res <- character()
collector <- function(expr, envir) {
res <<- append(res, expr)
res
}
invisible(glue::glue("this is a msg with {foo} {bar}", .transformer = collector))
res
#> [1] "foo" "bar" Created on 2021-11-08 by the reprex package (v2.0.1) |
Nice! That looks like a pretty good fit for the use case here. (1) Run It's not very efficient but it shouldn't really matter here. |
If we want to fully support and encourage use of glue strings, it would be nice to check that the
msgstr
contains the same{}
wrapper components as themsgid
.This would protect against folks accidentally translating the variable name:
Or just introducing a typo
The text was updated successfully, but these errors were encountered: