Convenience wrapper that runs the audit, then either prints the
globalVariables(...) block to console (default) or writes it to
R/globals.R. Wraps print_globals().
fix_globals(pkg = ".", write = FALSE, checks = NULL)Path to the package.
If TRUE, write a single globalVariables(...) call
to <pkg>/R/globals.R, merging with whatever names that file
already declares (the freshly detected names are added on top of
the existing ones, deduplicated). Default FALSE (print the
block to the console for manual paste).
Optional. A pre-computed rcmdcheck::rcmdcheck() result
(a list with at least a notes element). When supplied, fix_globals()
reuses it instead of re-running R CMD check on pkg. Useful to share
a single check between audit_globals() and fix_globals().
Invisibly, the path written (when write = TRUE) or NULL.
if (FALSE) { # \dontrun{
pkg <- create_example_pkg()
fix_globals(pkg)
fix_globals(pkg, write = TRUE)
# Reuse a single R CMD check across both audit and fix:
chk <- rcmdcheck::rcmdcheck(pkg)
audit_globals(pkg, checks = chk)
fix_globals(pkg, checks = chk, write = TRUE)
} # }