From 9ded282d98bad65bf710fd59b0564eba397ccea6 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 17:45:33 +0200 Subject: [PATCH 01/60] delete cache directories if empty --- R/zzz.R | 28 +++++++++++++++++++++++++++- tests/testthat/test-zzz.R | 13 +++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index cc838d3a5..b3f682956 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -23,6 +23,25 @@ invisible() } +delete_temp_directory_if_empty <- function(path) { + if (grepl(tools::R_user_dir("R.cache", which = "cache"), path, fixed = TRUE)) { + all_files <- list.files(path, + full.names = TRUE, + recursive = TRUE, + all.files = FALSE + ) + if (length(all_files) < 1L) { + unlink(path, recursive = TRUE) + return(TRUE) + } + return(FALSE) + } else { + rlang::abort( + "Can only delete absolute paths under `tools::R_user_dir('R.cache')" + ) + } +} + ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) { if (ask && stats::runif(1L) > 0.9 && is.null(getOption("styler.cache_root"))) { @@ -40,14 +59,21 @@ ask_to_switch_to_non_default_cache_root_impl <- function() { } remove_old_cache_files <- function() { + path_version_specific <- R.cache::getCachePath(c("styler", styler_version)) all_cached <- list.files( - R.cache::getCachePath(c("styler", styler_version)), + path_version_specific, full.names = TRUE, recursive = TRUE ) date_boundary <- Sys.time() - 60L * 60L * 24L * 6L file.remove( all_cached[file.info(all_cached)$mtime < date_boundary] ) + path_styler_specific <- dirname(path_version_specific) + path_r_cache_specific <- dirname(path_styler_specific) + purrr::walk( + c(path_version_specific, path_styler_specific, path_r_cache_specific), + delete_temp_directory_if_empty + ) } diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index 3b0b8da0c..907014841 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -14,3 +14,16 @@ test_that("clear Cache", { length(list.dirs(R.cache::getCachePath("styler"))) == 1L ) }) + + +test_that("can delete empty directory", { + tmpdir <- withr::local_tempdir() + withr::local_dir(tmpdir) + dir.create("xxx") + expect_true(delete_temp_directory_if_empty("xxx")) + dir.create("xxx") + file.create("xxx/yyy") + list.files("xxx") + expect_false(delete_temp_directory_if_empty("xxx")) + expect_true(file.exists(tmpdir)) +}) From d874d9b963fb91a23f9b280e56f8a2763b79d252 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 17:58:51 +0200 Subject: [PATCH 02/60] show dir --- R/zzz.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index b3f682956..aecc67ada 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -36,9 +36,10 @@ delete_temp_directory_if_empty <- function(path) { } return(FALSE) } else { - rlang::abort( - "Can only delete absolute paths under `tools::R_user_dir('R.cache')" - ) + rlang::abort(c( + "Can only delete absolute paths under `tools::R_user_dir('R.cache'), ", + "not ", path + )) } } From f51cb26e8c2fd8ccd4644ed22cc78a60422be973 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 18:08:41 +0200 Subject: [PATCH 03/60] normalise for regex check --- R/zzz.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index aecc67ada..6953a1e1f 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,7 +24,8 @@ } delete_temp_directory_if_empty <- function(path) { - if (grepl(tools::R_user_dir("R.cache", which = "cache"), path, fixed = TRUE)) { + designated_cache_path <- tools::R_user_dir("R.cache", which = "cache") + if (grepl(designated_cache_path, path, fixed = TRUE)) { all_files <- list.files(path, full.names = TRUE, recursive = TRUE, @@ -37,8 +38,8 @@ delete_temp_directory_if_empty <- function(path) { return(FALSE) } else { rlang::abort(c( - "Can only delete absolute paths under `tools::R_user_dir('R.cache'), ", - "not ", path + "Can only delete absolute paths under `tools::R_user_dir('R.cache') (", + designated_cache_path, ") not ", path )) } } @@ -71,8 +72,11 @@ remove_old_cache_files <- function() { ) path_styler_specific <- dirname(path_version_specific) path_r_cache_specific <- dirname(path_styler_specific) + paths <- normalizePath( + c(path_version_specific, path_styler_specific, path_r_cache_specific) + ) purrr::walk( - c(path_version_specific, path_styler_specific, path_r_cache_specific), + paths, delete_temp_directory_if_empty ) } From c359f5615cf21a9b964bdfaf10ae02a19662ef8d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 21:40:38 +0200 Subject: [PATCH 04/60] also match any temp dir that was used in R CMD check --- R/zzz.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index 6953a1e1f..d8f0a1188 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,8 +24,12 @@ } delete_temp_directory_if_empty <- function(path) { - designated_cache_path <- tools::R_user_dir("R.cache", which = "cache") - if (grepl(designated_cache_path, path, fixed = TRUE)) { + designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) + match_cache_dir <- grepl( + paste0("start", designated_cache_path), paste0("start", path), + fixed = TRUE + ) + if (match_cache_dir || grepl("^(/var/|/tmp/|/private/)", path)) { all_files <- list.files(path, full.names = TRUE, recursive = TRUE, From 5989a17877998dc23337b8cbc0983d9ee3892fad Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 22:04:02 +0200 Subject: [PATCH 05/60] use absolute paths for test --- tests/testthat/test-zzz.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index 907014841..7f8bb2f4d 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -20,10 +20,10 @@ test_that("can delete empty directory", { tmpdir <- withr::local_tempdir() withr::local_dir(tmpdir) dir.create("xxx") - expect_true(delete_temp_directory_if_empty("xxx")) + expect_true(delete_temp_directory_if_empty(file.path(getwd(), "xxx"))) dir.create("xxx") file.create("xxx/yyy") list.files("xxx") - expect_false(delete_temp_directory_if_empty("xxx")) + expect_false(delete_temp_directory_if_empty(file.path(getwd(), "xxx"))) expect_true(file.exists(tmpdir)) }) From e5e9b376d4a68b964740c0e874423015ce24b7c6 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Fri, 19 May 2023 23:25:20 +0200 Subject: [PATCH 06/60] R < 4 does not have tools::R_user_dir(), so skip check skip check on CRAN, since on Windows, temp dir is different during R CMD CHECK --- R/zzz.R | 8 +++----- tests/testthat/test-zzz.R | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index d8f0a1188..79382b7d8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,6 +24,9 @@ } delete_temp_directory_if_empty <- function(path) { + if (getRversion() < package_version("4.0.0")) { + return(FALSE) + } designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) match_cache_dir <- grepl( paste0("start", designated_cache_path), paste0("start", path), @@ -40,11 +43,6 @@ delete_temp_directory_if_empty <- function(path) { return(TRUE) } return(FALSE) - } else { - rlang::abort(c( - "Can only delete absolute paths under `tools::R_user_dir('R.cache') (", - designated_cache_path, ") not ", path - )) } } diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index 7f8bb2f4d..f722ec3fc 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -17,6 +17,8 @@ test_that("clear Cache", { test_that("can delete empty directory", { + skip_if(getRversion() < package_version("4.0.0")) + skip_on_cran() tmpdir <- withr::local_tempdir() withr::local_dir(tmpdir) dir.create("xxx") From 47f1b4501680b9309d2115a5235ca09653c22f39 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 20 May 2023 11:27:53 +0200 Subject: [PATCH 07/60] show all env variables to maybe just rely on them to find temp dir on every operating system --- R/zzz.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/zzz.R b/R/zzz.R index 79382b7d8..e740e1cfe 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,6 +24,8 @@ } delete_temp_directory_if_empty <- function(path) { + rlang::warn("here are all the env variables:") + print(Sys.getenv()) if (getRversion() < package_version("4.0.0")) { return(FALSE) } @@ -43,6 +45,11 @@ delete_temp_directory_if_empty <- function(path) { return(TRUE) } return(FALSE) + } else { + rlang::abort(c( + "Can only delete absolute paths under `tools::R_user_dir('R.cache') (", + designated_cache_path, ") not ", path + )) } } From c476334cac8e8b744a6ffc1dca2d5943fd716f06 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 20 May 2023 21:43:43 +0200 Subject: [PATCH 08/60] derive temp directory from env variable --- R/zzz.R | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index e740e1cfe..cfcd06bb9 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -24,17 +24,16 @@ } delete_temp_directory_if_empty <- function(path) { - rlang::warn("here are all the env variables:") - print(Sys.getenv()) + path <- normalizePath(path) if (getRversion() < package_version("4.0.0")) { return(FALSE) } + designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) - match_cache_dir <- grepl( - paste0("start", designated_cache_path), paste0("start", path), - fixed = TRUE - ) - if (match_cache_dir || grepl("^(/var/|/tmp/|/private/)", path)) { + is_in_tools_cache <- startsWith(path, designated_cache_path) + temp_dir <- normalizePath(Sys.getenv("TMPDIR", Sys.getenv("TMP"))) + is_in_generic_cache <- startsWith(path, temp_dir) + if (is_in_tools_cache || is_in_generic_cache) { all_files <- list.files(path, full.names = TRUE, recursive = TRUE, From db26b5f1becce10d255160e1eea1c1ab2628b1fe Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 20 May 2023 22:16:32 +0200 Subject: [PATCH 09/60] fail on error only for R > 3.6 since `tools::R_user_dir()` was introduced after --- .github/workflows/check-full.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index f4228d672..532ddf1b3 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -56,6 +56,6 @@ jobs: - uses: r-lib/actions/check-r-package@v2 with: upload-snapshots: true - error-on: '"note"' + error-on: 'ifelse(getRversion() > 3.6, "error", "note")' env: _R_CHECK_FORCE_SUGGESTS_: false From f6b6b3be299a81429de7c203fa96688890d44569 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 22 May 2023 08:17:38 +0200 Subject: [PATCH 10/60] rename and document --- R/zzz.R | 20 +++++++++++--------- man/delete_if_cache_directory.Rd | 20 ++++++++++++++++++++ tests/testthat/test-zzz.R | 6 +++--- 3 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 man/delete_if_cache_directory.Rd diff --git a/R/zzz.R b/R/zzz.R index cfcd06bb9..2c2c58757 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -23,12 +23,19 @@ invisible() } -delete_temp_directory_if_empty <- function(path) { +#' Delete a cache or temp directory +#' +#' For safety, `path` is only deleted if it is a sub-directory of a temporary +#' directory or user cache. Since this function relies on `tools::R_user_dir()`, +#' it early returns `FALSE` on `R < 4.0.0`. +#' @param path Absolute path to a directory to delete. +#' @returns `TRUE` if anything was deleted, `FALSE` otherwise. +#' @keywords internal +delete_if_cache_directory <- function(path) { path <- normalizePath(path) if (getRversion() < package_version("4.0.0")) { return(FALSE) } - designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) is_in_tools_cache <- startsWith(path, designated_cache_path) temp_dir <- normalizePath(Sys.getenv("TMPDIR", Sys.getenv("TMP"))) @@ -43,13 +50,8 @@ delete_temp_directory_if_empty <- function(path) { unlink(path, recursive = TRUE) return(TRUE) } - return(FALSE) - } else { - rlang::abort(c( - "Can only delete absolute paths under `tools::R_user_dir('R.cache') (", - designated_cache_path, ") not ", path - )) } + FALSE } @@ -85,7 +87,7 @@ remove_old_cache_files <- function() { ) purrr::walk( paths, - delete_temp_directory_if_empty + delete_if_cache_directory ) } diff --git a/man/delete_if_cache_directory.Rd b/man/delete_if_cache_directory.Rd new file mode 100644 index 000000000..a79745cab --- /dev/null +++ b/man/delete_if_cache_directory.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\name{delete_if_cache_directory} +\alias{delete_if_cache_directory} +\title{Delete a cache or temp directory} +\usage{ +delete_if_cache_directory(path) +} +\arguments{ +\item{path}{Absolute path to a directory to delete.} +} +\value{ +\code{TRUE} if anything was deleted, \code{FALSE} otherwise. +} +\description{ +For safety, \code{path} is only deleted if it is a sub-directory of a temporary +directory or user cache. Since this function relies on \code{tools::R_user_dir()}, +it early returns \code{FALSE} on \verb{R < 4.0.0}. +} +\keyword{internal} diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index f722ec3fc..f9d01d9f1 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -16,16 +16,16 @@ test_that("clear Cache", { }) -test_that("can delete empty directory", { +test_that("can delete empty cache directory", { skip_if(getRversion() < package_version("4.0.0")) skip_on_cran() tmpdir <- withr::local_tempdir() withr::local_dir(tmpdir) dir.create("xxx") - expect_true(delete_temp_directory_if_empty(file.path(getwd(), "xxx"))) + expect_true(delete_if_cache_directory(file.path(getwd(), "xxx"))) dir.create("xxx") file.create("xxx/yyy") list.files("xxx") - expect_false(delete_temp_directory_if_empty(file.path(getwd(), "xxx"))) + expect_false(delete_if_cache_directory(file.path(getwd(), "xxx"))) expect_true(file.exists(tmpdir)) }) From ed16b6e07739d3874c6c629d089271a896bfc358 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 22 May 2023 08:35:17 +0200 Subject: [PATCH 11/60] R 3.6 produces a note, so can fail on warning, not just error --- .github/workflows/check-full.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index 532ddf1b3..8f98653d0 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -56,6 +56,6 @@ jobs: - uses: r-lib/actions/check-r-package@v2 with: upload-snapshots: true - error-on: 'ifelse(getRversion() > 3.6, "error", "note")' + error-on: 'ifelse(getRversion() > 3.6, "warning", "note")' env: _R_CHECK_FORCE_SUGGESTS_: false From bedf6895e98fe55d4e7cde6bd3d8556d19b3cdb8 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 22 May 2023 08:21:13 +0200 Subject: [PATCH 12/60] add news --- NEWS.md | 21 +++++++++++++++++++++ inst/WORDLIST | 1 + 2 files changed, 22 insertions(+) diff --git a/NEWS.md b/NEWS.md index e91e30bc6..d1c5838f9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,25 @@ +# styler 1.10.0 + +**Infrastructure** + +- Bump `actions/checkout` to version 3 in GitHub Actions (#1098). +- Bump {touchstone} config (#1104, #1107). +- split `test-public_api.R` for better sharding (#1109). +- 0-pad filenames for sharding (#1110) +- add missing {testthat} snapshots (#1115). + +**Other changes** + +- Remove tail recursion in favor of `repeat` (#1113). +- Prefer {vctrs} functions over slower {base} equivalents (#1114). +- Replace deprecated use of `rlang::with_handlers()` (#1103). +- Require at least R 3.6 (#1101). + + +Thanks for everyone contributing to this release: + +[@IndrajeetPatil](https://github.com/IndrajeetPatil), [@krlmlr](https://github.com/krlmlr), [@kyleam](https://github.com/kyleam), [@MichaelChirico](https://github.com/MichaelChirico), [@mvanaman](https://github.com/mvanaman), [@olivroy](https://github.com/olivroy), and [@vvarik](https://github.com/vvarik). # styler 1.9.1 diff --git a/inst/WORDLIST b/inst/WORDLIST index 0ff1db851..b6a53ac74 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -232,6 +232,7 @@ setCacheRootPath setdiff setenv Shallowify +sharding shinydashboardPlus shinymeta shinyMonacoEditor From 7fddf1b50229aa55f76425a27897c7531bcbf63f Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 22 May 2023 08:21:56 +0200 Subject: [PATCH 13/60] bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index dd94ea44e..07118f6c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: styler Title: Non-Invasive Pretty Printing of R Code -Version: 1.9.1 +Version: 1.10.0 Authors@R: c(person(given = "Kirill", family = "Müller", From f2ba1021bdbfc4887ecc05ffd676e85e28b48d36 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 22 May 2023 08:24:05 +0200 Subject: [PATCH 14/60] update R versions checked for --- cran-comments.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 3408b33e9..c7103acc0 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -4,14 +4,16 @@ editor_options: wrap: 79 --- -This is a release to fix critical bugs and release a new feature. +This is a release requested by the CRAN team to delete empty directories in the +user's cache. ## Test environments -- ubuntu 20.04 (on GitHub Actions): R devel, R 4.2.1, 4.1.2, R 4.0.5, R 3.6, - R 3.5. -- Windows Server 10 (on GitHub Actions): R devel, R 4.2.1, R 4.1.2, R 3.6. +- ubuntu 20.04 (on GitHub Actions): R devel, R 4.3.0, R 4.2.1, 4.1.2, R 4.0.5, + R 3.6 +- Windows Server 10 (on GitHub Actions): R devel, R 4.3.0, R 4.2.1, R 4.1.2, + R 3.6. - win-builder: R devel ## R CMD check results From 21c764f6dfcef7ea68aecedb6c5cd389b60f9bd6 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 24 May 2023 08:07:19 +0200 Subject: [PATCH 15/60] give context and simplify news --- NEWS.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index d1c5838f9..9efbd2658 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,21 +1,25 @@ # styler 1.10.0 -**Infrastructure** +This release contains speed-ups between 20% and 40% depending on your use case +thanks to replacing {base} functionality with {vctrs} (#1114). With the speed +boost introduced in version 1.8.0 in Oct. 2022, {styler} is now up to 2x as fast +as before release 1.8.0. -- Bump `actions/checkout` to version 3 in GitHub Actions (#1098). -- Bump {touchstone} config (#1104, #1107). -- split `test-public_api.R` for better sharding (#1109). -- 0-pad filenames for sharding (#1110) -- add missing {testthat} snapshots (#1115). +This release was created upon a request by the CRAN team to actively manage not +just cached files but also the potentially empty cache directories they live in +(#1118). Here are the changes in detail: -**Other changes** -- Remove tail recursion in favor of `repeat` (#1113). +- Require at least R 3.6 (#1101). - Prefer {vctrs} functions over slower {base} equivalents (#1114). - Replace deprecated use of `rlang::with_handlers()` (#1103). -- Require at least R 3.6 (#1101). - +- Remove tail recursion in favor of `repeat` (#1113). +- split `test-public_api.R` for better sharding (#1109). +- 0-pad filenames for sharding (#1110) +- add missing {testthat} snapshots (#1115). +- Bump {touchstone} config (#1104, #1107). +- Bump `actions/checkout` to version 3 in GitHub Actions (#1098). Thanks for everyone contributing to this release: From c1730b5439d1552b89e306788d4a09610ddd3d3f Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 24 May 2023 09:29:10 +0200 Subject: [PATCH 16/60] after revdepcheck --- cran-comments.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index c7103acc0..229978c38 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -39,4 +39,5 @@ compliant with the requirements of CRAN. I also ran R CMD check on all 39 downstream dependencies of styler using the revdepcheck package. -All of them finished R CMD CHECK with zero (0) ERRORS, WARNINGS and NOTES. +All of them finished R CMD CHECK with the same number of ERRORS, WARNINGS and +NOTES. From fdb7580cd605dec69aa8ee797780b3c909f622f7 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 24 May 2023 20:31:22 +0200 Subject: [PATCH 17/60] bump dev --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 07118f6c6..94ecae74c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: styler Title: Non-Invasive Pretty Printing of R Code -Version: 1.10.0 +Version: 1.10.0.9000 Authors@R: c(person(given = "Kirill", family = "Müller", From c79f2811d9c4adb5a6772343323f9ed5abbb7872 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 16:21:32 -0400 Subject: [PATCH 18/60] rm assert_data.tree_installation() --- R/communicate.R | 7 ------- R/nested-to-tree.R | 2 +- R/set-assert-args.R | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/R/communicate.R b/R/communicate.R index 5ca445f47..5b1ca30a0 100644 --- a/R/communicate.R +++ b/R/communicate.R @@ -39,10 +39,3 @@ communicate_summary <- function(changed, ruler_width) { cli::cat_rule(width = max(40L, ruler_width)) } } - - -assert_data.tree_installation <- function() { - if (!is_installed("data.tree")) { - abort("The package data.tree needs to be installed for this functionality.") - } -} diff --git a/R/nested-to-tree.R b/R/nested-to-tree.R index f2523f65a..c51445140 100644 --- a/R/nested-to-tree.R +++ b/R/nested-to-tree.R @@ -47,7 +47,7 @@ create_tree_from_pd_with_default_style_attributes <- function(pd, #' } #' @keywords internal create_node_from_nested_root <- function(pd_nested, structure_only) { - assert_data.tree_installation() + check_installed("data.tree") name <- if (structure_only) { "Hierarchical structure" } else { diff --git a/R/set-assert-args.R b/R/set-assert-args.R index fd046e960..7d2a0c21c 100644 --- a/R/set-assert-args.R +++ b/R/set-assert-args.R @@ -9,7 +9,7 @@ set_arg_write_tree <- function(write_tree) { if (is.na(write_tree)) { write_tree <- is_installed("data.tree") } else if (write_tree) { - assert_data.tree_installation() + check_installed("data.tree") } write_tree } From 9747ba91d0dd012b699d027db461683013129d81 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 16:51:31 -0400 Subject: [PATCH 19/60] Adding explanation of parallel testing. Before, it just said `. is TRUE` --- R/testing.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/testing.R b/R/testing.R index b83978360..5d48d6852 100644 --- a/R/testing.R +++ b/R/testing.R @@ -379,5 +379,5 @@ skip_during_parallel <- function() { Sys.getenv("STYLER_TEST_IS_TRULY_PARALLEL", TRUE) %>% toupper() %>% as.logical() %>% - testthat::skip_if() + testthat::skip_if("Running in parallel") } From 8e613333148d1d48a70971c0893a8f0bdabdac76 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 16:52:24 -0400 Subject: [PATCH 20/60] Explicitely require prettycode to avoid snapshot change. --- tests/testthat/test-helpers.R | 1 + tests/testthat/test-public_api-3.R | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 55c654375..c5f3a5619 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,6 +1,7 @@ test_that("can construct and print vertical", { + skip_if_not_installed("prettycode") expect_snapshot({ construct_vertical(c("1 + 1", "nw")) }) diff --git a/tests/testthat/test-public_api-3.R b/tests/testthat/test-public_api-3.R index 7c1235f7a..35757d559 100644 --- a/tests/testthat/test-public_api-3.R +++ b/tests/testthat/test-public_api-3.R @@ -159,6 +159,7 @@ test_that("Can display warning on unset styler cache", { }) test_that("No sensitive to decimal option", { + skip_if_not_installed("prettycode") withr::local_options(OutDec = ",") expect_snapshot({ style_text("1") From 3900d31864f6f74f17968405bc27c206f5c646ae Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 16:53:09 -0400 Subject: [PATCH 21/60] Cosmetic code change. This message could benefit to being converted to cli. --- R/vertical.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/vertical.R b/R/vertical.R index 2dae20f56..3f04c7286 100644 --- a/R/vertical.R +++ b/R/vertical.R @@ -25,7 +25,7 @@ print.vertical <- function(x, ..., x <- prettycode::highlight(x, style = style) } else { warn(paste( - "Could not use colored = TRUE, as the package prettycode is not", + "Could not use `colored = TRUE`, as the package prettycode is not", "installed. Please install it if you want to see colored output", "or see `?print.vertical` for more information." )) From 1180c41db9fba1590c7fec741a9d892d0d487bd6 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 16:59:45 -0400 Subject: [PATCH 22/60] Using the handy `.internal = TRUE` of `rlang::abort()` * update snapshot --- R/parse.R | 5 ++--- R/transform-files.R | 11 ++++------- tests/testthat/_snaps/roundtrip.md | 4 +++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/R/parse.R b/R/parse.R index 3aab38f5e..6beadd942 100644 --- a/R/parse.R +++ b/R/parse.R @@ -158,9 +158,8 @@ ensure_correct_txt <- function(pd, text) { if (!lines_and_cols_match(new_text)) { abort(paste( - "Error in styler:::ensure_correct_txt().", - "Please file an issue on GitHub (https://github.com/r-lib/styler/issues)" - )) + "Error in styler:::ensure_correct_txt()." + ), .internal = TRUE) } names_to_keep <- setdiff( names(new_text), diff --git a/R/transform-files.R b/R/transform-files.R index f564b4632..3fb769fbc 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -418,19 +418,16 @@ verify_roundtrip <- function(old_text, new_text, parsable_only = FALSE) { error = function(e) { rlang::abort(paste0( "Styling resulted in code that isn't parsable. This should not ", - "happen. Please file a bug report on GitHub ", - "(https://github.com/r-lib/styler/issues) using a reprex." - )) + "happen." + ), .internal = TRUE) } ) } else if (!expressions_are_identical(old_text, new_text)) { msg <- paste( "The expression evaluated before the styling is not the same as the", - "expression after styling. This should not happen. Please file a", - "bug report on GitHub (https://github.com/r-lib/styler/issues)", - "using a reprex." + "expression after styling. This should not happen." ) - abort(msg) + abort(msg, .internal = TRUE) } } diff --git a/tests/testthat/_snaps/roundtrip.md b/tests/testthat/_snaps/roundtrip.md index 4c326e73e..f0f66b9bc 100644 --- a/tests/testthat/_snaps/roundtrip.md +++ b/tests/testthat/_snaps/roundtrip.md @@ -5,5 +5,7 @@ # corrupt styling does give an error - The expression evaluated before the styling is not the same as the expression after styling. This should not happen. Please file a bug report on GitHub (https://github.com/r-lib/styler/issues) using a reprex. + The expression evaluated before the styling is not the same as the expression after styling. This should not happen. + i This is an internal error that was detected in the styler package. + Please report it at with a reprex () and the full backtrace. From 7aa005721e291128a4f19afb407bec4d328048ba Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 17:12:49 -0400 Subject: [PATCH 23/60] Use `rlang::check_installed()` --- NAMESPACE | 1 + R/styler-package.R | 6 ++---- R/transform-code.R | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 11b8927ba..1c39bc4ca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -48,6 +48,7 @@ importFrom(purrr,pmap) importFrom(purrr,pwalk) importFrom(rlang,"%||%") importFrom(rlang,abort) +importFrom(rlang,check_installed) importFrom(rlang,is_installed) importFrom(rlang,seq2) importFrom(rlang,set_names) diff --git a/R/styler-package.R b/R/styler-package.R index 373a60140..c1558ef4e 100644 --- a/R/styler-package.R +++ b/R/styler-package.R @@ -23,10 +23,8 @@ #' @importFrom magrittr "%>%" #' @importFrom purrr compact partial flatten flatten_int flatten_chr #' @importFrom purrr map map_lgl map_int map_chr map2 map2_chr map_at pmap pwalk -#' @importFrom rlang abort warn seq2 is_installed "%||%" set_names -#' @importFrom vctrs vec_rbind -#' @importFrom vctrs vec_slice -#' @importFrom vctrs vec_split +#' @importFrom rlang abort warn seq2 check_installed is_installed "%||%" set_names +#' @importFrom vctrs vec_rbind vec_slice vec_split ## usethis namespace: end NULL diff --git a/R/transform-code.R b/R/transform-code.R index d8ecebc36..4f2b0337d 100644 --- a/R/transform-code.R +++ b/R/transform-code.R @@ -22,7 +22,7 @@ transform_code <- function(path, fun, ..., dry) { ..., dry = dry ) } else { - abort(paste(path, "is not an R, Rmd or Rnw file")) + abort(paste(path, "is not an R, Rmd, qmd, or Rnw file")) } } From 28b5d0674cd271a386bc3f952506b8aeaba2415d Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 24 May 2023 17:22:31 -0400 Subject: [PATCH 24/60] Add 2 missing skip_if_not_installed("data.tree") --- tests/testthat/test-create_tree.R | 2 ++ tests/testthat/test-relocate_eq_assign.R | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/testthat/test-create_tree.R b/tests/testthat/test-create_tree.R index b3b0ebb7f..c8bcfb319 100644 --- a/tests/testthat/test-create_tree.R +++ b/tests/testthat/test-create_tree.R @@ -2,6 +2,7 @@ test_that("create_trees outputs identical structure if trees have same structure", { skip_if_not_installed("DiagrammeR") + skip_if_not_installed("data.tree") eq <- "a <- fun(a = b)" arrow <- "a <- data.frame(x = qq)" expect_equal( @@ -12,6 +13,7 @@ test_that("create_trees outputs identical structure if trees have same structure test_that("create_trees outputs are not identical structure if trees have different structure", { skip_if_not_installed("DiagrammeR") + skip_if_not_installed("data.tree") eq <- "a <- fun(a = 1:3)" arrow <- "a <- data.frame(x = qq)" expect_true( diff --git a/tests/testthat/test-relocate_eq_assign.R b/tests/testthat/test-relocate_eq_assign.R index 9718c5655..fe7b13bc1 100644 --- a/tests/testthat/test-relocate_eq_assign.R +++ b/tests/testthat/test-relocate_eq_assign.R @@ -2,6 +2,7 @@ # Tests code in R/relevel.R test_that("tree hierarchy is the same no matter whether = or <- is used", { skip_if_not_installed("DiagrammeR") + skip_if_not_installed("data.tree") assign_left <- create_tree( "x <- 5 From 250c251726fc4da527005adbf3d2fac1b3d7f236 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 04:01:33 +0000 Subject: [PATCH 25/60] Bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 Bumps [JamesIves/github-pages-deploy-action](https://github.com/JamesIves/github-pages-deploy-action) from 4.4.1 to 4.4.2. - [Release notes](https://github.com/JamesIves/github-pages-deploy-action/releases) - [Commits](https://github.com/JamesIves/github-pages-deploy-action/compare/v4.4.1...v4.4.2) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/pkgdown.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 087f0b05f..d227c59cf 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -39,7 +39,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.4.2 with: clean: false branch: gh-pages From b6a750df67f8f63327518f33ecfa3fde4eb027c3 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Thu, 1 Jun 2023 10:58:30 +0200 Subject: [PATCH 26/60] fix calculation of temp_dir in delete_if_cache_directory() close #1125 --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 2c2c58757..6d17357ba 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -38,7 +38,7 @@ delete_if_cache_directory <- function(path) { } designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) is_in_tools_cache <- startsWith(path, designated_cache_path) - temp_dir <- normalizePath(Sys.getenv("TMPDIR", Sys.getenv("TMP"))) + temp_dir <- normalizePath(dirname(tempdir())) is_in_generic_cache <- startsWith(path, temp_dir) if (is_in_tools_cache || is_in_generic_cache) { all_files <- list.files(path, From 975fefd236d62b5aab8a2f89e5d36ff5af77e457 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:18:02 -0400 Subject: [PATCH 27/60] Use cli messaging for cache --- R/zzz.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index 6d17357ba..3f7fe061a 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -64,9 +64,9 @@ ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) { ask_to_switch_to_non_default_cache_root_impl <- function() { - rlang::inform(paste0( + cli::cli_inform(paste0( "{styler} cache is cleared after 6 days. ", - "See `?styler::caching` to configure differently or silence this message." + "See {.help styler::caching} to configure differently or silence this message." )) } From d8209128efcf45515b0efb128b1c45b0bb0ffe53 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Sat, 3 Jun 2023 16:36:20 -0400 Subject: [PATCH 28/60] Improve other warning or error messages * Fix with autolinking in vignette * Update a test that I broke. --- R/set-assert-args.R | 10 +++++----- R/stylerignore.R | 4 ++-- R/vertical.R | 4 ++-- R/zzz.R | 2 +- tests/testthat/test-public_api-3.R | 2 +- vignettes/remove_rules.Rmd | 5 ++--- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/R/set-assert-args.R b/R/set-assert-args.R index 7d2a0c21c..db49c4097 100644 --- a/R/set-assert-args.R +++ b/R/set-assert-args.R @@ -28,22 +28,22 @@ assert_transformers <- function(transformers) { action <- if (utils::packageVersion("styler") >= version_cutoff) { "are not supported anymore" } else { - "depreciated and will be removed in a future version of styler." + "deprecated and will be removed in a future version of styler." } message <- paste( "Style guides without a name and a version field are", action, "\nIf you are a user: Open an issue on", "https://github.com/r-lib/styler and provide a reproducible example", "of this error. \nIf you are a developer:", - "When you create a style guide with `styler::create_style_guide()`, the", + "When you create a style guide with {.fn styler::create_style_guide}, the", "argument `style_guide_name` and `style_guide_version` should be", - "non-NULL. See help(\"create_style_guide\") for how to set them." + "non-NULL. See {.help styler::create_style_guide} for how to set them." ) if (utils::packageVersion("styler") >= version_cutoff) { - rlang::abort(message) + cli::cli_abort(message) } else { - rlang::warn(message) + cli::cli_warn(message) } } } diff --git a/R/stylerignore.R b/R/stylerignore.R index ce558dfd6..4cf0b30bd 100644 --- a/R/stylerignore.R +++ b/R/stylerignore.R @@ -76,9 +76,9 @@ add_stylerignore <- function(pd_flat) { pd_flat$indicator_off <- cumsum_start + cumsum_stop is_invalid <- cumsum_start - cumsum_stop < 0L | cumsum_start - cumsum_stop > 1L if (any(is_invalid)) { - warn(paste0( + cli::cli_warn(paste0( "Invalid stylerignore sequences found, potentially ignoring some of the ", - "markers set.\nSee `help(\"stylerignore\", \"styler\")`." + "markers set.\nSee {.help styler::stylerignore}." )) } diff --git a/R/vertical.R b/R/vertical.R index 3f04c7286..8062185a1 100644 --- a/R/vertical.R +++ b/R/vertical.R @@ -24,10 +24,10 @@ print.vertical <- function(x, ..., if (is_installed("prettycode")) { x <- prettycode::highlight(x, style = style) } else { - warn(paste( + cli::cli_warn(paste( "Could not use `colored = TRUE`, as the package prettycode is not", "installed. Please install it if you want to see colored output", - "or see `?print.vertical` for more information." + "or see {.help styler::print.vertical} for more information." )) } } diff --git a/R/zzz.R b/R/zzz.R index 3f7fe061a..bee69d85d 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -65,7 +65,7 @@ ask_to_switch_to_non_default_cache_root <- function(ask = interactive()) { ask_to_switch_to_non_default_cache_root_impl <- function() { cli::cli_inform(paste0( - "{styler} cache is cleared after 6 days. ", + "{{styler}} cache is cleared after 6 days. ", "See {.help styler::caching} to configure differently or silence this message." )) } diff --git a/tests/testthat/test-public_api-3.R b/tests/testthat/test-public_api-3.R index 35757d559..8b1e926fb 100644 --- a/tests/testthat/test-public_api-3.R +++ b/tests/testthat/test-public_api-3.R @@ -153,7 +153,7 @@ test_that("Can display warning on unset styler cache", { withr::local_seed(7) expect_message( ask_to_switch_to_non_default_cache_root(ask = TRUE), - "See `?styler::caching`", + regexp = "styler::caching", fixed = TRUE ) }) diff --git a/vignettes/remove_rules.Rmd b/vignettes/remove_rules.Rmd index 11c79ae63..c0f076239 100644 --- a/vignettes/remove_rules.Rmd +++ b/vignettes/remove_rules.Rmd @@ -25,8 +25,7 @@ If you want to change the behavior of styler to match your desired style, there are multiple ways: - Use the tidyverse style guide, but not with the default options. Starting - point for this approach is the [help - file](https://styler.r-lib.org/reference/tidyverse_style.html) for the + point for this approach is the `help("tidyverse_style")` for the function `tidyverse_style()`, which returns the transformer functions that prettify your code. Most of these options are explained in `vignette("styler")`. @@ -164,7 +163,7 @@ styler. - Then pinpoint the probable rule type (e.g. line breaks if you want less new lines). -- In a local styler clone, add e.g. a `return(pd` at the top of the body to +- In a local styler clone, add e.g. a `return(pd)` at the top of the body to deactivate the rule quickly, or add a `print(pd)` or `browser()` call in the functions of that type (e.g. the different functions of `R/rules-line-breaks.R`), `load_all()`, run your example, see if that From 015874f1dc0c5cbd08bfa2077d74c10223022f27 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Sat, 3 Jun 2023 16:42:39 -0400 Subject: [PATCH 29/60] Fix failing test. --- tests/testthat/test-exception_handling.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-exception_handling.R b/tests/testthat/test-exception_handling.R index 11e1cbb71..74afef5e8 100644 --- a/tests/testthat/test-exception_handling.R +++ b/tests/testthat/test-exception_handling.R @@ -32,6 +32,6 @@ test_that("warning is given when transformers does not contain a version", { } expect_fun( assert_transformers(sg), - "name and a version field are depreciated and will be removed in a future version of styler" + "name and a version field are deprecated and will be removed in a future version of styler" ) }) From 7c64a26aeedee9923d516a750c2a693242bc47ae Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 18:09:49 +0200 Subject: [PATCH 30/60] deactivate cache for all vignettes --- vignettes/caching.Rmd | 2 ++ vignettes/customizing_styler.Rmd | 9 +++++++++ vignettes/detect-alignment.Rmd | 7 ++++++- vignettes/distribute_custom_style_guides.Rmd | 2 ++ vignettes/remove_rules.Rmd | 5 ++++- vignettes/strict.Rmd | 2 ++ vignettes/styler.Rmd | 9 +++++++-- 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/vignettes/caching.Rmd b/vignettes/caching.Rmd index b5f9a7553..b15c7b92a 100644 --- a/vignettes/caching.Rmd +++ b/vignettes/caching.Rmd @@ -12,6 +12,8 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) +options(styler.colored_print.vertical = FALSE) +styler::cache_deactivate() ``` ```{r setup} diff --git a/vignettes/customizing_styler.Rmd b/vignettes/customizing_styler.Rmd index 5a681c435..e566daabd 100644 --- a/vignettes/customizing_styler.Rmd +++ b/vignettes/customizing_styler.Rmd @@ -7,6 +7,15 @@ vignette: > %\VignetteEncoding{UTF-8} --- +```{r} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +options(styler.colored_print.vertical = FALSE) +styler::cache_deactivate() +``` + This vignette provides a high-level overview of how styler works and how you can define your own style guide and format code according to it. If you simply want to customize the tidyverse style guide to your needs, check out `vignette("styler")`, to remove some rules, have a look at `vignette("remove_rules")`. How to distribute a custom style guide is described in `vignette("distribute_custom_style_guides")`. # How styler works diff --git a/vignettes/detect-alignment.Rmd b/vignettes/detect-alignment.Rmd index 937d2921e..b3872d7f5 100644 --- a/vignettes/detect-alignment.Rmd +++ b/vignettes/detect-alignment.Rmd @@ -8,7 +8,12 @@ vignette: > --- ```{r, include=FALSE} -knitr::opts_chunk$set(eval = FALSE) +knitr::opts_chunk$set( + eval = FALSE, + collapse = TRUE, + comment = "#>" +) +styler::cache_deactivate() ``` # Overview diff --git a/vignettes/distribute_custom_style_guides.Rmd b/vignettes/distribute_custom_style_guides.Rmd index 0284facc8..031a13876 100644 --- a/vignettes/distribute_custom_style_guides.Rmd +++ b/vignettes/distribute_custom_style_guides.Rmd @@ -12,6 +12,8 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) +styler::cache_deactivate() +options(styler.colored_print.vertical = FALSE) ``` This vignette describes how you can distribute your own style guide. It builds on `vignette("customizing_styler")` and assumes you understand how to create a style guide with `create_style_guide()`. diff --git a/vignettes/remove_rules.Rmd b/vignettes/remove_rules.Rmd index c0f076239..657538c76 100644 --- a/vignettes/remove_rules.Rmd +++ b/vignettes/remove_rules.Rmd @@ -15,6 +15,7 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) +styler::cache_deactivate() ``` ```{r, echo = FALSE, include = FALSE} @@ -60,7 +61,9 @@ Here are the steps required to deactivate a rule you don't like Lets assume you want to remove the rule that turns `=` into `<-` for assignment. That means you want - string = "hi there" +``` +string = "hi there" +``` to remain unchanged after applying styler. This is not the case if you use the default style guide of styler: diff --git a/vignettes/strict.Rmd b/vignettes/strict.Rmd index f73d98679..880a5db10 100644 --- a/vignettes/strict.Rmd +++ b/vignettes/strict.Rmd @@ -14,6 +14,8 @@ knitr::opts_chunk$set( results = "hide" ) +styler::cache_deactivate() + knitr::knit_engines$set(list( styler = function(options) { options$comment <- "" diff --git a/vignettes/styler.Rmd b/vignettes/styler.Rmd index 2428465fa..dcb451adc 100644 --- a/vignettes/styler.Rmd +++ b/vignettes/styler.Rmd @@ -21,6 +21,7 @@ knitr::knit_engines$set(list( )) options(styler.colored_print.vertical = FALSE) +styler::cache_deactivate() ``` # Entry-points @@ -35,14 +36,18 @@ styler provides the following API to format code: - RStudio Addins for styling the active file, styling the current package and styling the highlighted selection, see `help("styler_addins")`. -Beyond that, styler can be used through other tools documented in the `vignette("third-party-integrations")`. +Beyond that, styler can be used through other tools documented in the `vignette("third-party-integrations")`. Let's get started. +```{r} +library(styler) +``` + + ### Passing arguments to the style guide styler separates the abstract definition of a style guide from the application of it. That's why you must supply a style guide via `transformers` when styling (in case you don't want to rely on the defaults): ```{r} -library(styler) style_text("a + b", transformers = tidyverse_style(scope = "indention")) ``` From a2b9d11100e6fbf6a0c6b3aaf08d6a25887b583c Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 18:14:35 +0200 Subject: [PATCH 31/60] move cache clearning into separate test file that is ran at the end. --- tests/testthat/test-cache-clean-up.R | 27 +++++++++++++++++++++++++++ tests/testthat/test-zzz.R | 18 ------------------ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 tests/testthat/test-cache-clean-up.R diff --git a/tests/testthat/test-cache-clean-up.R b/tests/testthat/test-cache-clean-up.R new file mode 100644 index 000000000..ed5dc5b81 --- /dev/null +++ b/tests/testthat/test-cache-clean-up.R @@ -0,0 +1,27 @@ +test_that("styler tests did not use R.cache in user root", { + skip_on_cran() + skip_on_covr() + skip_during_parallel() + expect_true( + length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L + ) +}) + +test_that("clear Cache", { + # if R CMD CHECK is running, R.cache root is set to a temp + # directory by default. + # https://github.com/HenrikBengtsson/R.cache/commit/c7ac171f15f035674346d5504049c38cf07c268f + # Hence, this clean up won't clean up the user directory that Ripley is + # concerned about, but only some temp directory. + # On the other hand, it seems completely unclear how the user cache even gets + # populated. + # skip_during_parallel() + cache_path <- R.cache::getCachePath("styler") + R.cache::clearCache(cache_path, recursive = TRUE, prompt = FALSE) + # rlang::abort(paste0('cache path:', cache_path)) + skip_on_cran() + skip_on_covr() + expect_true( + length(list.dirs(R.cache::getCachePath("styler"))) == 1L + ) +}) diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index f9d01d9f1..dbbee5082 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -1,21 +1,3 @@ -test_that("styler tests did not use R.cache in user root", { - skip_on_cran() - skip_on_covr() - expect_true( - length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L - ) -}) - -test_that("clear Cache", { - R.cache::clearCache(R.cache::getCachePath("styler"), recursive = TRUE) - skip_on_cran() - skip_on_covr() - expect_true( - length(list.dirs(R.cache::getCachePath("styler"))) == 1L - ) -}) - - test_that("can delete empty cache directory", { skip_if(getRversion() < package_version("4.0.0")) skip_on_cran() From 611c689075eed1c1d7fcdbe1c285892cb6986ded Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 19:40:37 +0200 Subject: [PATCH 32/60] use more concise timeout --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index bee69d85d..e6e628c66 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -76,7 +76,7 @@ remove_old_cache_files <- function() { path_version_specific, full.names = TRUE, recursive = TRUE ) - date_boundary <- Sys.time() - 60L * 60L * 24L * 6L + date_boundary <- Sys.time() - as.difftime(6, unit = "days") file.remove( all_cached[file.info(all_cached)$mtime < date_boundary] ) From 98127c756030fc01a90023911e6b89586b61dd09 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 20:12:23 +0200 Subject: [PATCH 33/60] fix errors --- DESCRIPTION | 2 +- NEWS.md | 10 +++++++++- R/zzz.R | 2 +- tests/testthat/test-cache-clean-up.R | 10 +++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 94ecae74c..434ff833e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: styler Title: Non-Invasive Pretty Printing of R Code -Version: 1.10.0.9000 +Version: 1.10.1 Authors@R: c(person(given = "Kirill", family = "Müller", diff --git a/NEWS.md b/NEWS.md index 9efbd2658..6dc69a941 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,12 @@ - +# styler 1.10.1 + +This release was requested by CRAN due to accidentally populating a user cache while building vignettes for R >= 4.3.0. + +* Code quality improvements (#1122). +* Bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 (#1123). + +Thanks to everyone who contributed to this release: [@olivroy](https://github.com/olivroy) and [@krlmlr](https://github.com/krlmlr). + # styler 1.10.0 This release contains speed-ups between 20% and 40% depending on your use case diff --git a/R/zzz.R b/R/zzz.R index e6e628c66..340054b67 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -76,7 +76,7 @@ remove_old_cache_files <- function() { path_version_specific, full.names = TRUE, recursive = TRUE ) - date_boundary <- Sys.time() - as.difftime(6, unit = "days") + date_boundary <- Sys.time() - as.difftime(6L, unit = "days") file.remove( all_cached[file.info(all_cached)$mtime < date_boundary] ) diff --git a/tests/testthat/test-cache-clean-up.R b/tests/testthat/test-cache-clean-up.R index ed5dc5b81..66adce823 100644 --- a/tests/testthat/test-cache-clean-up.R +++ b/tests/testthat/test-cache-clean-up.R @@ -8,17 +8,13 @@ test_that("styler tests did not use R.cache in user root", { }) test_that("clear Cache", { - # if R CMD CHECK is running, R.cache root is set to a temp + # if R CMD CHECK is detected, R.cache root is set to a temp # directory by default. # https://github.com/HenrikBengtsson/R.cache/commit/c7ac171f15f035674346d5504049c38cf07c268f - # Hence, this clean up won't clean up the user directory that Ripley is - # concerned about, but only some temp directory. - # On the other hand, it seems completely unclear how the user cache even gets - # populated. - # skip_during_parallel() + # Hence, this clean up won't clean up the user directory. + skip_during_parallel() cache_path <- R.cache::getCachePath("styler") R.cache::clearCache(cache_path, recursive = TRUE, prompt = FALSE) - # rlang::abort(paste0('cache path:', cache_path)) skip_on_cran() skip_on_covr() expect_true( From c51956ffa600cd6253c67810b5982ba9a94bb978 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 20:19:21 +0200 Subject: [PATCH 34/60] update cran comments --- cran-comments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 229978c38..ed38adf29 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -4,8 +4,8 @@ editor_options: wrap: 79 --- -This is a release requested by the CRAN team to delete empty directories in the -user's cache. +This is a release requested by the CRAN team to delete the population of the +user's cache while building vignettes. ## Test environments From 82dcfe3cc9343bd72a06c77949a3228788a60485 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 29 May 2023 18:26:39 +0000 Subject: [PATCH 35/60] pre-commit --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index b6a53ac74..1e14ad162 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -107,6 +107,7 @@ iNZightTools io ixmypi ized +JamesIves Jupyterlab Kirill kirill From fc5a61d8ed7fba1febda10a70f1cd52936e47e24 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 29 May 2023 20:40:17 +0200 Subject: [PATCH 36/60] go to bleeding edge --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bb1af251..a45eaf64f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ default_language_version: repos: - repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9007 + rev: f3498c421d68a1db26de1a1fe3ecc91dd6f03b5e hooks: - id: style-files args: From b1d4793b67416a0ec0427a3b212fc83bea1ebb71 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 30 May 2023 09:17:31 +0200 Subject: [PATCH 37/60] no partial matching --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 340054b67..77b90ee17 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -76,7 +76,7 @@ remove_old_cache_files <- function() { path_version_specific, full.names = TRUE, recursive = TRUE ) - date_boundary <- Sys.time() - as.difftime(6L, unit = "days") + date_boundary <- Sys.time() - as.difftime(6L, units = "days") file.remove( all_cached[file.info(all_cached)$mtime < date_boundary] ) From 01f426117dbb867f0204738f4443ca436b3a3a89 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sat, 10 Jun 2023 16:00:17 -0700 Subject: [PATCH 38/60] avoid warning when missing R cache dir --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 77b90ee17..9bdc76c48 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -36,7 +36,7 @@ delete_if_cache_directory <- function(path) { if (getRversion() < package_version("4.0.0")) { return(FALSE) } - designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache")) + designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache"), mustWork = FALSE) is_in_tools_cache <- startsWith(path, designated_cache_path) temp_dir <- normalizePath(dirname(tempdir())) is_in_generic_cache <- startsWith(path, temp_dir) From b0e895b8c25c60a759b1385f3a8c2cc8e02648dd Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 12 Jun 2023 07:56:29 +0200 Subject: [PATCH 39/60] use latest package versions --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a45eaf64f..d3722e4fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,8 +34,8 @@ repos: - id: roxygenize additional_dependencies: - r-lib/pkgapi - - dplyr@1.0.9 - - roxygen2@7.2.2 + - dplyr@1.1.2 + - roxygen2@7.2.3 - id: use-tidy-description - id: spell-check exclude: > From 69f5ab008d6b3bac16a00e84bf28aadd5ae5db59 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 12 Jun 2023 08:09:24 +0200 Subject: [PATCH 40/60] latest rlang --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3722e4fb..7c0a31b31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,6 +36,7 @@ repos: - r-lib/pkgapi - dplyr@1.1.2 - roxygen2@7.2.3 + - rlang@1.1.0 - id: use-tidy-description - id: spell-check exclude: > From bac9a1dde8bbe579ff25895c583f59ba32e9a688 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 11 Jun 2023 17:20:46 +0200 Subject: [PATCH 41/60] don't require dplyr anywhere --- DESCRIPTION | 1 - R/compat-dplyr.R | 9 +++++++++ tests/testthat/test-cache-low-level-api.R | 16 ++++++++-------- vignettes/customizing_styler.Rmd | 10 +++++----- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 434ff833e..27ae3bd79 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,6 @@ Imports: Suggests: data.tree (>= 0.1.6), digest, - dplyr, here, knitr, prettycode, diff --git a/R/compat-dplyr.R b/R/compat-dplyr.R index 340810003..bbeb3c919 100644 --- a/R/compat-dplyr.R +++ b/R/compat-dplyr.R @@ -57,3 +57,12 @@ map_dfr <- function(.x, .f, ...) { res <- map(.x, .f, ...) vec_rbind(!!!res) } + +mutate <- function(.data, ...) { + collected <- list(...) + for (idx in seq_along(collected)) { + .data[names(collected)[idx]] <- unname(collected[[idx]]) + } + + .data +} diff --git a/tests/testthat/test-cache-low-level-api.R b/tests/testthat/test-cache-low-level-api.R index 0c9ed6acd..b5f29b342 100644 --- a/tests/testthat/test-cache-low-level-api.R +++ b/tests/testthat/test-cache-low-level-api.R @@ -1,16 +1,16 @@ test_that("caching utils make right blocks with semi-colon", { blocks_simple_uncached <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - dplyr::mutate(is_cached = FALSE) %>% + mutate(is_cached = FALSE) %>% cache_find_block() expect_equal(blocks_simple_uncached, c(1, 1, 1, 1)) blocks_simple_cached <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - dplyr::mutate(is_cached = TRUE) %>% + mutate(is_cached = TRUE) %>% cache_find_block() expect_equal(blocks_simple_cached, c(1, 1, 1, 1)) blocks_edge <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - dplyr::mutate(is_cached = c(TRUE, TRUE, FALSE, FALSE)) %>% + mutate(is_cached = c(TRUE, TRUE, FALSE, FALSE)) %>% cache_find_block() expect_equal(blocks_edge, c(1, 2, 2, 2)) }) @@ -30,7 +30,7 @@ test_that("caching utils make right blocks with comments", { blocks_simple_uncached <- compute_parse_data_nested(text) %>% - dplyr::mutate(is_cached = c( + mutate(is_cached = c( FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE )) %>% @@ -48,7 +48,7 @@ test_that("caching utils make right blocks with comments", { tau1 = 1 # here? " blocks_simple_cached <- compute_parse_data_nested(text) %>% - dplyr::mutate(is_cached = c( + mutate(is_cached = c( FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE )) %>% cache_find_block() @@ -101,17 +101,17 @@ test_that("blank lines are correctly identified", { test_that("caching utils make right blocks with comments", { blocks_simple_uncached <- compute_parse_data_nested(c("1 + 1", "2 # comment")) %>% - dplyr::mutate(is_cached = FALSE) %>% + mutate(is_cached = FALSE) %>% cache_find_block() expect_equal(blocks_simple_uncached, c(1, 1, 1)) blocks_simple_cached <- compute_parse_data_nested(c("1 + 1", "2 # comment2")) %>% - dplyr::mutate(is_cached = TRUE) %>% + mutate(is_cached = TRUE) %>% cache_find_block() expect_equal(blocks_simple_cached, c(1, 1, 1)) blocks_edge <- compute_parse_data_nested(c("1 + 1", "2 # 1+1")) %>% - dplyr::mutate(is_cached = c(TRUE, TRUE, FALSE)) %>% + mutate(is_cached = c(TRUE, TRUE, FALSE)) %>% cache_find_block() expect_equal(blocks_edge, c(1, 2, 2)) }) diff --git a/vignettes/customizing_styler.Rmd b/vignettes/customizing_styler.Rmd index e566daabd..7742b9e18 100644 --- a/vignettes/customizing_styler.Rmd +++ b/vignettes/customizing_styler.Rmd @@ -32,8 +32,8 @@ The `transformers` argument is, apart from the code to style, the key argument o ```{r, message = FALSE} library("styler") +library("magrittr") cache_deactivate() -library("dplyr") names(tidyverse_style()) str(tidyverse_style(), give.attr = FALSE, list.len = 3) ``` @@ -50,8 +50,9 @@ As the name says, this function removes spaces after the opening parenthesis. Bu string_to_format <- "call( 3)" pd <- styler:::compute_parse_data_nested(string_to_format) %>% styler:::pre_visit_one(default_style_guide_attributes) -pd$child[[1]] %>% - select(token, terminal, text, newlines, spaces) + +cols <- c('token', 'terminal', 'text', 'newlines', 'spaces') +pd$child[[1]][, cols] ``` `default_style_guide_attributes()` is called to initialize some variables, it does not actually transform the parse table. @@ -59,8 +60,7 @@ pd$child[[1]] %>% All the function `remove_space_after_opening_paren()` now does is to look for the opening bracket and set the column `spaces` of the token to zero. Note that it is very important to check whether there is also a line break following after that token. If so, `spaces` should not be touched because of the way `spaces` and `newlines` are defined. `spaces` are the number of spaces after a token and `newlines`. Hence, if a line break follows, spaces are not EOL spaces, but rather the spaces directly before the next token. If there was a line break after the token and the rule did not check for that, indention for the token following `(` would be removed. This would be unwanted for example if `use_raw_indention` is set to `TRUE` (which means indention should not be touched). If we apply the rule to our parse table, we can see that the column `spaces` changes and is now zero for all tokens: ```{r} -styler:::remove_space_after_opening_paren(pd$child[[1]]) %>% - select(token, terminal, text, newlines, spaces) +styler:::remove_space_after_opening_paren(pd$child[[1]])[, cols] ``` All top-level styling functions have a `style` argument (which defaults to `tidyverse_style`). If you check out the help file, you can see that the argument `style` is only used to create the default `transformers` argument, which defaults to `style(...)`. This allows for the styling options to be set without having to specify them inside the function passed to `transformers`. From eec8c06e82c81902e94e2d16a47b1e87035213da Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 12 Jun 2023 07:40:46 +0200 Subject: [PATCH 42/60] avoid mutate() since it has not exactly dplyr::mutate() schemantics (nse, !!, etc.) and it's not intended to be used in source code anyways --- R/compat-dplyr.R | 9 --------- tests/testthat/test-cache-low-level-api.R | 16 ++++++++-------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/R/compat-dplyr.R b/R/compat-dplyr.R index bbeb3c919..340810003 100644 --- a/R/compat-dplyr.R +++ b/R/compat-dplyr.R @@ -57,12 +57,3 @@ map_dfr <- function(.x, .f, ...) { res <- map(.x, .f, ...) vec_rbind(!!!res) } - -mutate <- function(.data, ...) { - collected <- list(...) - for (idx in seq_along(collected)) { - .data[names(collected)[idx]] <- unname(collected[[idx]]) - } - - .data -} diff --git a/tests/testthat/test-cache-low-level-api.R b/tests/testthat/test-cache-low-level-api.R index b5f29b342..f4b4694ea 100644 --- a/tests/testthat/test-cache-low-level-api.R +++ b/tests/testthat/test-cache-low-level-api.R @@ -1,16 +1,16 @@ test_that("caching utils make right blocks with semi-colon", { blocks_simple_uncached <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - mutate(is_cached = FALSE) %>% + base::transform(is_cached = FALSE) %>% cache_find_block() expect_equal(blocks_simple_uncached, c(1, 1, 1, 1)) blocks_simple_cached <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - mutate(is_cached = TRUE) %>% + base::transform(is_cached = TRUE) %>% cache_find_block() expect_equal(blocks_simple_cached, c(1, 1, 1, 1)) blocks_edge <- compute_parse_data_nested(c("1 + 1", "2; 1+1")) %>% - mutate(is_cached = c(TRUE, TRUE, FALSE, FALSE)) %>% + base::transform(is_cached = c(TRUE, TRUE, FALSE, FALSE)) %>% cache_find_block() expect_equal(blocks_edge, c(1, 2, 2, 2)) }) @@ -30,7 +30,7 @@ test_that("caching utils make right blocks with comments", { blocks_simple_uncached <- compute_parse_data_nested(text) %>% - mutate(is_cached = c( + base::transform(is_cached = c( FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE )) %>% @@ -48,7 +48,7 @@ test_that("caching utils make right blocks with comments", { tau1 = 1 # here? " blocks_simple_cached <- compute_parse_data_nested(text) %>% - mutate(is_cached = c( + base::transform(is_cached = c( FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE )) %>% cache_find_block() @@ -101,17 +101,17 @@ test_that("blank lines are correctly identified", { test_that("caching utils make right blocks with comments", { blocks_simple_uncached <- compute_parse_data_nested(c("1 + 1", "2 # comment")) %>% - mutate(is_cached = FALSE) %>% + base::transform(is_cached = FALSE) %>% cache_find_block() expect_equal(blocks_simple_uncached, c(1, 1, 1)) blocks_simple_cached <- compute_parse_data_nested(c("1 + 1", "2 # comment2")) %>% - mutate(is_cached = TRUE) %>% + base::transform(is_cached = TRUE) %>% cache_find_block() expect_equal(blocks_simple_cached, c(1, 1, 1)) blocks_edge <- compute_parse_data_nested(c("1 + 1", "2 # 1+1")) %>% - mutate(is_cached = c(TRUE, TRUE, FALSE)) %>% + base::transform(is_cached = c(TRUE, TRUE, FALSE)) %>% cache_find_block() expect_equal(blocks_edge, c(1, 2, 2)) }) From e24dc6812316ba0cb7506a4978ac0f27a163571f Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 28 Jun 2023 15:39:12 -0400 Subject: [PATCH 43/60] Exclude R/import-standalone.+R files from restyling. --- R/ui-styling.R | 12 ++++++++---- man/prettify_any.Rd | 4 ++-- man/prettify_pkg.Rd | 4 ++-- man/style_dir.Rd | 4 ++-- man/style_pkg.Rd | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/R/ui-styling.R b/R/ui-styling.R index bb4cc136c..a5a3bd3e8 100644 --- a/R/ui-styling.R +++ b/R/ui-styling.R @@ -69,7 +69,7 @@ style_pkg <- function(pkg = ".", style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), - exclude_files = c("R/RcppExports.R", "R/cpp11.R"), + exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, @@ -91,8 +91,8 @@ style_pkg <- function(pkg = ".", #' ".Rmd")`, or `c("r", "rmd")`. Supported values (after standardization) are: #' "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as #' Rmd. -#' @param exclude_files Character vector with paths to files that should be -#' excluded from styling. +#' @param exclude_files Character vector with paths or regular expressions to files +#' that should be excluded from styling. #' @param exclude_dirs Character vector with directories to exclude #' (recursively). Note that the default values were set for consistency with #' [style_dir()] and as these directories are anyways not styled. @@ -107,8 +107,10 @@ prettify_pkg <- function(transformers, dry) { filetype_ <- set_and_assert_arg_filetype(filetype) r_files <- rprofile_files <- vignette_files <- readme <- NULL + exclude_files <- set_arg_paths(exclude_files) + exclude_files_regex <- paste0(exclude_files[!file.exists(exclude_files)], collapse = "|") exclude_files <- c( - set_arg_paths(exclude_files), + exclude_files, dir_without_.(exclude_dirs, pattern = map_filetype_to_pattern(filetype)) ) if ("\\.r" %in% filetype_) { @@ -171,6 +173,8 @@ prettify_pkg <- function(transformers, c(r_files, rprofile_files, vignette_files, readme), exclude_files ) + # Remove the regex. + files <- files[!grepl(exclude_files_regex, files)] transform_files(files, transformers = transformers, include_roxygen_examples = include_roxygen_examples, diff --git a/man/prettify_any.Rd b/man/prettify_any.Rd index c4b7fc5a1..590560522 100644 --- a/man/prettify_any.Rd +++ b/man/prettify_any.Rd @@ -28,8 +28,8 @@ Rmd.} \item{recursive}{A logical value indicating whether or not files in subdirectories should be styled as well.} -\item{exclude_files}{Character vector with paths to files that should be -excluded from styling.} +\item{exclude_files}{Character vector with paths or regular expressions to files +that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude (recursively). Note that the default values were set for consistency with diff --git a/man/prettify_pkg.Rd b/man/prettify_pkg.Rd index 4e9a40cb8..53a946575 100644 --- a/man/prettify_pkg.Rd +++ b/man/prettify_pkg.Rd @@ -23,8 +23,8 @@ be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".R "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as Rmd.} -\item{exclude_files}{Character vector with paths to files that should be -excluded from styling.} +\item{exclude_files}{Character vector with paths or regular expressions to files +that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude (recursively). Note that the default values were set for consistency with diff --git a/man/style_dir.Rd b/man/style_dir.Rd index 9f8294354..3913c53ff 100644 --- a/man/style_dir.Rd +++ b/man/style_dir.Rd @@ -41,8 +41,8 @@ Rmd.} \item{recursive}{A logical value indicating whether or not files in sub directories of \code{path} should be styled as well.} -\item{exclude_files}{Character vector with paths to files that should be -excluded from styling.} +\item{exclude_files}{Character vector with paths or regular expressions to files +that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude (recursively).} diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 303dc7693..59232b1dc 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -37,8 +37,8 @@ be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".R "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as Rmd.} -\item{exclude_files}{Character vector with paths to files that should be -excluded from styling.} +\item{exclude_files}{Character vector with paths or regular expressions to files +that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude (recursively). Note that the default values were set for consistency with From 6d2f25d2fac86cf234d39b7a1c322d35198d2215 Mon Sep 17 00:00:00 2001 From: Olivier Roy Date: Wed, 28 Jun 2023 15:52:30 -0400 Subject: [PATCH 44/60] document --- API | 2 +- man/style_pkg.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/API b/API index 46b34bbcd..b392a14b4 100644 --- a/API +++ b/API @@ -27,7 +27,7 @@ specify_reindention(regex_pattern = NULL, indention = 0L, comments_only = TRUE) specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL) style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") -style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports.R", "R/cpp11.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") +style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L) tidyverse_math_token_spacing() tidyverse_reindention() diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 59232b1dc..9d07b235a 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -10,7 +10,7 @@ style_pkg( style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), - exclude_files = c("R/RcppExports.R", "R/cpp11.R"), + exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, From a2b8ad472310975c0dc8e9eba24805969302ecad Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 16 Jul 2023 20:13:53 +0200 Subject: [PATCH 45/60] exclude files is not interpreteted as a regex instead of plain file names and R/import-standalone.*\\.R is added --- API | 2 +- R/ui-styling.R | 8 ++++---- man/prettify_any.Rd | 2 +- man/prettify_pkg.Rd | 2 +- man/style_dir.Rd | 2 +- man/style_pkg.Rd | 5 +++-- tests/testthat/test-public_api-0.R | 12 ++++++++++-- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/API b/API index b392a14b4..429de55f4 100644 --- a/API +++ b/API @@ -27,7 +27,7 @@ specify_reindention(regex_pattern = NULL, indention = 0L, comments_only = TRUE) specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL) style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") -style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") +style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports\\.R", "R/cpp11\\.R", "R/import-standalone.*\\.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off") style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L) tidyverse_math_token_spacing() tidyverse_reindention() diff --git a/R/ui-styling.R b/R/ui-styling.R index a5a3bd3e8..e25eed10c 100644 --- a/R/ui-styling.R +++ b/R/ui-styling.R @@ -69,7 +69,7 @@ style_pkg <- function(pkg = ".", style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), - exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), + exclude_files = c("R/RcppExports\\.R", "R/cpp11\\.R", "R/import-standalone.*\\.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, @@ -91,7 +91,7 @@ style_pkg <- function(pkg = ".", #' ".Rmd")`, or `c("r", "rmd")`. Supported values (after standardization) are: #' "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as #' Rmd. -#' @param exclude_files Character vector with paths or regular expressions to files +#' @param exclude_files Character vector with regular expressions to files #' that should be excluded from styling. #' @param exclude_dirs Character vector with directories to exclude #' (recursively). Note that the default values were set for consistency with @@ -107,6 +107,8 @@ prettify_pkg <- function(transformers, dry) { filetype_ <- set_and_assert_arg_filetype(filetype) r_files <- rprofile_files <- vignette_files <- readme <- NULL + all_files <- list.files(".", recursive = TRUE, all.files = TRUE) + exclude_files <- grep(paste0(exclude_files, collapse = "|"), all_files, value = TRUE) exclude_files <- set_arg_paths(exclude_files) exclude_files_regex <- paste0(exclude_files[!file.exists(exclude_files)], collapse = "|") exclude_files <- c( @@ -173,8 +175,6 @@ prettify_pkg <- function(transformers, c(r_files, rprofile_files, vignette_files, readme), exclude_files ) - # Remove the regex. - files <- files[!grepl(exclude_files_regex, files)] transform_files(files, transformers = transformers, include_roxygen_examples = include_roxygen_examples, diff --git a/man/prettify_any.Rd b/man/prettify_any.Rd index 590560522..b1db51e44 100644 --- a/man/prettify_any.Rd +++ b/man/prettify_any.Rd @@ -28,7 +28,7 @@ Rmd.} \item{recursive}{A logical value indicating whether or not files in subdirectories should be styled as well.} -\item{exclude_files}{Character vector with paths or regular expressions to files +\item{exclude_files}{Character vector with regular expressions to files that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude diff --git a/man/prettify_pkg.Rd b/man/prettify_pkg.Rd index 53a946575..0c999550c 100644 --- a/man/prettify_pkg.Rd +++ b/man/prettify_pkg.Rd @@ -23,7 +23,7 @@ be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".R "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as Rmd.} -\item{exclude_files}{Character vector with paths or regular expressions to files +\item{exclude_files}{Character vector with regular expressions to files that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude diff --git a/man/style_dir.Rd b/man/style_dir.Rd index 3913c53ff..7f0f61a58 100644 --- a/man/style_dir.Rd +++ b/man/style_dir.Rd @@ -41,7 +41,7 @@ Rmd.} \item{recursive}{A logical value indicating whether or not files in sub directories of \code{path} should be styled as well.} -\item{exclude_files}{Character vector with paths or regular expressions to files +\item{exclude_files}{Character vector with regular expressions to files that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 9d07b235a..0eca9278e 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -10,7 +10,8 @@ style_pkg( style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), - exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"), + exclude_files = c("R/RcppExports\\\\.R", "R/cpp11\\\\.R", + "R/import-standalone.*\\\\.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, @@ -37,7 +38,7 @@ be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".R "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as Rmd.} -\item{exclude_files}{Character vector with paths or regular expressions to files +\item{exclude_files}{Character vector with regular expressions to files that should be excluded from styling.} \item{exclude_dirs}{Character vector with directories to exclude diff --git a/tests/testthat/test-public_api-0.R b/tests/testthat/test-public_api-0.R index e0d46f105..70e90cbec 100644 --- a/tests/testthat/test-public_api-0.R +++ b/tests/testthat/test-public_api-0.R @@ -32,7 +32,7 @@ test_that("styler can style package and exclude some directories and files", { capture_output(expect_true({ styled <- style_pkg(testthat_file("public-api", "xyzpackage"), exclude_dirs = "tests", - exclude_files = ".Rprofile" + exclude_files = "\\.Rprofile" ) nrow(styled) == 1 })) @@ -40,10 +40,18 @@ test_that("styler can style package and exclude some directories and files", { capture_output(expect_true({ styled <- style_pkg(testthat_file("public-api", "xyzpackage"), exclude_dirs = "tests", - exclude_files = "./.Rprofile" + exclude_files = ".*ofile" ) nrow(styled) == 1 })) + + capture_output(expect_true({ + styled <- style_pkg(testthat_file("public-api", "xyzpackage"), + exclude_dirs = "tests", + exclude_files = "hello" + ) + nrow(styled) == 0 + })) }) From bfb6cf6251167b5f22f4055ea8ef1e396bc5be27 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 03:52:56 +0000 Subject: [PATCH 46/60] Bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/pkgdown.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index d227c59cf..520d1e570 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -39,7 +39,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.2 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: clean: false branch: gh-pages From d9f3f6a4d52b17559c947a9354e3f1afd596c6c9 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 21 Aug 2023 15:37:44 +0200 Subject: [PATCH 47/60] show warning --- .github/workflows/check-full.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index 8f98653d0..b0eba4048 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -59,3 +59,4 @@ jobs: error-on: 'ifelse(getRversion() > 3.6, "warning", "note")' env: _R_CHECK_FORCE_SUGGESTS_: false + _R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_: true From de938c575eca15931bc7894ed04eb995d2e0a15d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 21 Aug 2023 17:21:10 +0200 Subject: [PATCH 48/60] fix the issue --- R/set-assert-args.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/set-assert-args.R b/R/set-assert-args.R index db49c4097..7cccd0aa5 100644 --- a/R/set-assert-args.R +++ b/R/set-assert-args.R @@ -21,7 +21,7 @@ set_arg_write_tree <- function(write_tree) { #' @inheritParams make_transformer #' @keywords internal assert_transformers <- function(transformers) { - version_cutoff <- 2.0 + version_cutoff <- "2.0" no_name <- is.null(transformers$style_guide_name) no_version <- is.null(transformers$style_guide_version) if (no_name || no_version) { From 696663dec432d6863672f68d510ccec5696bca89 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 21 Aug 2023 20:34:25 +0200 Subject: [PATCH 49/60] upgrade pre-commit to stable release that does not contain reference to bleeding lintr --- .pre-commit-config.yaml | 2 +- R/nest.R | 2 +- R/testing.R | 2 +- R/ui-caching.R | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c0a31b31..d6dd581fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ default_language_version: repos: - repo: https://github.com/lorenzwalthert/precommit - rev: f3498c421d68a1db26de1a1fe3ecc91dd6f03b5e + rev: v0.3.2.9019 hooks: - id: style-files args: diff --git a/R/nest.R b/R/nest.R index f56cdc6e3..f6e26d210 100644 --- a/R/nest.R +++ b/R/nest.R @@ -343,7 +343,7 @@ nest_parse_data <- function(pd_flat) { rhs <- nest_(child, "child", setdiff(names(child), "parent_")) - nested <- left_join(internal, rhs, by = c("id" = "parent_")) + nested <- left_join(internal, rhs, by = c(id = "parent_")) children <- nested$child for (i in seq_along(children)) { diff --git a/R/testing.R b/R/testing.R index 5d48d6852..4b94d7e1b 100644 --- a/R/testing.R +++ b/R/testing.R @@ -327,7 +327,7 @@ local_test_setup <- function(cache = FALSE, .local_envir = parent.frame()) { current_cache <- cache_info(format = "tabular") withr::local_options( - list("styler.quiet" = TRUE, "R.cache.rootPath" = tempfile()), + list(styler.quiet = TRUE, R.cache.rootPath = tempfile()), .local_envir = .local_envir ) if (cache) { diff --git a/R/ui-caching.R b/R/ui-caching.R index 9aace1eb1..42e80f529 100644 --- a/R/ui-caching.R +++ b/R/ui-caching.R @@ -138,7 +138,7 @@ cache_info <- function(cache_name = NULL, format = "both") { #' @export cache_activate <- function(cache_name = NULL, verbose = !getOption("styler.quiet", FALSE)) { - options("styler.cache_name" = cache_name %||% styler_version) + options(styler.cache_name = cache_name %||% styler_version) path <- cache_find_path(cache_name) if (verbose) { @@ -155,7 +155,7 @@ cache_activate <- function(cache_name = NULL, #' @rdname cache_activate #' @export cache_deactivate <- function(verbose = !getOption("styler.quiet", FALSE)) { - options("styler.cache_name" = NULL) + options(styler.cache_name = NULL) if (verbose) { cat("Deactivated cache.\n") From 0c9ff1f382ffcdd6298c8e735a5e79639e06fe96 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Mon, 21 Aug 2023 20:37:43 +0200 Subject: [PATCH 50/60] fix line starts --- tests/testthat/test-create_token.R | 2 -- tests/testthat/test-create_tree.R | 2 -- tests/testthat/test-curly-curly.R | 2 -- tests/testthat/test-exception_handling.R | 2 -- tests/testthat/test-helpers.R | 2 -- tests/testthat/test-identify-roxygen-examples.R | 2 -- tests/testthat/test-indention_curly.R | 2 -- tests/testthat/test-indention_fun_calls.R | 2 -- tests/testthat/test-indention_multiple.R | 2 -- tests/testthat/test-indention_operators.R | 2 -- tests/testthat/test-indention_round_brackets.R | 2 -- tests/testthat/test-insertion_comment_interaction.R | 2 -- tests/testthat/test-line_breaks_and_other.R | 2 -- tests/testthat/test-line_breaks_fun_call.R | 1 - tests/testthat/test-math_token_spacing.R | 2 -- tests/testthat/test-parsing.R | 2 -- tests/testthat/test-relocate_eq_assign.R | 1 - tests/testthat/test-rmd.R | 2 -- tests/testthat/test-rnw.R | 2 -- tests/testthat/test-roundtrip.R | 3 --- tests/testthat/test-roxygen-examples-parse.R | 2 -- tests/testthat/test-scope-AsIs.R | 2 -- tests/testthat/test-scope-character.R | 2 -- tests/testthat/test-serialize_tests.R | 2 -- tests/testthat/test-spacing.R | 2 -- tests/testthat/test-square_brackets.R | 2 -- tests/testthat/test-start_line.R | 2 -- tests/testthat/test-strict.R | 2 -- tests/testthat/test-tidyeval.R | 2 -- tests/testthat/test-token_adding_removing.R | 2 -- tests/testthat/test-unary.R | 2 -- tests/testthat/test-unindention.R | 2 -- tests/testthat/test-unindention_regex.R | 1 - tests/testthat/test-utils.R | 2 -- tests/testthat/test-varia.R | 2 -- 35 files changed, 68 deletions(-) diff --git a/tests/testthat/test-create_token.R b/tests/testthat/test-create_token.R index c00892808..bf99b6dcb 100644 --- a/tests/testthat/test-create_token.R +++ b/tests/testthat/test-create_token.R @@ -1,5 +1,3 @@ - - test_that("can create a token that has relevant columns", { pd_names <- c( "token", "text", "short", "lag_newlines", "newlines", "pos_id", diff --git a/tests/testthat/test-create_tree.R b/tests/testthat/test-create_tree.R index c8bcfb319..e6ab27068 100644 --- a/tests/testthat/test-create_tree.R +++ b/tests/testthat/test-create_tree.R @@ -1,5 +1,3 @@ - - test_that("create_trees outputs identical structure if trees have same structure", { skip_if_not_installed("DiagrammeR") skip_if_not_installed("data.tree") diff --git a/tests/testthat/test-curly-curly.R b/tests/testthat/test-curly-curly.R index d61299e75..7d1008cf5 100644 --- a/tests/testthat/test-curly-curly.R +++ b/tests/testthat/test-curly-curly.R @@ -1,5 +1,3 @@ - - test_that("curly-culry", { expect_warning(test_collection("curly-curly", "mixed", diff --git a/tests/testthat/test-exception_handling.R b/tests/testthat/test-exception_handling.R index 74afef5e8..7bf1b9f1d 100644 --- a/tests/testthat/test-exception_handling.R +++ b/tests/testthat/test-exception_handling.R @@ -1,5 +1,3 @@ - - test_that("style_text returns custom error", { expect_error(style_text("a <- 3 4"), "unexpected numeric constant") }) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index c5f3a5619..139a86314 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,5 +1,3 @@ - - test_that("can construct and print vertical", { skip_if_not_installed("prettycode") expect_snapshot({ diff --git a/tests/testthat/test-identify-roxygen-examples.R b/tests/testthat/test-identify-roxygen-examples.R index 8eee143e2..0b89c6fde 100644 --- a/tests/testthat/test-identify-roxygen-examples.R +++ b/tests/testthat/test-identify-roxygen-examples.R @@ -1,5 +1,3 @@ - - #' Things to consider: #' * one function declaration or many #' * example(s) is last tag or not? diff --git a/tests/testthat/test-indention_curly.R b/tests/testthat/test-indention_curly.R index 5064dcb4d..fe0e1d928 100644 --- a/tests/testthat/test-indention_curly.R +++ b/tests/testthat/test-indention_curly.R @@ -1,5 +1,3 @@ - - test_that("indention on one-liner curley only is not changed", { expect_warning(test_collection("indention_curly_brackets", "one_line_curly", diff --git a/tests/testthat/test-indention_fun_calls.R b/tests/testthat/test-indention_fun_calls.R index f44c037b8..eddb4e639 100644 --- a/tests/testthat/test-indention_fun_calls.R +++ b/tests/testthat/test-indention_fun_calls.R @@ -1,5 +1,3 @@ - - test_that("edge cases work", { expect_warning(test_collection("indention_fun_calls", transformer = style_text, strict = FALSE diff --git a/tests/testthat/test-indention_multiple.R b/tests/testthat/test-indention_multiple.R index a99634f3d..c9d68feac 100644 --- a/tests/testthat/test-indention_multiple.R +++ b/tests/testthat/test-indention_multiple.R @@ -1,5 +1,3 @@ - - test_that("multiple round brackets don't cause extraindention", { expect_warning(test_collection("indention_multiple", "round_only", diff --git a/tests/testthat/test-indention_operators.R b/tests/testthat/test-indention_operators.R index 3e62f85f8..2e7d1d4ff 100644 --- a/tests/testthat/test-indention_operators.R +++ b/tests/testthat/test-indention_operators.R @@ -1,5 +1,3 @@ - - test_that("pipe is indended correctly", { expect_warning(test_collection("indention_operators", "pipe", diff --git a/tests/testthat/test-indention_round_brackets.R b/tests/testthat/test-indention_round_brackets.R index c0c6a9409..1e01ade44 100644 --- a/tests/testthat/test-indention_round_brackets.R +++ b/tests/testthat/test-indention_round_brackets.R @@ -1,5 +1,3 @@ - - test_that("one-line function call yields correct indention", { expect_warning(test_collection("indention_round_brackets", "one_line", diff --git a/tests/testthat/test-insertion_comment_interaction.R b/tests/testthat/test-insertion_comment_interaction.R index 698b58d03..e9b97cdc4 100644 --- a/tests/testthat/test-insertion_comment_interaction.R +++ b/tests/testthat/test-insertion_comment_interaction.R @@ -1,5 +1,3 @@ - - ## ............................................................................ ## strict = TRUE #### diff --git a/tests/testthat/test-line_breaks_and_other.R b/tests/testthat/test-line_breaks_and_other.R index 7568ac71f..512f09fe7 100644 --- a/tests/testthat/test-line_breaks_and_other.R +++ b/tests/testthat/test-line_breaks_and_other.R @@ -1,5 +1,3 @@ - - test_that("line breaks involing curly brackets", { expect_warning(test_collection("line_breaks_and_other", "curly", transformer = style_text diff --git a/tests/testthat/test-line_breaks_fun_call.R b/tests/testthat/test-line_breaks_fun_call.R index 939a95d1b..375232630 100644 --- a/tests/testthat/test-line_breaks_fun_call.R +++ b/tests/testthat/test-line_breaks_fun_call.R @@ -1,4 +1,3 @@ - test_that("line breaks work in general", { expect_warning(test_collection("line_breaks_fun_call", "token_dependent_mixed", diff --git a/tests/testthat/test-math_token_spacing.R b/tests/testthat/test-math_token_spacing.R index 9b1aa9009..dd03370f0 100644 --- a/tests/testthat/test-math_token_spacing.R +++ b/tests/testthat/test-math_token_spacing.R @@ -1,5 +1,3 @@ - - test_that("invalid tokens return error", { expect_error(test_collection( "math_token_spacing", "non_strict_math_spacing_all", diff --git a/tests/testthat/test-parsing.R b/tests/testthat/test-parsing.R index c5cb2463a..f64314009 100644 --- a/tests/testthat/test-parsing.R +++ b/tests/testthat/test-parsing.R @@ -1,5 +1,3 @@ - - test_that("repreated parsing solves wrong parent assignment", { expect_warning( test_collection( diff --git a/tests/testthat/test-relocate_eq_assign.R b/tests/testthat/test-relocate_eq_assign.R index fe7b13bc1..0fbcd40b8 100644 --- a/tests/testthat/test-relocate_eq_assign.R +++ b/tests/testthat/test-relocate_eq_assign.R @@ -1,4 +1,3 @@ - # Tests code in R/relevel.R test_that("tree hierarchy is the same no matter whether = or <- is used", { skip_if_not_installed("DiagrammeR") diff --git a/tests/testthat/test-rmd.R b/tests/testthat/test-rmd.R index 6ff803d80..79811ba60 100644 --- a/tests/testthat/test-rmd.R +++ b/tests/testthat/test-rmd.R @@ -1,5 +1,3 @@ - - test_that("can style .Rmd files", { expect_warning(test_collection("rmd", "simple", transformer = transform_mixed, diff --git a/tests/testthat/test-rnw.R b/tests/testthat/test-rnw.R index 1a9158d3f..206d63b89 100644 --- a/tests/testthat/test-rnw.R +++ b/tests/testthat/test-rnw.R @@ -1,5 +1,3 @@ - - test_that("can style .Rnw files", { expect_warning(test_collection( "rnw", "008-outdec", diff --git a/tests/testthat/test-roundtrip.R b/tests/testthat/test-roundtrip.R index d50242bc2..a92dd8598 100644 --- a/tests/testthat/test-roundtrip.R +++ b/tests/testthat/test-roundtrip.R @@ -1,6 +1,3 @@ - - - test_that("parse_tree_must_be_identical works", { expect_true( parse_tree_must_be_identical(tidyverse_style(scope = "line_breaks")) diff --git a/tests/testthat/test-roxygen-examples-parse.R b/tests/testthat/test-roxygen-examples-parse.R index d733b1585..5a1a56c96 100644 --- a/tests/testthat/test-roxygen-examples-parse.R +++ b/tests/testthat/test-roxygen-examples-parse.R @@ -1,5 +1,3 @@ - - test_that("simple examples can be parsed", { expected_out <- c("\n", "x <- 1\n") expect_equal(parse_roxygen(c("#' @examples", "#' x <- 1"))$text, expected_out) diff --git a/tests/testthat/test-scope-AsIs.R b/tests/testthat/test-scope-AsIs.R index 97eec4ebf..5ea573ca2 100644 --- a/tests/testthat/test-scope-AsIs.R +++ b/tests/testthat/test-scope-AsIs.R @@ -1,5 +1,3 @@ - - test_that("no indention manipulation but spaces manipulation", { expect_warning(test_collection( "scope-AsIs", "scope_spaces-", diff --git a/tests/testthat/test-scope-character.R b/tests/testthat/test-scope-character.R index 256f7d670..ef7ee0d2d 100644 --- a/tests/testthat/test-scope-character.R +++ b/tests/testthat/test-scope-character.R @@ -1,5 +1,3 @@ - - test_that("no indention manipulation but spaces manipulation", { expect_warning(test_collection( "scope-character", "scope_spaces", diff --git a/tests/testthat/test-serialize_tests.R b/tests/testthat/test-serialize_tests.R index 2b858a77a..cab2100e3 100644 --- a/tests/testthat/test-serialize_tests.R +++ b/tests/testthat/test-serialize_tests.R @@ -1,5 +1,3 @@ - - test_that("No files to compare returns error", { expect_error(test_collection("serialize_tests", "xyz", transformer = as_is diff --git a/tests/testthat/test-spacing.R b/tests/testthat/test-spacing.R index 9caadf9e4..7fdb6e55a 100644 --- a/tests/testthat/test-spacing.R +++ b/tests/testthat/test-spacing.R @@ -1,5 +1,3 @@ - - test_that("curly braces", { expect_warning(test_collection( "spacing", "round", diff --git a/tests/testthat/test-square_brackets.R b/tests/testthat/test-square_brackets.R index a400c1f30..7f4c4d481 100644 --- a/tests/testthat/test-square_brackets.R +++ b/tests/testthat/test-square_brackets.R @@ -1,5 +1,3 @@ - - test_that("square brackets cause indention", { expect_warning(test_collection( "indention_square_brackets", diff --git a/tests/testthat/test-start_line.R b/tests/testthat/test-start_line.R index f154dc555..bb17a2aad 100644 --- a/tests/testthat/test-start_line.R +++ b/tests/testthat/test-start_line.R @@ -1,5 +1,3 @@ - - test_that("leading spaces are preserved at start of text", { expect_warning(test_collection("start_line", transformer = style_empty diff --git a/tests/testthat/test-strict.R b/tests/testthat/test-strict.R index 774096980..da8ea93e4 100644 --- a/tests/testthat/test-strict.R +++ b/tests/testthat/test-strict.R @@ -1,5 +1,3 @@ - - test_that("can style example source file with strict = TRUE", { expect_warning(test_collection( "strict", "strict", diff --git a/tests/testthat/test-tidyeval.R b/tests/testthat/test-tidyeval.R index 76b7a2457..5d1c074f6 100644 --- a/tests/testthat/test-tidyeval.R +++ b/tests/testthat/test-tidyeval.R @@ -1,5 +1,3 @@ - - test_that("no spaces within bang-bang operator !!!", { expect_warning(test_collection("tidyeval", "bang_bang", transformer = style_text diff --git a/tests/testthat/test-token_adding_removing.R b/tests/testthat/test-token_adding_removing.R index cd0026a0f..47ad6703d 100644 --- a/tests/testthat/test-token_adding_removing.R +++ b/tests/testthat/test-token_adding_removing.R @@ -1,5 +1,3 @@ - - test_that("other manipulations are correct (add braces, semi-colon etc.)", { expect_warning(test_collection("token_adding_removing", "mixed_token", transformer = style_text diff --git a/tests/testthat/test-unary.R b/tests/testthat/test-unary.R index 8fe52eb0c..264e58ae7 100644 --- a/tests/testthat/test-unary.R +++ b/tests/testthat/test-unary.R @@ -1,5 +1,3 @@ - - test_that("no spaces before unary operator", { expect_warning(test_collection("unary_spacing", "unary_simple", diff --git a/tests/testthat/test-unindention.R b/tests/testthat/test-unindention.R index cd06de29c..ea48778d1 100644 --- a/tests/testthat/test-unindention.R +++ b/tests/testthat/test-unindention.R @@ -1,5 +1,3 @@ - - test_that("round brackets are unindented correctly", { expect_warning(test_collection("unindention", "mixed", diff --git a/tests/testthat/test-unindention_regex.R b/tests/testthat/test-unindention_regex.R index 7e364fa46..1eace2b0b 100644 --- a/tests/testthat/test-unindention_regex.R +++ b/tests/testthat/test-unindention_regex.R @@ -1,4 +1,3 @@ - test_that("forced regex token-dependent indention", { expect_warning(test_collection( "unindention_regex", "regex_force_with", diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index ed43923ff..f11e241fd 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,5 +1,3 @@ - - test_that("non-comment-helpers", { pd <- compute_parse_data_nested("a <- # hi \n x %>% b()") child <- pd$child[[1]] diff --git a/tests/testthat/test-varia.R b/tests/testthat/test-varia.R index 422363a0d..effc0f865 100644 --- a/tests/testthat/test-varia.R +++ b/tests/testthat/test-varia.R @@ -1,5 +1,3 @@ - - test_that("ensure_last_n_empty", { expect_equal( ensure_last_n_empty("x"), From 1e52d5a03273cb78b9a9dffcf7cc1edccee151a3 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 22 Aug 2023 14:00:37 +0200 Subject: [PATCH 51/60] fix workflow --- .github/workflows/check-full.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index b0eba4048..bb5bb162b 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -56,7 +56,7 @@ jobs: - uses: r-lib/actions/check-r-package@v2 with: upload-snapshots: true - error-on: 'ifelse(getRversion() > 3.6, "warning", "note")' + error-on: 'ifelse(getRversion() > "3.6", "warning", "note")' env: _R_CHECK_FORCE_SUGGESTS_: false _R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_: true From f7fdd00f7d5962bfae8d4293fd87ca1a9a4cd203 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 22 Aug 2023 18:01:25 +0200 Subject: [PATCH 52/60] Bump version to 1.10.2 --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 27ae3bd79..e38798e39 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: styler Title: Non-Invasive Pretty Printing of R Code -Version: 1.10.1 +Version: 1.10.2 Authors@R: c(person(given = "Kirill", family = "Müller", diff --git a/NEWS.md b/NEWS.md index 6dc69a941..1e5adc0c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ + + +# styler 1.10.2 + +- Same as previous version. + + # styler 1.10.1 This release was requested by CRAN due to accidentally populating a user cache while building vignettes for R >= 4.3.0. From 70a7b78d45082b124e4583fa83586f4fe548ddf4 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 23 Aug 2023 08:43:41 +0200 Subject: [PATCH 53/60] update news --- NEWS.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 1e5adc0c9..d189fd61f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,8 +2,21 @@ # styler 1.10.2 -- Same as previous version. +This release was requested by the CRAN team to fix CRAN warning on invalid +numeric version inputs (#1143). +**Minor changes** + +* Use cli messaging for cache (#1127). +* Use latest (and stable!) pre-commit (#1144). +* Fix CRAN warning on invalid numeric version inputs (#1143). +* Bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 (#1139). +* fix pre-commit (#1132). +* Don't require dplyr anywhere (#1131). + +We thank everyone who helped making this release possible. + +[@krlmlr](https://github.com/krlmlr), [@lorenzwalthert](https://github.com/lorenzwalthert), [@MichaelChirico](https://github.com/MichaelChirico), [@olivroy](https://github.com/olivroy), [@rkrug](https://github.com/rkrug), and [@rossdrucker](https://github.com/rossdrucker). # styler 1.10.1 From afdf5d25f0f39480d355d1ea0fde9c8ecf2c4a71 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 23 Aug 2023 08:46:51 +0200 Subject: [PATCH 54/60] update cran comments --- cran-comments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index ed38adf29..747d0b082 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -4,8 +4,8 @@ editor_options: wrap: 79 --- -This is a release requested by the CRAN team to delete the population of the -user's cache while building vignettes. +This is a release requested by the CRAN team to comply with +`R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS`. ## Test environments From 790bbcca61b0deb12b717e36af422afa007ddce2 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 23 Aug 2023 08:51:16 +0200 Subject: [PATCH 55/60] fix windevel warnings --- R/parse.R | 1 - R/rules-line-breaks.R | 4 +++- man/is_insufficiently_parsed_string.Rd | 2 -- man/set_line_break_after_opening_if_call_is_multi_line.Rd | 6 ++++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/parse.R b/R/parse.R index 6beadd942..4ddbb72db 100644 --- a/R/parse.R +++ b/R/parse.R @@ -182,7 +182,6 @@ ensure_correct_txt <- function(pd, text) { #' changes from "all strings" to "all problematic strings", is partly #' misleading and this approach was chosen for performance reasons only. #' @param pd A parse table. -#' @param text The initial code to style. #' @keywords internal is_insufficiently_parsed_string <- function(pd) { grepl("^\\[", pd$text) & pd$token == "STR_CONST" diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index badff81eb..f0805cc94 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -282,7 +282,9 @@ set_line_break_after_assignment <- function(pd) { NULL #' Sets line break after opening parenthesis -#' +#' @param pd The parse table. +#' @param except_token_after,except_token_before The tokens before or after the +#' token that cause an exception. #' @details #' In general, every call that is multi-line has a line break after the opening #' parenthesis. Exceptions: diff --git a/man/is_insufficiently_parsed_string.Rd b/man/is_insufficiently_parsed_string.Rd index 83cdfb67a..0344443c4 100644 --- a/man/is_insufficiently_parsed_string.Rd +++ b/man/is_insufficiently_parsed_string.Rd @@ -8,8 +8,6 @@ is_insufficiently_parsed_string(pd) } \arguments{ \item{pd}{A parse table.} - -\item{text}{The initial code to style.} } \description{ Identifies strings that were not fully parsed due to their vast length. diff --git a/man/set_line_break_after_opening_if_call_is_multi_line.Rd b/man/set_line_break_after_opening_if_call_is_multi_line.Rd index 417c04a1a..328d56391 100644 --- a/man/set_line_break_after_opening_if_call_is_multi_line.Rd +++ b/man/set_line_break_after_opening_if_call_is_multi_line.Rd @@ -11,6 +11,12 @@ set_line_break_after_opening_if_call_is_multi_line( force_text_before = NULL ) } +\arguments{ +\item{pd}{The parse table.} + +\item{except_token_after, except_token_before}{The tokens before or after the +token that cause an exception.} +} \description{ Sets line break after opening parenthesis } From 9402414e72f06dbea2201bcc6a01a40d1f2ec267 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 26 Aug 2023 21:39:16 +0200 Subject: [PATCH 56/60] fix roxygen --- R/rules-line-breaks.R | 22 +++++++++---------- ...eak_after_opening_if_call_is_multi_line.Rd | 9 ++++++-- man/set_line_break_if_call_is_multi_line.Rd | 16 +++++--------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index f0805cc94..6febecc6a 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -268,14 +268,8 @@ set_line_break_after_assignment <- function(pd) { #' Set line break for multi-line function calls #' @param pd A parse table. -#' @param except_token_after A character vector with tokens after "'('" that do -#' not cause a line break after "'('". -#' @param except_text_before A character vector with text before "'('" that do -#' not cause a line break after "'('". -#' @param except_token_before A character vector with text before "')'" that do -#' not cause a line break before "')'". -#' @param force_text_before A character vector with text before "'('" that -#' forces a line break after every argument in the call. +#' @param except_token_before A character vector with tokens that do +#' not cause a line break after them. #' @name set_line_break_if_call_is_multi_line #' #' @keywords internal @@ -283,8 +277,11 @@ NULL #' Sets line break after opening parenthesis #' @param pd The parse table. -#' @param except_token_after,except_token_before The tokens before or after the -#' token that cause an exception. +#' @param except_token_after The tokens after the token that cause an exception. +#' @param except_text_before A character vector with text before a token that +#' does not cause a line break. +#' @param force_text_before A character vector with text before "'('" that +#' forces a line break after every argument in the call. #' @details #' In general, every call that is multi-line has a line break after the opening #' parenthesis. Exceptions: @@ -343,7 +340,7 @@ set_line_break_after_opening_if_call_is_multi_line <- function(pd, #' position of the first named argument and breaks returns the index of it. #' If there is no named argument, the line is broken right after the opening #' parenthesis. -#' @inheritParams set_line_break_if_call_is_multi_line +#' @param pd A parse table. #' @keywords internal find_line_break_position_in_multiline_call <- function(pd) { candidate <- (which(pd$token == "EQ_SUB") - 1L)[1L] @@ -379,7 +376,8 @@ set_line_break_before_closing_call <- function(pd, except_token_before) { } -#' @rdname set_line_break_if_call_is_multi_line +#' @describeIn set_line_break_if_call_is_multi_line Remove line breaks in +#' function calls. #' @keywords internal remove_line_break_in_fun_call <- function(pd, strict) { if (is_function_call(pd)) { diff --git a/man/set_line_break_after_opening_if_call_is_multi_line.Rd b/man/set_line_break_after_opening_if_call_is_multi_line.Rd index 328d56391..174bee142 100644 --- a/man/set_line_break_after_opening_if_call_is_multi_line.Rd +++ b/man/set_line_break_after_opening_if_call_is_multi_line.Rd @@ -14,8 +14,13 @@ set_line_break_after_opening_if_call_is_multi_line( \arguments{ \item{pd}{The parse table.} -\item{except_token_after, except_token_before}{The tokens before or after the -token that cause an exception.} +\item{except_token_after}{The tokens after the token that cause an exception.} + +\item{except_text_before}{A character vector with text before a token that +does not cause a line break.} + +\item{force_text_before}{A character vector with text before "'('" that +forces a line break after every argument in the call.} } \description{ Sets line break after opening parenthesis diff --git a/man/set_line_break_if_call_is_multi_line.Rd b/man/set_line_break_if_call_is_multi_line.Rd index a8482a378..b7ad972eb 100644 --- a/man/set_line_break_if_call_is_multi_line.Rd +++ b/man/set_line_break_if_call_is_multi_line.Rd @@ -13,17 +13,8 @@ remove_line_break_in_fun_call(pd, strict) \arguments{ \item{pd}{A parse table.} -\item{except_token_before}{A character vector with text before "')'" that do -not cause a line break before "')'".} - -\item{except_token_after}{A character vector with tokens after "'('" that do -not cause a line break after "'('".} - -\item{except_text_before}{A character vector with text before "'('" that do -not cause a line break after "'('".} - -\item{force_text_before}{A character vector with text before "'('" that -forces a line break after every argument in the call.} +\item{except_token_before}{A character vector with tokens that do +not cause a line break after them.} } \description{ Set line break for multi-line function calls @@ -33,5 +24,8 @@ Set line break for multi-line function calls \item \code{set_line_break_before_closing_call()}: Sets line break before closing parenthesis. +\item \code{remove_line_break_in_fun_call()}: Remove line breaks in +function calls. + }} \keyword{internal} From f6a311d813b8e05858c75594f3e32e9736d0468d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 27 Aug 2023 14:08:23 +0200 Subject: [PATCH 57/60] make benchmark less tight --- tests/testthat/tests-cache-require-serial.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/tests-cache-require-serial.R b/tests/testthat/tests-cache-require-serial.R index 96c861247..ae7226b3c 100644 --- a/tests/testthat/tests-cache-require-serial.R +++ b/tests/testthat/tests-cache-require-serial.R @@ -25,7 +25,7 @@ test_that("top-level test: Caches top-level expressions efficiently on style_tex partially_cached_benchmark["elapsed"] * 1.5, not_cached_benchmark["elapsed"] ) - expect_lt(full_cached_benchmark["elapsed"] * 35, benchmark["elapsed"]) + expect_lt(full_cached_benchmark["elapsed"] * 30, benchmark["elapsed"]) }) From 9b31d04972d285c20f090963b06be20c4eb06922 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 03:56:49 +0000 Subject: [PATCH 58/60] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-all-examples.yaml | 2 +- .github/workflows/check-full.yaml | 2 +- .github/workflows/check-link-rot.yaml | 2 +- .github/workflows/pkgdown.yaml | 2 +- .github/workflows/pre-commit.yaml | 2 +- .github/workflows/test-coverage.yaml | 2 +- .github/workflows/touchstone-receive.yaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml index 7de30a17f..36415fc90 100644 --- a/.github/workflows/check-all-examples.yaml +++ b/.github/workflows/check-all-examples.yaml @@ -22,7 +22,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index bb5bb162b..dfeb4cc4e 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -38,7 +38,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/check-link-rot.yaml b/.github/workflows/check-link-rot.yaml index 666d27c86..3d977b694 100644 --- a/.github/workflows/check-link-rot.yaml +++ b/.github/workflows/check-link-rot.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 520d1e570..48e1d1dc7 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -20,7 +20,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 0ab0603db..fbbded7a6 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -21,7 +21,7 @@ jobs: uses: styfle/cancel-workflow-action@0.11.0 with: access_token: ${{ github.token }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install system dependencies diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index fe87549b5..d9d5c3d89 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/touchstone-receive.yaml b/.github/workflows/touchstone-receive.yaml index b1b462650..361368720 100644 --- a/.github/workflows/touchstone-receive.yaml +++ b/.github/workflows/touchstone-receive.yaml @@ -24,7 +24,7 @@ jobs: config: ${{ steps.read_touchstone_config.outputs.config }} steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 From 25992d8e3967310904dafc7bf16788e0649ca7e3 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Mon, 11 Sep 2023 09:26:28 +0200 Subject: [PATCH 59/60] Clean new lints --- R/rules-indention.R | 2 +- R/rules-line-breaks.R | 1 - R/transform-files.R | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/rules-indention.R b/R/rules-indention.R index 7019ef7e6..30cf7b246 100644 --- a/R/rules-indention.R +++ b/R/rules-indention.R @@ -20,7 +20,7 @@ indent_braces <- function(pd, indent_by) { #' @keywords internal unindent_fun_dec <- function(pd, indent_by = 2L) { if (is_function_declaration(pd)) { - idx_closing_brace <- which(pd$token %in% "')'") + idx_closing_brace <- which(pd$token == "')'") fun_dec_head <- seq2(2L, idx_closing_brace) if (is_double_indent_function_declaration(pd, indent_by = indent_by)) { pd$indent[fun_dec_head] <- 2L * indent_by diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 6febecc6a..5c6f3345b 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -153,7 +153,6 @@ style_line_break_around_curly <- function(strict, pd) { closing_before <- pd$token == "'}'" opening_before <- (pd$token == "'{'") to_break <- lag(opening_before, default = FALSE) | closing_before - len_to_break <- sum(to_break) pd$lag_newlines[to_break] <- ifelse( pd$token[to_break] == "COMMENT", pmin(1L, pd$lag_newlines[to_break]), diff --git a/R/transform-files.R b/R/transform-files.R index 3fb769fbc..a79c4a61b 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -116,9 +116,12 @@ make_transformer <- function(transformers, use_cache <- FALSE } - if (!use_cache) { + if (use_cache) { + text + } else { transformed_code <- text %>% - parse_transform_serialize_r(transformers, + parse_transform_serialize_r( + transformers, base_indention = base_indention, warn_empty = warn_empty ) @@ -139,8 +142,6 @@ make_transformer <- function(transformers, } transformed_code - } else { - text } } } From 07d93915c6fd91af2a37ba7e8bd3faa439760bd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 03:32:10 +0000 Subject: [PATCH 60/60] Bump styfle/cancel-workflow-action from 0.11.0 to 0.12.0 Bumps [styfle/cancel-workflow-action](https://github.com/styfle/cancel-workflow-action) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/styfle/cancel-workflow-action/releases) - [Commits](https://github.com/styfle/cancel-workflow-action/compare/0.11.0...0.12.0) --- updated-dependencies: - dependency-name: styfle/cancel-workflow-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/pre-commit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index fbbded7a6..14b388dea 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -18,7 +18,7 @@ jobs: ) steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 + uses: styfle/cancel-workflow-action@0.12.0 with: access_token: ${{ github.token }} - uses: actions/checkout@v4