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

Automate global variables defintition #1463

Open
hadley opened this issue Feb 21, 2024 · 1 comment
Open

Automate global variables defintition #1463

hadley opened this issue Feb 21, 2024 · 1 comment

Comments

@hadley
Copy link
Member

hadley commented Feb 21, 2024

  • Stick to convention that all SQL functions/values should be in upper case
  • Use codetools to find all undefined variables (or maybe just those in sql_expr()?
  • Extract all undefined variables that are uppercase
@hadley
Copy link
Member Author

hadley commented Feb 21, 2024

Something like this:

env <- pkgload::load_all()$env
objs <- as.list(env)
funs <- Filter(is.function, objs)

globals <- lapply(funs, codetools::findGlobals)

known <- c(
  names(pkgload::imports_env("dbplyr")),
  names(pkgload::ns_env("dbplyr")),
  names(pkgload::pkg_env("base"))
)
all_globals <- setdiff(unique(unlist(all_globals)), known)

all_globals <- all_globals[all_globals == toupper(all_globals)]

dput(sort(all_globals))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant