## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----setup-------------------------------------------------------------------- # library(checkhelper) ## ----------------------------------------------------------------------------- # pkg <- "/path/to/the/package" # # # 1. Run R CMD check ONCE and reuse it everywhere it's needed. # chk <- rcmdcheck::rcmdcheck(pkg, args = "--as-cran") # # # 2. Static audits (no extra check needed). # audit_tags(pkg) # exported funs without @return / internals without @noRd # audit_ascii(pkg) # non-ASCII characters in R/, tests/, vignettes/, man/, DESCRIPTION, NAMESPACE # audit_dataset_doc(pkg) # datasets in data/ without a roxygen block # audit_citation(pkg) # old-style personList() / citEntry() in inst/CITATION # audit_dontrun(pkg) # \dontrun{} blocks in man/*.Rd # audit_description(pkg) # unquoted package names in DESCRIPTION's Description field # audit_downloads(pkg) # network / download call sites to review for offline-safe guards # # # 3. Audits that need the check output - pass `chk` to skip a 2nd run. # audit_globals(pkg, checks = chk) # # # 4. Apply the safe fixes. # fix_globals(pkg, checks = chk, write = TRUE) # # # Preview before applying: fix_ascii() returns invisibly, so capture # # it to see which files would change. # preview <- fix_ascii(pkg, dry_run = TRUE) # preview[preview$changed, ] # fix_ascii(pkg, dry_run = FALSE) # then apply # # fix_dataset_doc("my_data", pkg = pkg, # description = "Description of my_data", # source = "Internal") # one call per undocumented dataset ## ----------------------------------------------------------------------------- # chk <- rcmdcheck::rcmdcheck(pkg, args = "--as-cran") # # audit_globals(pkg, checks = chk) # fix_globals(pkg, checks = chk, write = TRUE) ## ----------------------------------------------------------------------------- # audit_globals(pkg, checks = chk) # fix_globals(pkg, checks = chk, write = TRUE) ## ----------------------------------------------------------------------------- # audit_tags(pkg) ## ----------------------------------------------------------------------------- # audit_ascii(pkg) # # # Always preview which files would change. fix_ascii() returns # # invisibly - capture the result to inspect per-file detail # # (path, changed, n_tokens, n_chars). # preview <- fix_ascii(pkg, dry_run = TRUE) # preview[preview$changed, ] # # # Apply when you've reviewed the proposed rewrite. # fix_ascii(pkg, dry_run = FALSE) ## ----------------------------------------------------------------------------- # audit_dataset_doc(pkg) # # fix_dataset_doc("my_data", # pkg = pkg, # description = "Description of my_data", # source = "Internal") ## ----------------------------------------------------------------------------- # audit_citation(pkg) ## ----------------------------------------------------------------------------- # audit_description(pkg) ## ----------------------------------------------------------------------------- # audit_downloads(pkg) ## ----------------------------------------------------------------------------- # audit_dontrun(pkg) ## ----------------------------------------------------------------------------- # pkg <- create_example_pkg(with_nonascii = TRUE, # with_undocumented_data = TRUE) # # chk <- rcmdcheck::rcmdcheck(pkg, args = "--as-cran") # # audit_tags(pkg) # @return / @noRd issues # audit_ascii(pkg) # accents in comments / strings # audit_dataset_doc(pkg) # data/demo_dataset.rda has no doc # audit_citation(pkg) # old-style personList() / citEntry() # audit_dontrun(pkg) # \dontrun{} blocks in examples # audit_description(pkg) # unquoted package names in Description # audit_downloads(pkg) # network call sites to review for offline-safe guards # audit_globals(pkg, checks = chk) # # fix_globals(pkg, checks = chk, write = TRUE) # fix_ascii(pkg, dry_run = FALSE) # fix_dataset_doc("demo_dataset", pkg = pkg, # description = "A small demo dataset", # source = "Generated by create_example_pkg()")