Skip to content
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

Support cli functions in extract_glued_symbols() #2252

Open
Bisaloo opened this issue Oct 31, 2023 · 1 comment
Open

Support cli functions in extract_glued_symbols() #2252

Bisaloo opened this issue Oct 31, 2023 · 1 comment
Labels
feature a feature request or enhancement object linters 🏀

Comments

@Bisaloo
Copy link
Collaborator

Bisaloo commented Oct 31, 2023

# glue::glue passes
lintr::lint(
  text = "foo <- function() { x <- 1; glue::glue('{x}') }",
  linters = lintr::object_usage_linter()
)

# cli functions lint
lintr::lint(
  text = "foo <- function() { x <- 1; cli::cli_h1('{x}') }",
  linters = lintr::object_usage_linter()
)
#> <text>:1:21: warning: [object_usage_linter] local variable 'x' assigned but may not be used
#> foo <- function() { x <- 1; cli::cli_h1('{x}') }
#>                     ^

# This is valid cli usage
x <- 1
cli::cli_h1('{x}')
#> 
#> ── 1 ───────────────────────────────────────────────────────────────────────────

Created on 2023-10-31 with reprex v2.0.2

@MichaelChirico
Copy link
Collaborator

Didn't realize how highly requested this is!

One major issue is that {cli}'s mark-up syntax is much richer than {glue}'s, and there's currently no equivalent for extracting the variables besides custom logic we'd have to maintain & keep in sync:

r-lib/cli#750

In the short term, we could just treat cli exactly like glue, at least capturing simple glue-like interpolations, would that be useful enough as a first step?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement object linters 🏀
Projects
None yet
Development

No branches or pull requests

3 participants