lintr
lintr copied to clipboard
Should we lint code in `glue::glue()` expressions?
Inspired by #942.
Should be possible to do IINM, but not sure how to best report lints found within glue expressions.
stringr::str_interp()
is another interpolation function with similar semantics.
To obtain a list of lints for a particular glue expression, we could lint(..., text = paste(glue_exprs, collapse = "\n"))
and then translate the lints
obtained to location info in the original file.
object_usage_linter()
would need special care not to report undefined variables which are defined in an outer scope, i.e. outside of the glue call.
FWIW I think we should ignore str_interp()
, since it's marked as superseded:
https://stringr.tidyverse.org/reference/str_interp.html
Its successor, str_glue()
should be treated same as glue()
since it's just a wrapper:
stringr::str_glue
function (..., .sep = "", .envir = parent.frame())
{
glue::glue(..., .sep = .sep, .envir = .envir)
}
Since it is mentioned in the README of glue about stringr::str_glue()
, it would be great if it is treated in the same way as glue::glue()
.
https://github.com/tidyverse/glue/blob/d47d6c7701f738f8647b951df418cfd5e6a7bf76/README.md?plain=1#L50-L52