From b903e3c18ae6b17f8e064cbefc2f5f7f37a9a7bd Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 8 Jan 2026 15:58:34 -0600 Subject: [PATCH] `use_air()` --- .Rbuildignore | 2 + .vscode/extensions.json | 5 + .vscode/settings.json | 10 ++ R/active.R | 12 ++- R/build-manual.R | 26 +++-- R/build-readme.R | 28 +++++- R/check-devtools.R | 4 +- R/check-mac.R | 28 ++++-- R/check-win.R | 87 +++++++++++++---- R/check.R | 93 +++++++++++------- R/install.R | 95 ++++++++++++------- R/package.R | 4 +- R/pkgbuild.R | 22 ++++- R/pkgload.R | 20 +++- R/release.R | 48 +++++++--- R/reload.R | 8 +- R/remotes.R | 36 +++++-- R/revdep.R | 34 ++++--- R/run-examples.R | 60 +++++++++--- R/run-source.R | 15 ++- R/session-info.R | 3 +- R/show-news.R | 10 +- R/sitrep.R | 73 ++++++++------ R/spell-check.R | 6 +- R/test.R | 36 ++++--- R/uninstall.R | 7 +- R/vignette-r.R | 4 +- R/vignettes.R | 32 ++++--- R/zzz.R | 4 +- air.toml | 0 tests/spelling.R | 10 +- tests/testthat/test-build-site.R | 27 ++++-- tests/testthat/test-check-doc.R | 17 ++-- tests/testthat/test-check-win.R | 10 +- tests/testthat/test-run-source.R | 1 - tests/testthat/test-sitrep.R | 6 +- tests/testthat/test-test.R | 4 +- tests/testthat/test-utils.R | 5 +- tests/testthat/testError/R/error.R | 1 - .../testPkgdown/R/pkgdown-test-test.R | 1 - tests/testthat/testTest/R/dummy.R | 1 - tests/testthat/testTestWithFailure/R/dummy.R | 1 - tests/testthat/testUseData/R/a.R | 1 - tests/testthat/testVignettesBuilt/R/code.R | 2 +- 44 files changed, 643 insertions(+), 256 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 air.toml diff --git a/.Rbuildignore b/.Rbuildignore index 1fb1046a3..4cd13ab26 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,5 @@ ^\.lintr\.R$ ^notes$ ^CRAN-SUBMISSION$ +^[.]?air[.]toml$ +^\.vscode$ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..344f76eba --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "Posit.air-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a9f69fe41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "[r]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "Posit.air-vscode" + }, + "[quarto]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "quarto.quarto" + } +} diff --git a/R/active.R b/R/active.R index e54f893d8..fe174cfe1 100644 --- a/R/active.R +++ b/R/active.R @@ -1,6 +1,9 @@ find_active_file <- function(arg = "file", call = parent.frame()) { if (!is_rstudio_running()) { - cli::cli_abort("Argument {.arg {arg}} is missing, with no default", call = call) + cli::cli_abort( + "Argument {.arg {arg}} is missing, with no default", + call = call + ) } normalizePath(rstudioapi::getSourceEditorContext()$path) } @@ -18,7 +21,12 @@ find_test_file <- function(path, call = parent.frame()) { pkg <- as.package(dirname(path)) is_test <- type == "test" - path[!is_test] <- paste0(pkg$path, "/tests/testthat/test-", name_source(path[!is_test]), ".R") + path[!is_test] <- paste0( + pkg$path, + "/tests/testthat/test-", + name_source(path[!is_test]), + ".R" + ) path <- unique(path[file_exists(path)]) if (length(path) == 0) { diff --git a/R/build-manual.R b/R/build-manual.R index 0c9112db2..804a58005 100644 --- a/R/build-manual.R +++ b/R/build-manual.R @@ -10,15 +10,23 @@ build_manual <- function(pkg = ".", path = NULL) { pkg <- as.package(pkg) path <- path %||% path_dir(pkg$path) name <- paste0(pkg$package, "_", pkg$version, ".pdf", collapse = " ") - tryCatch(msg <- callr::rcmd("Rd2pdf", cmdargs = c( - "--force", - paste0("--output=", path, "/", name), - pkg$path - ), fail_on_status = TRUE, stderr = "2>&1", spinner = FALSE), - error = function(e) { - cat(e$stdout) - cli::cli_abort("Failed to build manual") - }) + tryCatch( + msg <- callr::rcmd( + "Rd2pdf", + cmdargs = c( + "--force", + paste0("--output=", path, "/", name), + pkg$path + ), + fail_on_status = TRUE, + stderr = "2>&1", + spinner = FALSE + ), + error = function(e) { + cat(e$stdout) + cli::cli_abort("Failed to build manual") + } + ) cat(msg$stdout) invisible(msg) diff --git a/R/build-readme.R b/R/build-readme.R index 174efcdc1..ddd1da7d2 100644 --- a/R/build-readme.R +++ b/R/build-readme.R @@ -11,7 +11,13 @@ #' @inheritParams install #' @inheritParams rmarkdown::render #' @export -build_rmd <- function(files, path = ".", output_options = list(), ..., quiet = TRUE) { +build_rmd <- function( + files, + path = ".", + output_options = list(), + ..., + quiet = TRUE +) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) pkg <- as.package(path) @@ -33,12 +39,16 @@ build_rmd <- function(files, path = ".", output_options = list(), ..., quiet = T # Ensure rendering github_document() doesn't generate HTML file output_options$html_preview <- FALSE - for (path in paths) { cli::cli_inform(c(i = "Building {.path {path}}")) callr::r_safe( function(...) rmarkdown::render(...), - args = list(input = path, ..., output_options = output_options, quiet = quiet), + args = list( + input = path, + ..., + output_options = output_options, + quiet = quiet + ), show = TRUE, spinner = FALSE, stderr = "2>&1" @@ -54,13 +64,21 @@ build_readme <- function(path = ".", quiet = TRUE, ...) { pkg <- as.package(path) regexp <- paste0(path_file(pkg$path), "/(inst/)?readme[.]rmd") - readme_path <- path_abs(dir_ls(pkg$path, ignore.case = TRUE, regexp = regexp, recurse = 1, type = "file")) + readme_path <- path_abs(dir_ls( + pkg$path, + ignore.case = TRUE, + regexp = regexp, + recurse = 1, + type = "file" + )) if (length(readme_path) == 0) { cli::cli_abort("Can't find {.file README.Rmd} or {.file inst/README.Rmd}.") } if (length(readme_path) > 1) { - cli::cli_abort("Can't have both {.file README.Rmd} and {.file inst/README.Rmd}.") + cli::cli_abort( + "Can't have both {.file README.Rmd} and {.file inst/README.Rmd}." + ) } build_rmd(readme_path, path = path, quiet = quiet, ...) diff --git a/R/check-devtools.R b/R/check-devtools.R index 96727b00e..d10f5caa1 100644 --- a/R/check-devtools.R +++ b/R/check-devtools.R @@ -59,7 +59,9 @@ check_version <- function(pkg = ".") { check_vignette_titles <- function(pkg = ".") { pkg <- as.package(pkg) vigns <- tools::pkgVignettes(dir = pkg$path) - if (length(vigns$docs) == 0) return() + if (length(vigns$docs) == 0) { + return() + } has_vignette_title <- function(v, n) { h <- readLines(v, n = n) diff --git a/R/check-mac.R b/R/check-mac.R index 3346775d2..b4ed56d06 100644 --- a/R/check-mac.R +++ b/R/check-mac.R @@ -11,7 +11,14 @@ #' @family build functions #' @return The url with the check results (invisibly) #' @export -check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, manual = TRUE, quiet = FALSE, ...) { +check_mac_release <- function( + pkg = ".", + dep_pkgs = character(), + args = NULL, + manual = TRUE, + quiet = FALSE, + ... +) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) pkg <- as.package(pkg) @@ -23,17 +30,25 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma )) } - built_path <- pkgbuild::build(pkg$path, tempdir(), + built_path <- pkgbuild::build( + pkg$path, + tempdir(), args = args, - manual = manual, quiet = quiet, ... + manual = manual, + quiet = quiet, + ... ) dep_built_paths <- character() for (i in seq_along(dep_pkgs)) { dep_pkg <- as.package(dep_pkgs[[i]])$path - dep_built_paths[[i]] <- pkgbuild::build(dep_pkg, tempdir(), + dep_built_paths[[i]] <- pkgbuild::build( + dep_pkg, + tempdir(), args = args, - manual = manual, quiet = quiet, ... + manual = manual, + quiet = quiet, + ... ) } on.exit(file_delete(c(built_path, dep_built_paths)), add = TRUE) @@ -49,7 +64,8 @@ check_mac_release <- function(pkg = ".", dep_pkgs = character(), args = NULL, ma body <- append(body, uploads) } - res <- httr::POST(url, + res <- httr::POST( + url, body = body, headers = list( "Content-Type" = "multipart/form-data" diff --git a/R/check-win.R b/R/check-win.R index fd735cc7e..87e6b5853 100644 --- a/R/check-win.R +++ b/R/check-win.R @@ -20,39 +20,82 @@ NULL #' @describeIn check_win Check package on the development version of R. #' @export -check_win_devel <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) { +check_win_devel <- function( + pkg = ".", + args = NULL, + manual = TRUE, + email = NULL, + quiet = FALSE, + ... +) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) check_win( - pkg = pkg, version = "R-devel", args = args, manual = manual, - email = email, quiet = quiet, ... + pkg = pkg, + version = "R-devel", + args = args, + manual = manual, + email = email, + quiet = quiet, + ... ) } #' @describeIn check_win Check package on the released version of R. #' @export -check_win_release <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) { +check_win_release <- function( + pkg = ".", + args = NULL, + manual = TRUE, + email = NULL, + quiet = FALSE, + ... +) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) check_win( - pkg = pkg, version = "R-release", args = args, manual = manual, - email = email, quiet = quiet, ... + pkg = pkg, + version = "R-release", + args = args, + manual = manual, + email = email, + quiet = quiet, + ... ) } #' @describeIn check_win Check package on the previous major release version of R. #' @export -check_win_oldrelease <- function(pkg = ".", args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) { +check_win_oldrelease <- function( + pkg = ".", + args = NULL, + manual = TRUE, + email = NULL, + quiet = FALSE, + ... +) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) check_win( - pkg = pkg, version = "R-oldrelease", args = args, manual = manual, - email = email, quiet = quiet, ... + pkg = pkg, + version = "R-oldrelease", + args = args, + manual = manual, + email = email, + quiet = quiet, + ... ) } -check_win <- function(pkg = ".", version = c("R-devel", "R-release", "R-oldrelease"), - args = NULL, manual = TRUE, email = NULL, quiet = FALSE, ...) { +check_win <- function( + pkg = ".", + version = c("R-devel", "R-release", "R-oldrelease"), + args = NULL, + manual = TRUE, + email = NULL, + quiet = FALSE, + ... +) { pkg <- as.package(pkg) if (!is.null(email)) { @@ -80,14 +123,20 @@ check_win <- function(pkg = ".", version = c("R-devel", "R-release", "R-oldrelea } } - built_path <- pkgbuild::build(pkg$path, tempdir(), + built_path <- pkgbuild::build( + pkg$path, + tempdir(), args = args, - manual = manual, quiet = quiet, ... + manual = manual, + quiet = quiet, + ... ) on.exit(file_delete(built_path), add = TRUE) url <- paste0( - "ftp://win-builder.r-project.org/", version, "/", + "ftp://win-builder.r-project.org/", + version, + "/", path_file(built_path) ) lapply(url, upload_ftp, file = built_path) @@ -142,8 +191,12 @@ upload_ftp <- function(file, url, verbose = FALSE) { con <- file(file, open = "rb") on.exit(close(con), add = TRUE) h <- curl::new_handle(upload = TRUE, filetime = FALSE) - curl::handle_setopt(h, readfunction = function(n) { - readBin(con, raw(), n = n) - }, verbose = verbose) + curl::handle_setopt( + h, + readfunction = function(n) { + readBin(con, raw(), n = n) + }, + verbose = verbose + ) curl::curl_fetch_memory(url, handle = h) } diff --git a/R/check.R b/R/check.R index 11489ffb1..244f358a8 100644 --- a/R/check.R +++ b/R/check.R @@ -49,23 +49,25 @@ #' @seealso [release()] if you want to send the checked package to #' CRAN. #' @export -check <- function(pkg = ".", - document = NULL, - build_args = NULL, - ..., - manual = FALSE, - cran = TRUE, - remote = FALSE, - incoming = remote, - force_suggests = FALSE, - run_dont_test = FALSE, - args = "--timings", - env_vars = c(NOT_CRAN = "true"), - quiet = FALSE, - check_dir = NULL, - cleanup = deprecated(), - vignettes = TRUE, - error_on = c("never", "error", "warning", "note")) { +check <- function( + pkg = ".", + document = NULL, + build_args = NULL, + ..., + manual = FALSE, + cran = TRUE, + remote = FALSE, + incoming = remote, + force_suggests = FALSE, + run_dont_test = FALSE, + args = "--timings", + env_vars = c(NOT_CRAN = "true"), + quiet = FALSE, + check_dir = NULL, + cleanup = deprecated(), + vignettes = TRUE, + error_on = c("never", "error", "warning", "note") +) { pkg <- as.package(pkg) withr::local_options(list(warn = 1)) @@ -179,11 +181,20 @@ can_document <- function(pkg) { #' definitive source for what the different values mean. If not specified by #' the user, both `check()` and `check_built()` default to `error_on = #' "never"` in interactive use and `"warning"` in a non-interactive setting. -check_built <- function(path = NULL, cran = TRUE, - remote = FALSE, incoming = remote, force_suggests = FALSE, - run_dont_test = FALSE, manual = FALSE, args = "--timings", - env_vars = NULL, check_dir = tempdir(), quiet = FALSE, - error_on = c("never", "error", "warning", "note")) { +check_built <- function( + path = NULL, + cran = TRUE, + remote = FALSE, + incoming = remote, + force_suggests = FALSE, + run_dont_test = FALSE, + manual = FALSE, + args = "--timings", + env_vars = NULL, + check_dir = tempdir(), + quiet = FALSE, + error_on = c("never", "error", "warning", "note") +) { if (missing(error_on) && !interactive()) { error_on <- "warning" } @@ -218,20 +229,30 @@ check_built <- function(path = NULL, cran = TRUE, } withr::with_envvar(env_vars, action = "replace", { - rcmdcheck::rcmdcheck(path, - quiet = quiet, args = args, - check_dir = check_dir, error_on = error_on + rcmdcheck::rcmdcheck( + path, + quiet = quiet, + args = args, + check_dir = check_dir, + error_on = error_on ) }) } -check_env_vars <- function(cran = FALSE, remote = FALSE, incoming = remote, - force_suggests = TRUE, env_vars = character()) { +check_env_vars <- function( + cran = FALSE, + remote = FALSE, + incoming = remote, + force_suggests = TRUE, + env_vars = character() +) { c( aspell_env_var(), # Switch off expensive check for package version # https://github.com/r-lib/devtools/issues/1271 - if (getRversion() >= "3.4.0" && as.numeric(R.version[["svn rev"]]) >= 70944) { + if ( + getRversion() >= "3.4.0" && as.numeric(R.version[["svn rev"]]) >= 70944 + ) { c("_R_CHECK_CRAN_INCOMING_REMOTE_" = as.character(remote)) }, "_R_CHECK_CRAN_INCOMING_" = as.character(incoming), @@ -241,13 +262,19 @@ check_env_vars <- function(cran = FALSE, remote = FALSE, incoming = remote, } aspell_env_var <- function() { - tryCatch({ - utils::aspell(NULL, program = "aspell") - c("_R_CHECK_CRAN_INCOMING_USE_ASPELL_" = "TRUE") - }, error = function(e) character()) + tryCatch( + { + utils::aspell(NULL, program = "aspell") + c("_R_CHECK_CRAN_INCOMING_USE_ASPELL_" = "TRUE") + }, + error = function(e) character() + ) } show_env_vars <- function(env_vars) { cli::cat_line("Setting env vars:", col = "darkgrey") - cat_bullet(paste0(format(names(env_vars)), ": ", unname(env_vars)), col = "darkgrey") + cat_bullet( + paste0(format(names(env_vars)), ": ", unname(env_vars)), + col = "darkgrey" + ) } diff --git a/R/install.R b/R/install.R index 139dff158..b56402cbb 100644 --- a/R/install.R +++ b/R/install.R @@ -51,13 +51,20 @@ #' debugging flags set. #' @export install <- - function(pkg = ".", reload = TRUE, quick = FALSE, build = !quick, - args = getOption("devtools.install.args"), quiet = FALSE, - dependencies = NA, upgrade = "default", - build_vignettes = FALSE, - keep_source = getOption("keep.source.pkgs"), - force = FALSE, - ...) { + function( + pkg = ".", + reload = TRUE, + quick = FALSE, + build = !quick, + args = getOption("devtools.install.args"), + quiet = FALSE, + dependencies = NA, + upgrade = "default", + build_vignettes = FALSE, + keep_source = getOption("keep.source.pkgs"), + force = FALSE, + ... + ) { pkg <- as.package(pkg) # Forcing all of the promises for the current namespace now will avoid lazy-load @@ -86,14 +93,25 @@ install <- check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) - remotes::install_deps(pkg$path, - build = build, build_opts = build_opts, - INSTALL_opts = opts, dependencies = dependencies, quiet = quiet, - force = force, upgrade = upgrade, ... + remotes::install_deps( + pkg$path, + build = build, + build_opts = build_opts, + INSTALL_opts = opts, + dependencies = dependencies, + quiet = quiet, + force = force, + upgrade = upgrade, + ... ) if (build) { - install_path <- pkgbuild::build(pkg$path, dest_path = tempdir(), args = build_opts, quiet = quiet) + install_path <- pkgbuild::build( + pkg$path, + dest_path = tempdir(), + args = build_opts, + quiet = quiet + ) on.exit(file_delete(install_path), add = TRUE) } else { install_path <- pkg$path @@ -106,8 +124,17 @@ install <- pkgload::unregister(pkg$package) } - pkgbuild::with_build_tools(required = FALSE, - callr::rcmd("INSTALL", c(install_path, opts), echo = !quiet, show = !quiet, spinner = FALSE, stderr = "2>&1", fail_on_status = TRUE) + pkgbuild::with_build_tools( + required = FALSE, + callr::rcmd( + "INSTALL", + c(install_path, opts), + echo = !quiet, + show = !quiet, + spinner = FALSE, + stderr = "2>&1", + fail_on_status = TRUE + ) ) if (reload && was_loaded) { @@ -129,15 +156,17 @@ install <- #' @inheritParams install #' @inherit remotes::install_deps #' @export -install_deps <- function(pkg = ".", - dependencies = NA, - repos = getOption("repos"), - type = getOption("pkgType"), - upgrade = c("default", "ask", "always", "never"), - quiet = FALSE, - build = TRUE, - build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), - ...) { +install_deps <- function( + pkg = ".", + dependencies = NA, + repos = getOption("repos"), + type = getOption("pkgType"), + upgrade = c("default", "ask", "always", "never"), + quiet = FALSE, + build = TRUE, + build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), + ... +) { pkg <- as.package(pkg) check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) @@ -157,15 +186,17 @@ install_deps <- function(pkg = ".", #' @rdname install_deps #' @export -install_dev_deps <- function(pkg = ".", - dependencies = TRUE, - repos = getOption("repos"), - type = getOption("pkgType"), - upgrade = c("default", "ask", "always", "never"), - quiet = FALSE, - build = TRUE, - build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), - ...) { +install_dev_deps <- function( + pkg = ".", + dependencies = TRUE, + repos = getOption("repos"), + type = getOption("pkgType"), + upgrade = c("default", "ask", "always", "never"), + quiet = FALSE, + build = TRUE, + build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"), + ... +) { remotes::update_packages("roxygen2") pkg <- as.package(pkg) diff --git a/R/package.R b/R/package.R index debbb79f1..c632b064a 100644 --- a/R/package.R +++ b/R/package.R @@ -10,7 +10,9 @@ #' @export #' @keywords internal as.package <- function(x = NULL, create = deprecated()) { - if (is.package(x)) return(x) + if (is.package(x)) { + return(x) + } if (lifecycle::is_present(create)) { lifecycle::deprecate_warn("2.5.0", "as.package(create = )") } diff --git a/R/pkgbuild.R b/R/pkgbuild.R index 9287afc15..7b9c75811 100644 --- a/R/pkgbuild.R +++ b/R/pkgbuild.R @@ -7,8 +7,16 @@ #' [submit_cran()] or [release()]. #' @param ... Additional arguments passed to [pkgbuild::build]. #' @export -build <- function(pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE, - manual = FALSE, args = NULL, quiet = FALSE, ...) { +build <- function( + pkg = ".", + path = NULL, + binary = FALSE, + vignettes = TRUE, + manual = FALSE, + args = NULL, + quiet = FALSE, + ... +) { save_all() if (!file_exists(pkg)) { @@ -18,8 +26,14 @@ build <- function(pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE, check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) pkgbuild::build( - path = pkg, dest_path = path, binary = binary, - vignettes = vignettes, manual = manual, args = args, quiet = quiet, ... + path = pkg, + dest_path = path, + binary = binary, + vignettes = vignettes, + manual = manual, + args = args, + quiet = quiet, + ... ) } diff --git a/R/pkgload.R b/R/pkgload.R index a775b1dcd..7cf9da1e7 100644 --- a/R/pkgload.R +++ b/R/pkgload.R @@ -1,8 +1,15 @@ #' @inherit pkgload::load_all #' @param ... Additional arguments passed to [pkgload::load_all()]. #' @export -load_all <- function(path = ".", reset = TRUE, recompile = FALSE, - export_all = TRUE, helpers = TRUE, quiet = FALSE, ...) { +load_all <- function( + path = ".", + reset = TRUE, + recompile = FALSE, + export_all = TRUE, + helpers = TRUE, + quiet = FALSE, + ... +) { if (inherits(path, "package")) { path <- path$path } @@ -12,8 +19,13 @@ load_all <- function(path = ".", reset = TRUE, recompile = FALSE, check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) pkgload::load_all( - path = path, reset = reset, recompile = recompile, - export_all = export_all, helpers = helpers, quiet = quiet, ... + path = path, + reset = reset, + recompile = recompile, + export_all = export_all, + helpers = helpers, + quiet = quiet, + ... ) } diff --git a/R/release.R b/R/release.R index 0eeb14515..65c6c8c11 100644 --- a/R/release.R +++ b/R/release.R @@ -44,9 +44,13 @@ release <- function(pkg = ".", check = FALSE, args = NULL) { right = pkg$package, line = 2 ) - check(pkg, - cran = TRUE, remote = TRUE, manual = TRUE, - build_args = args, run_dont_test = TRUE + check( + pkg, + cran = TRUE, + remote = TRUE, + manual = TRUE, + build_args = args, + run_dont_test = TRUE ) } if (yesno("Have you run `R CMD check` locally?")) { @@ -74,10 +78,16 @@ release <- function(pkg = ".", check = FALSE, args = NULL) { cat_rule() } cran_url <- paste0( - cran_mirror(), "/web/checks/check_results_", - pkg$package, ".html" + cran_mirror(), + "/web/checks/check_results_", + pkg$package, + ".html" ) - if (yesno("Have you fixed all existing problems at \n{cran_url}{end_sentence}")) { + if ( + yesno( + "Have you fixed all existing problems at \n{cran_url}{end_sentence}" + ) + ) { return(invisible()) } } @@ -94,7 +104,9 @@ release <- function(pkg = ".", check = FALSE, args = NULL) { deps <- if (new_pkg) 0 else length(revdep(pkg$package)) if (deps > 0) { msg <- paste0( - "Have you checked the ", deps, " reverse dependencies ", + "Have you checked the ", + deps, + " reverse dependencies ", "(with the revdepcheck package)?" ) if (yesno(msg)) { @@ -106,7 +118,9 @@ release <- function(pkg = ".", check = FALSE, args = NULL) { "Have you updated `NEWS.md` file?", "Have you updated `DESCRIPTION`?", "Have you updated `cran-comments.md?`", - if (file_exists("codemeta.json")) "Have you updated codemeta.json with codemetar::write_codemeta()?", + if (file_exists("codemeta.json")) { + "Have you updated codemeta.json with codemetar::write_codemeta()?" + }, find_release_questions(pkg) ) for (question in questions) { @@ -145,7 +159,15 @@ find_release_questions <- function(pkg = ".") { } yesno <- function(msg, .envir = parent.frame()) { - yeses <- c("Yes", "Definitely", "For sure", "Yup", "Yeah", "Of course", "Absolutely") + yeses <- c( + "Yes", + "Definitely", + "For sure", + "Yup", + "Yeah", + "Of course", + "Absolutely" + ) nos <- c("No way", "Not yet", "I forget", "No", "Nope", "Uhhhh... Maybe?") cli::cli_inform(msg, .envir = .envir) @@ -249,9 +271,7 @@ submit_cran <- function(pkg = ".", args = NULL) { upload_cran(pkg, built_path) - usethis::with_project(pkg$path, - flag_release(pkg) - ) + usethis::with_project(pkg$path, flag_release(pkg)) } extract_cran_msg <- function(msg) { @@ -339,7 +359,9 @@ flag_release <- function(pkg = ".") { return(invisible()) } - cli::cli_inform(c("!" = "Don't forget to tag this release once accepted by CRAN")) + cli::cli_inform(c( + "!" = "Don't forget to tag this release once accepted by CRAN" + )) withr::with_dir(pkg$path, { sha <- system2("git", c("rev-parse", "HEAD"), stdout = TRUE) diff --git a/R/reload.R b/R/reload.R index d3e0046be..5624e79be 100644 --- a/R/reload.R +++ b/R/reload.R @@ -26,11 +26,15 @@ reload <- function(pkg = ".", quiet = FALSE) { pkg <- as.package(pkg) if (is_attached(pkg)) { - if (!quiet) cli::cli_inform(c(i = "Reloading attached {.pkg {pkg$package}}")) + if (!quiet) { + cli::cli_inform(c(i = "Reloading attached {.pkg {pkg$package}}")) + } pkgload::unload(pkg$package) require(pkg$package, character.only = TRUE, quietly = TRUE) } else if (is_loaded(pkg)) { - if (!quiet) cli::cli_inform(c(i = "Reloading loaded {.pkg {pkg$package}}")) + if (!quiet) { + cli::cli_inform(c(i = "Reloading loaded {.pkg {pkg$package}}")) + } pkgload::unload(pkg$package) requireNamespace(pkg$package, quietly = TRUE) } diff --git a/R/remotes.R b/R/remotes.R index c783301dc..8d7cf7689 100644 --- a/R/remotes.R +++ b/R/remotes.R @@ -3,9 +3,11 @@ with_ellipsis <- function(fun) { b <- body(fun) f <- function(...) { - ellipsis::check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) + ellipsis::check_dots_used( + action = getOption("devtools.ellipsis_action", rlang::warn) + ) - !! b + !!b } f <- rlang::expr_interp(f) @@ -15,7 +17,11 @@ with_ellipsis <- function(fun) { with_pkgbuild_build_tools <- function(fun) { b <- body(fun) - pkgbuild_call <- as.call(c(call("::", as.symbol("pkgbuild"), as.symbol("with_build_tools")), b, list(required = FALSE))) + pkgbuild_call <- as.call(c( + call("::", as.symbol("pkgbuild"), as.symbol("with_build_tools")), + b, + list(required = FALSE) + )) body(fun) <- pkgbuild_call fun @@ -43,7 +49,9 @@ install_bioc <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_bioc)) #' @importFrom remotes install_bitbucket #' @rdname remote-reexports #' @export -install_bitbucket <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_bitbucket)) +install_bitbucket <- with_pkgbuild_build_tools(with_ellipsis( + remotes::install_bitbucket +)) #' @importFrom remotes install_cran #' @rdname remote-reexports @@ -63,7 +71,9 @@ install_git <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_git)) #' @importFrom remotes install_github #' @rdname remote-reexports #' @export -install_github <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_github)) +install_github <- with_pkgbuild_build_tools(with_ellipsis( + remotes::install_github +)) #' @importFrom remotes github_pull #' @rdname reexports @@ -78,12 +88,16 @@ remotes::github_release #' @importFrom remotes install_gitlab #' @rdname remote-reexports #' @export -install_gitlab <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_gitlab)) +install_gitlab <- with_pkgbuild_build_tools(with_ellipsis( + remotes::install_gitlab +)) #' @importFrom remotes install_local #' @rdname remote-reexports #' @export -install_local <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_local)) +install_local <- with_pkgbuild_build_tools(with_ellipsis( + remotes::install_local +)) #' @importFrom remotes install_svn #' @rdname remote-reexports @@ -98,12 +112,16 @@ install_url <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_url)) #' @importFrom remotes install_version #' @rdname remote-reexports #' @export -install_version <- with_pkgbuild_build_tools(with_ellipsis(remotes::install_version)) +install_version <- with_pkgbuild_build_tools(with_ellipsis( + remotes::install_version +)) #' @importFrom remotes update_packages #' @rdname remote-reexports #' @export -update_packages <- with_pkgbuild_build_tools(with_ellipsis(remotes::update_packages)) +update_packages <- with_pkgbuild_build_tools(with_ellipsis( + remotes::update_packages +)) #' @importFrom remotes dev_package_deps #' @rdname remote-reexports diff --git a/R/revdep.R b/R/revdep.R index c5d55bb6d..8c489ef7b 100644 --- a/R/revdep.R +++ b/R/revdep.R @@ -28,11 +28,16 @@ #' #' revdep("ggplot2", ignore = c("xkcd", "zoo")) #' } -revdep <- function(pkg, - dependencies = c("Depends", "Imports", "Suggests", "LinkingTo"), - recursive = FALSE, ignore = NULL, - bioconductor = FALSE) { - if (missing(pkg)) pkg <- as.package(".")$package +revdep <- function( + pkg, + dependencies = c("Depends", "Imports", "Suggests", "LinkingTo"), + recursive = FALSE, + ignore = NULL, + bioconductor = FALSE +) { + if (missing(pkg)) { + pkg <- as.package(".")$package + } all <- if (bioconductor) packages() else cran_packages() @@ -44,7 +49,9 @@ revdep <- function(pkg, #' @rdname revdep #' @export revdep_maintainers <- function(pkg = ".") { - if (missing(pkg)) pkg <- as.package(".")$package + if (missing(pkg)) { + pkg <- as.package(".")$package + } maintainers <- unique(packages()[revdep(pkg), "Maintainer"]) class(maintainers) <- "maintainers" @@ -64,26 +71,31 @@ print.maintainers <- function(x, ...) { cran_packages <- memoise::memoise( function() { local <- path_temp("packages.rds") - utils::download.file("https://cran.R-project.org/web/packages/packages.rds", local, - mode = "wb", quiet = TRUE + utils::download.file( + "https://cran.R-project.org/web/packages/packages.rds", + local, + mode = "wb", + quiet = TRUE ) on.exit(file_delete(local)) cp <- readRDS(local) rownames(cp) <- unname(cp[, 1]) cp }, - ~memoise::timeout(30 * 60) + ~ memoise::timeout(30 * 60) ) bioc_packages <- memoise::memoise( - function(views = paste(BiocManager::repositories()[["BioCsoft"]], "VIEWS", sep = "/")) { + function( + views = paste(BiocManager::repositories()[["BioCsoft"]], "VIEWS", sep = "/") + ) { con <- url(views) on.exit(close(con)) bioc <- read.dcf(con) rownames(bioc) <- bioc[, 1] bioc }, - ~memoise::timeout(30 * 60) + ~ memoise::timeout(30 * 60) ) packages <- function() { diff --git a/R/run-examples.R b/R/run-examples.R index c089237e7..d4c982fc0 100644 --- a/R/run-examples.R +++ b/R/run-examples.R @@ -22,16 +22,31 @@ #' examples are updated before running them. #' @keywords programming #' @export -run_examples <- function(pkg = ".", start = NULL, show = deprecated(), run_donttest = FALSE, - run_dontrun = FALSE, fresh = FALSE, document = TRUE, - run = deprecated(), test = deprecated()) { - +run_examples <- function( + pkg = ".", + start = NULL, + show = deprecated(), + run_donttest = FALSE, + run_dontrun = FALSE, + fresh = FALSE, + document = TRUE, + run = deprecated(), + test = deprecated() +) { if (!missing(run)) { - lifecycle::deprecate_warn("2.3.1", "run_examples(run)", 'run_example(run_dontrun)') + lifecycle::deprecate_warn( + "2.3.1", + "run_examples(run)", + 'run_example(run_dontrun)' + ) run_dontrun <- run } if (!missing(test)) { - lifecycle::deprecate_warn("2.3.1", "run_examples(test)", 'run_example(run_donttest)') + lifecycle::deprecate_warn( + "2.3.1", + "run_examples(test)", + 'run_example(run_donttest)' + ) run_donttest <- test } if (!missing(show)) { @@ -42,9 +57,28 @@ run_examples <- function(pkg = ".", start = NULL, show = deprecated(), run_dontt if (fresh) { to_run <- - function(path, start, run_donttest, run_dontrun) devtools::run_examples(pkg = path, start = start, run_donttest = run_donttest, run_dontrun = run_dontrun, document = FALSE) - - callr::r(to_run, args = list(path = pkg$path, start = start, run_donttest = run_donttest, run_dontrun = run_dontrun), show = TRUE, spinner = FALSE, stderr = "2>&1") + function(path, start, run_donttest, run_dontrun) { + devtools::run_examples( + pkg = path, + start = start, + run_donttest = run_donttest, + run_dontrun = run_dontrun, + document = FALSE + ) + } + + callr::r( + to_run, + args = list( + path = pkg$path, + start = start, + run_donttest = run_donttest, + run_dontrun = run_dontrun + ), + show = TRUE, + spinner = FALSE, + stderr = "2>&1" + ) return(invisible()) } @@ -65,7 +99,12 @@ run_examples <- function(pkg = ".", start = NULL, show = deprecated(), run_dontt load_all(pkg$path, reset = TRUE, export_all = FALSE, helpers = FALSE) on.exit(load_all(pkg$path, reset = TRUE)) - lapply(files, pkgload::run_example, run_donttest = run_donttest, run_dontrun = run_dontrun) + lapply( + files, + pkgload::run_example, + run_donttest = run_donttest, + run_dontrun = run_dontrun + ) invisible() } @@ -77,7 +116,6 @@ run_examples <- function(pkg = ".", start = NULL, show = deprecated(), run_dontt # * rerun example and rerun # * reload code and rerun - rd_files <- function(pkg = ".", start = NULL) { pkg <- as.package(pkg) diff --git a/R/run-source.R b/R/run-source.R index 3c8ac9ae4..262a79804 100644 --- a/R/run-source.R +++ b/R/run-source.R @@ -53,7 +53,9 @@ check_sha1 <- function(path, sha1) { cli::cli_inform(c(i = "SHA-1 hash of file is {.str {file_sha1}}")) } else { if (nchar(sha1) < 6) { - cli::cli_abort("{.arg sha1} must be at least 6 characters, not {nchar(sha1)}.") + cli::cli_abort( + "{.arg sha1} must be at least 6 characters, not {nchar(sha1)}." + ) } # Truncate file_sha1 to length of sha1 @@ -142,7 +144,11 @@ find_gist <- function(id, filename = NULL, call = parent.frame()) { } if (!is.null(filename)) { - if (!is.character(filename) || length(filename) > 1 || !grepl("\\.[rR]$", filename)) { + if ( + !is.character(filename) || + length(filename) > 1 || + !grepl("\\.[rR]$", filename) + ) { cli::cli_abort( "{.arg filename} must be {.code NULL}, or a single filename ending in .R/.r", call = call @@ -155,7 +161,10 @@ find_gist <- function(id, filename = NULL, call = parent.frame()) { } } else { if (length(r_files) > 1) { - cli::cli_inform("{length(r_files)} .R files in gist, using first", call = call) + cli::cli_inform( + "{length(r_files)} .R files in gist, using first", + call = call + ) } which <- 1 } diff --git a/R/session-info.R b/R/session-info.R index f82a3bf54..4223379b1 100644 --- a/R/session-info.R +++ b/R/session-info.R @@ -22,7 +22,8 @@ loaded_packages <- function() { dev_packages <- function() { packages <- vapply( loadedNamespaces(), - function(x) !is.null(pkgload::dev_meta(x)), logical(1) + function(x) !is.null(pkgload::dev_meta(x)), + logical(1) ) names(packages)[packages] diff --git a/R/show-news.R b/R/show-news.R index 2349bec0b..3af181eab 100644 --- a/R/show-news.R +++ b/R/show-news.R @@ -15,14 +15,14 @@ show_news <- function(pkg = ".", latest = TRUE, ...) { check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) - out <- utils::news(..., db = ("tools" %:::% ".news_reader_default")(news_path)) + out <- utils::news( + ..., + db = ("tools" %:::% ".news_reader_default")(news_path) + ) if (latest) { ver <- numeric_version(out$Version) recent <- ver == max(ver) - structure(out[recent, ], - class = class(out), - bad = attr(out, "bad")[recent] - ) + structure(out[recent, ], class = class(out), bad = attr(out, "bad")[recent]) } else { out } diff --git a/R/sitrep.R b/R/sitrep.R index 27c809c24..f8a7be0d5 100644 --- a/R/sitrep.R +++ b/R/sitrep.R @@ -10,25 +10,32 @@ rstudio_version_string <- function() { rvi$long_version %||% as.character(rvi$version) } -check_for_rstudio_updates <- function(os = tolower(Sys.info()[["sysname"]]), - version = rstudio_version_string(), - in_rstudio = is_rstudio_running()) { +check_for_rstudio_updates <- function( + os = tolower(Sys.info()[["sysname"]]), + version = rstudio_version_string(), + in_rstudio = is_rstudio_running() +) { if (!in_rstudio) { return() } url <- sprintf( "https://www.rstudio.org/links/check_for_update?version=%s&os=%s&format=%s&manual=true", - utils::URLencode(version, reserved = TRUE), os, "kvp" + utils::URLencode(version, reserved = TRUE), + os, + "kvp" ) tmp <- file_temp() withr::defer(file_exists(tmp) && nzchar(file_delete(tmp))) suppressWarnings( - download_ok <- tryCatch({ - utils::download.file(url, tmp, quiet = TRUE) - TRUE - }, error = function(e) FALSE) + download_ok <- tryCatch( + { + utils::download.file(url, tmp, quiet = TRUE) + TRUE + }, + error = function(e) FALSE + ) ) if (!download_ok) { return( @@ -56,7 +63,8 @@ check_for_rstudio_updates <- function(os = tolower(Sys.info()[["sysname"]]), } return( - sprintf("%s.\nDownload at: %s", + sprintf( + "%s.\nDownload at: %s", result[["update-message"]], ui_field(result[["update-url"]]) ) @@ -106,7 +114,9 @@ dev_sitrep <- function(pkg = ".", debug = FALSE) { rtools_path = if (has_build_tools) pkgbuild::rtools_path(), devtools_version = packageVersion("devtools"), devtools_deps = remotes::package_deps("devtools", dependencies = NA), - pkg_deps = if (!is.null(pkg)) { remotes::dev_package_deps(pkg$path, dependencies = TRUE) }, + pkg_deps = if (!is.null(pkg)) { + remotes::dev_package_deps(pkg$path, dependencies = TRUE) + }, rstudio_version = if (is_rstudio_running()) rstudioapi::getVersion(), rstudio_msg = check_for_rstudio_updates() ), @@ -116,17 +126,18 @@ dev_sitrep <- function(pkg = ".", debug = FALSE) { #' @export print.dev_sitrep <- function(x, ...) { - all_ok <- TRUE hd_line("R") kv_line("version", x$r_version) kv_line("path", x$r_path, path = TRUE) if (x$r_version < x$r_release_version) { - ui_todo(' + ui_todo( + ' {ui_field("R")} is out of date ({ui_value(x$r_version)} vs {ui_value(x$r_release_version)}) - ') - all_ok <- FALSE + ' + ) + all_ok <- FALSE } if (is_windows) { @@ -134,10 +145,12 @@ print.dev_sitrep <- function(x, ...) { if (x$has_build_tools) { kv_line("path", x$rtools_path, path = TRUE) } else { - ui_todo(' + ui_todo( + ' {ui_field("RTools")} is not installed: Download and install it from: {ui_field("https://cloud.r-project.org/bin/windows/Rtools/")} - ') + ' + ) } all_ok <- FALSE } @@ -152,18 +165,19 @@ print.dev_sitrep <- function(x, ...) { } } - hd_line("devtools") kv_line("version", x$devtools_version) devtools_deps_old <- x$devtools_deps$diff < 0 if (any(devtools_deps_old)) { - ui_todo(' + ui_todo( + ' {ui_field("devtools")} or its dependencies out of date: {paste(ui_value(x$devtools_deps$package[devtools_deps_old]), collapse = ", ")} Update them with {ui_code("devtools::update_packages(\\"devtools\\")")} - ') - all_ok <- FALSE + ' + ) + all_ok <- FALSE } hd_line("dev package") @@ -172,18 +186,22 @@ print.dev_sitrep <- function(x, ...) { pkg_deps_old <- x$pkg_deps$diff < 0 if (any(pkg_deps_old)) { - ui_todo(' + ui_todo( + ' {ui_field(x$pkg$package)} dependencies out of date: {paste(ui_value(x$pkg_deps$package[pkg_deps_old]), collapse = ", ")} Update them with {ui_code("devtools::install_dev_deps()")} - ') - all_ok <- FALSE + ' + ) + all_ok <- FALSE } if (all_ok) { - ui_done(" + ui_done( + " All checks passed - ") + " + ) } invisible(x) @@ -196,11 +214,10 @@ hd_line <- function(name) { cat_rule(cli::style_bold(name)) } -kv_line <- function (key, value, path = FALSE) { +kv_line <- function(key, value, path = FALSE) { if (is.null(value)) { value <- cli::col_silver("") - } - else { + } else { if (path) { value <- ui_path(value, base = NA) } else { diff --git a/R/spell-check.R b/R/spell-check.R index c3aa1e8e3..55cda5062 100644 --- a/R/spell-check.R +++ b/R/spell-check.R @@ -12,5 +12,9 @@ spell_check <- function(pkg = ".", vignettes = TRUE, use_wordlist = TRUE) { rlang::check_installed("spelling") pkg <- as.package(pkg) - spelling::spell_check_package(pkg = pkg, vignettes = vignettes, use_wordlist = use_wordlist) + spelling::spell_check_package( + pkg = pkg, + vignettes = vignettes, + use_wordlist = use_wordlist + ) } diff --git a/R/test.R b/R/test.R index 0bbe0fcc9..e2daabe6c 100644 --- a/R/test.R +++ b/R/test.R @@ -18,7 +18,13 @@ #' @inheritParams pkgload::load_all #' @inheritParams run_examples #' @export -test <- function(pkg = ".", filter = NULL, stop_on_failure = FALSE, export_all = TRUE, ...) { +test <- function( + pkg = ".", + filter = NULL, + stop_on_failure = FALSE, + export_all = TRUE, + ... +) { save_all() pkg <- as.package(pkg) @@ -112,17 +118,23 @@ test_coverage <- function(pkg = ".", show_report = interactive(), ...) { #' @rdname devtools-deprecated #' @export test_coverage_file <- function(file = find_active_file(), ...) { - lifecycle::deprecate_soft("2.4.0", "test_coverage()", "test_coverage_active_file()") + lifecycle::deprecate_soft( + "2.4.0", + "test_coverage()", + "test_coverage_active_file()" + ) test_coverage_active_file(file, ...) } #' @rdname test #' @export -test_coverage_active_file <- function(file = find_active_file(), - filter = TRUE, - show_report = interactive(), - export_all = TRUE, - ...) { +test_coverage_active_file <- function( + file = find_active_file(), + filter = TRUE, + show_report = interactive(), + export_all = TRUE, + ... +) { rlang::check_installed(c("covr", "DT")) check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn)) @@ -140,10 +152,12 @@ test_coverage_active_file <- function(file = find_active_file(), # and a stop reporter to inform the user about test failures snap_reporter <- testthat::local_snapshotter(file.path(test_dir, "_snaps")) snap_reporter$start_file(basename(test_file)) - reporter <- testthat::MultiReporter$new(reporters = list( - testthat::StopReporter$new(praise = FALSE), - snap_reporter - )) + reporter <- testthat::MultiReporter$new( + reporters = list( + testthat::StopReporter$new(praise = FALSE), + snap_reporter + ) + ) withr::local_envvar(r_env_vars()) testthat::with_reporter(reporter, { diff --git a/R/uninstall.R b/R/uninstall.R index b392890e8..98eb0f750 100644 --- a/R/uninstall.R +++ b/R/uninstall.R @@ -10,7 +10,12 @@ #' @export #' @family package installation #' @seealso [with_debug()] to install packages with debugging flags set. -uninstall <- function(pkg = ".", unload = TRUE, quiet = FALSE, lib = .libPaths()[[1]]) { +uninstall <- function( + pkg = ".", + unload = TRUE, + quiet = FALSE, + lib = .libPaths()[[1]] +) { pkg <- as.package(pkg) if (unload && pkg$package %in% loaded_packages()$package) { diff --git a/R/vignette-r.R b/R/vignette-r.R index 233af25fc..b2d8557ed 100644 --- a/R/vignette-r.R +++ b/R/vignette-r.R @@ -36,7 +36,9 @@ copy_vignettes <- function(pkg, keep_md) { return(invisible()) } - cli::cli_inform(c(i = "Copying extra files {.file {path_file(extra_files)}} to {.path doc/}")) + cli::cli_inform(c( + i = "Copying extra files {.file {path_file(extra_files)}} to {.path doc/}" + )) file_copy(extra_files, doc_dir) invisible() diff --git a/R/vignettes.R b/R/vignettes.R index 1ce59746c..ec878eabb 100644 --- a/R/vignettes.R +++ b/R/vignettes.R @@ -27,18 +27,22 @@ #' \file{doc} created from vignettes #' @export #' @seealso [clean_vignettes()] to remove build tex/pdf files. -build_vignettes <- function(pkg = ".", - dependencies = "VignetteBuilder", - clean = TRUE, - upgrade = "never", - quiet = FALSE, - install = TRUE, - keep_md = TRUE) { +build_vignettes <- function( + pkg = ".", + dependencies = "VignetteBuilder", + clean = TRUE, + upgrade = "never", + quiet = FALSE, + install = TRUE, + keep_md = TRUE +) { pkg <- as.package(pkg) save_all() vigns <- tools::pkgVignettes(dir = pkg$path) - if (length(vigns$docs) == 0) return() + if (length(vigns$docs) == 0) { + return() + } deps <- remotes::dev_package_deps(pkg$path, dependencies) update(deps, upgrade = upgrade) @@ -92,9 +96,13 @@ create_vignette_index <- function(pkg, vigns) { clean_vignettes <- function(pkg = ".") { pkg <- as.package(pkg) vigns <- tools::pkgVignettes(dir = pkg$path) - if (path_file(vigns$dir) != "vignettes") return() + if (path_file(vigns$dir) != "vignettes") { + return() + } - cli::cli_inform(c(i = "Cleaning built vignettes and index from {.pkg {pkg$package}}")) + cli::cli_inform(c( + i = "Cleaning built vignettes and index from {.pkg {pkg$package}}" + )) doc_path <- path(pkg$path, "doc") @@ -127,6 +135,8 @@ dir_delete_if_empty <- function(x) { } file_name <- function(x) { - if (length(x) == 0) return(NULL) + if (length(x) == 0) { + return(NULL) + } path_ext_remove(path_file(x)) } diff --git a/R/zzz.R b/R/zzz.R index dc8546066..d0d2b9e92 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -22,7 +22,9 @@ devtools_default_options <- list( .onLoad <- function(libname, pkgname) { op <- options() toset <- !(names(devtools_default_options) %in% names(op)) - if (any(toset)) options(devtools_default_options[toset]) + if (any(toset)) { + options(devtools_default_options[toset]) + } invisible() } diff --git a/air.toml b/air.toml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/spelling.R b/tests/spelling.R index 6713838fc..c597a1292 100644 --- a/tests/spelling.R +++ b/tests/spelling.R @@ -1,3 +1,7 @@ -if(requireNamespace('spelling', quietly = TRUE)) - spelling::spell_check_test(vignettes = TRUE, error = FALSE, - skip_on_cran = TRUE) +if (requireNamespace('spelling', quietly = TRUE)) { + spelling::spell_check_test( + vignettes = TRUE, + error = FALSE, + skip_on_cran = TRUE + ) +} diff --git a/tests/testthat/test-build-site.R b/tests/testthat/test-build-site.R index 22f034a79..dc9ad2c78 100644 --- a/tests/testthat/test-build-site.R +++ b/tests/testthat/test-build-site.R @@ -5,28 +5,35 @@ test_that("Package pkgdown site can be built ", { destination <- path(tempdir(), "testPkgdown", "docs") - build_output <- capture.output({ - build_site( - path = "testPkgdown", - override = list(destination = destination) - ) - }, type = c("output")) + build_output <- capture.output( + { + build_site( + path = "testPkgdown", + override = list(destination = destination) + ) + }, + type = c("output") + ) build_output <- paste(build_output, collapse = "\n") - expect_true(file_exists(path(destination, "index.html")), + expect_true( + file_exists(path(destination, "index.html")), info = build_output, label = "created site index" ) - expect_true(file_exists(path(destination, "reference", "index.html")), + expect_true( + file_exists(path(destination, "reference", "index.html")), info = build_output, label = "created reference index" ) - expect_true(file_exists(path(destination, "articles", "index.html")), + expect_true( + file_exists(path(destination, "articles", "index.html")), info = build_output, label = "created articles index" ) - expect_true(file_exists(path(destination, "articles", "test.html")), + expect_true( + file_exists(path(destination, "articles", "test.html")), info = build_output, label = "created articles index" ) diff --git a/tests/testthat/test-check-doc.R b/tests/testthat/test-check-doc.R index a7727d02a..e6b28cdd3 100644 --- a/tests/testthat/test-check-doc.R +++ b/tests/testthat/test-check-doc.R @@ -7,17 +7,22 @@ test_that("check_man works", { pkg <- local_package_create() dir.create(file.path(pkg, "man")) - writeLines(c(" + writeLines( + c( + " \\name{foo} \\title{Foo bar} \\usage{ foo(x) } \\arguments{\\item{foo}{}} -"), file.path(pkg, "man", "foo.Rd")) +" + ), + file.path(pkg, "man", "foo.Rd") + ) -expect_output( - check_man(pkg), - "Undocumented arguments" -) + expect_output( + check_man(pkg), + "Undocumented arguments" + ) }) diff --git a/tests/testthat/test-check-win.R b/tests/testthat/test-check-win.R index 8be817864..09dcd5b02 100644 --- a/tests/testthat/test-check-win.R +++ b/tests/testthat/test-check-win.R @@ -5,10 +5,12 @@ test_that("change_maintainer_email checks fields", { desc$write(path) expect_snapshot(change_maintainer_email(path, "x@example.com"), error = TRUE) - desc <- desc::desc(text = c( - "Authors@R: person('x', 'y')", - "Maintainer: foo " - )) + desc <- desc::desc( + text = c( + "Authors@R: person('x', 'y')", + "Maintainer: foo " + ) + ) desc$write(path) expect_snapshot(change_maintainer_email(path, "x@example.com"), error = TRUE) }) diff --git a/tests/testthat/test-run-source.R b/tests/testthat/test-run-source.R index ef968c355..de6554ce9 100644 --- a/tests/testthat/test-run-source.R +++ b/tests/testthat/test-run-source.R @@ -59,7 +59,6 @@ test_that("error if file doesn't exist or no files", { find_gist("605a984e764f9ed358556b4ce48cbd08", "c.r") find_gist("c535eee2d02e5f47c8e7642811bc327c") }) - }) test_that("check_sha1() checks or reports sha1 as needed", { diff --git a/tests/testthat/test-sitrep.R b/tests/testthat/test-sitrep.R index f359d5440..ba5bf106e 100644 --- a/tests/testthat/test-sitrep.R +++ b/tests/testthat/test-sitrep.R @@ -49,7 +49,11 @@ test_that("check_for_rstudio_updates", { # an out-of-date daily expect_snapshot( - writeLines(check_for_rstudio_updates("windows", "2021.09.0-daily+328", TRUE)), + writeLines(check_for_rstudio_updates( + "windows", + "2021.09.0-daily+328", + TRUE + )), transform = scrub_current_version ) }) diff --git a/tests/testthat/test-test.R b/tests/testthat/test-test.R index 69973ac47..bfcb01af7 100644 --- a/tests/testthat/test-test.R +++ b/tests/testthat/test-test.R @@ -27,7 +27,9 @@ test_that("Filtering works with devtools::test", { }) test_that("devtools::test_active_file works", { - out <- test_test_active_file(test_path("testTest/tests/testthat/test-dummy.R")) + out <- test_test_active_file(test_path( + "testTest/tests/testthat/test-dummy.R" + )) expect_equal(length(out), 1) }) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index dd153e818..e15a01f87 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,5 +1,8 @@ test_that("case-insensitive sort order", { expect_equal(sort_ci(rev(letters)), letters) expect_equal(sort_ci(rev(LETTERS)), LETTERS) - expect_equal(sort_ci(c(letters[1:3], LETTERS[1:3])), c("A", "a", "B", "b", "C", "c")) + expect_equal( + sort_ci(c(letters[1:3], LETTERS[1:3])), + c("A", "a", "B", "b", "C", "c") + ) }) diff --git a/tests/testthat/testError/R/error.R b/tests/testthat/testError/R/error.R index d55c675f8..1525aec57 100644 --- a/tests/testthat/testError/R/error.R +++ b/tests/testthat/testError/R/error.R @@ -3,5 +3,4 @@ f <- function() { } - stop("This is an error!") # nolint diff --git a/tests/testthat/testPkgdown/R/pkgdown-test-test.R b/tests/testthat/testPkgdown/R/pkgdown-test-test.R index cdb75e642..d6600785e 100644 --- a/tests/testthat/testPkgdown/R/pkgdown-test-test.R +++ b/tests/testthat/testPkgdown/R/pkgdown-test-test.R @@ -1,4 +1,3 @@ - #' pkgdown_test_test #' #' @param x marks the spot diff --git a/tests/testthat/testTest/R/dummy.R b/tests/testthat/testTest/R/dummy.R index 8b1378917..e69de29bb 100644 --- a/tests/testthat/testTest/R/dummy.R +++ b/tests/testthat/testTest/R/dummy.R @@ -1 +0,0 @@ - diff --git a/tests/testthat/testTestWithFailure/R/dummy.R b/tests/testthat/testTestWithFailure/R/dummy.R index 8b1378917..e69de29bb 100644 --- a/tests/testthat/testTestWithFailure/R/dummy.R +++ b/tests/testthat/testTestWithFailure/R/dummy.R @@ -1 +0,0 @@ - diff --git a/tests/testthat/testUseData/R/a.R b/tests/testthat/testUseData/R/a.R index 8b1378917..e69de29bb 100644 --- a/tests/testthat/testUseData/R/a.R +++ b/tests/testthat/testUseData/R/a.R @@ -1 +0,0 @@ - diff --git a/tests/testthat/testVignettesBuilt/R/code.R b/tests/testthat/testVignettesBuilt/R/code.R index 0e4c3c75b..2833b88fc 100644 --- a/tests/testthat/testVignettesBuilt/R/code.R +++ b/tests/testthat/testVignettesBuilt/R/code.R @@ -1,3 +1,3 @@ function_with_unusual_name <- function() { print("Hi!") -} \ No newline at end of file +}