diff --git a/.github/workflows/check-all-examples.yaml b/.github/workflows/check-all-examples.yaml deleted file mode 100644 index 36415fc90..000000000 --- a/.github/workflows/check-all-examples.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Make sure all examples run successfully, even the ones that are not supposed -# to be run or tested on CRAN machines by default. -# -# The examples that fail should use -# - `if (FALSE) { ... }` (if example is included only for illustrative purposes) -# - `try({ ... })` (if the intent is to show the error) -# -# This workflow helps find such failing examples that need to be modified. - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: check-all-examples - -jobs: - check-all-examples: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - pak-version: devel - extra-packages: | - any::devtools - local::. - - - name: Run examples - run: | - options(crayon.enabled = TRUE) - devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE) - shell: Rscript {0} diff --git a/.github/workflows/check-no-warnings.yaml b/.github/workflows/check-no-warnings.yaml new file mode 100644 index 000000000..4b792a68d --- /dev/null +++ b/.github/workflows/check-no-warnings.yaml @@ -0,0 +1,48 @@ +# execute all examples and tests with warnings turned into errors to look for new warnings +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: check-no-warnings + +jobs: + check-no-warnings: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + pak-version: devel + extra-packages: | + any::devtools + local::. + + - name: Run examples + run: | + options(crayon.enabled = TRUE, warn = 2L) + devtools::run_examples(fresh = TRUE, run_dontrun = TRUE, run_donttest = TRUE) + shell: Rscript {0} + + - name: Run Tests + run: | + options(crayon.enabled = TRUE) + pkgload::load_all() + # this workaround needed to play nicely with parallel testing + # see: https://github.com/r-lib/testthat/issues/1912 + test_script_paths <- testthat::find_test_scripts("tests/testthat") + test_with_warning_as_error <- function(path) { + withr::local_options(list(warn = 2L)) + testthat::test_file(path, stop_on_failure = TRUE, stop_on_warning = TRUE) + } + purrr::walk(test_script_paths, test_with_warning_as_error) + shell: Rscript {0} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index dad368915..466abf1e0 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.6.1 + uses: JamesIves/github-pages-deploy-action@v4.6.9 with: clean: false branch: gh-pages diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 690143359..c049998ee 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -25,7 +25,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.3.0 with: python-version: "3.9" architecture: "x64" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf22944df..4f34c10b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,6 @@ repos: )$ - id: roxygenize additional_dependencies: - - r-lib/pkgapi - dplyr - roxygen2 - rlang @@ -102,7 +101,7 @@ repos: )$ - id: pkgdown - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files args: ["--maxkb=200"] @@ -120,7 +119,7 @@ repos: tests/testthat/_snaps/.*| )$ - repo: https://github.com/lorenzwalthert/gitignore-tidy - rev: 517cddbf1d8514ddaf43159686617ae65895dc99 + rev: 0.1.2 hooks: - id: tidy-gitignore - repo: local diff --git a/DESCRIPTION b/DESCRIPTION index 42229a06c..a7d401163 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate", if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else { warning("Please install r-lib/pkgapi to make sure the file API is kept up to date"); NULL})) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Language: en-US Config/testthat/edition: 3 Config/testthat/parallel: true diff --git a/R/rules-indention.R b/R/rules-indention.R index 30cf7b246..3e953d76e 100644 --- a/R/rules-indention.R +++ b/R/rules-indention.R @@ -15,15 +15,16 @@ indent_braces <- function(pd, indent_by) { #' #' Necessary for consistent indention of the function declaration header. #' @param pd A parse table. -#' @inheritParams is_double_indent_function_declaration +#' @inheritParams is_single_indent_function_declaration #' @seealso set_unindention_child update_indention_ref_fun_dec #' @keywords internal unindent_fun_dec <- function(pd, indent_by = 2L) { if (is_function_declaration(pd)) { 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 + if (is_single_indent_function_declaration(pd, indent_by = indent_by)) { + pd$indent[fun_dec_head] <- indent_by + pd$indent[idx_closing_brace] <- 0L } else { pd$indent[fun_dec_head] <- 0L } @@ -31,20 +32,21 @@ unindent_fun_dec <- function(pd, indent_by = 2L) { pd } -#' Is the function declaration double indented? +#' Is the function declaration single indented? #' #' Assumes you already checked if it's a function with -#' `is_function_declaration`. It is double indented if the first token +#' `is_function_declaration`. It is single indented if the first token #' after the first line break that is a `"SYMBOL_FORMALS"`. #' @param pd A parse table. #' @inheritParams tidyverse_style #' @keywords internal -is_double_indent_function_declaration <- function(pd, indent_by = 2L) { +is_single_indent_function_declaration <- function(pd, indent_by = 2L) { head_pd <- vec_slice(pd, -nrow(pd)) line_break_in_header <- which(head_pd$lag_newlines > 0L & head_pd$token == "SYMBOL_FORMALS") if (length(line_break_in_header) > 0L) { # indent results from applying the rules, spaces is the initial spaces # (which is indention if a newline is ahead) + # The 2L factor is kept to convert double indent to single indent pd$spaces[line_break_in_header[1L] - 1L] <= 2L * indent_by } else { FALSE @@ -132,7 +134,7 @@ NULL #' #' @keywords internal update_indention_ref_fun_dec <- function(pd_nested) { - if (is_function_declaration(pd_nested) && !is_double_indent_function_declaration(pd_nested)) { + if (is_function_declaration(pd_nested) && !is_single_indent_function_declaration(pd_nested)) { seq <- seq2(3L, nrow(pd_nested) - 2L) pd_nested$indention_ref_pos_id[seq] <- pd_nested$pos_id[2L] } diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 8fc492643..07229ebc9 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -149,15 +149,21 @@ set_line_break_around_comma_and_or <- function(pd, strict) { } style_line_break_around_curly <- function(strict, pd) { - if (is_curly_expr(pd) && nrow(pd) > 2L) { - closing_before <- pd$token == "'}'" - opening_before <- (pd$token == "'{'") - to_break <- lag(opening_before, default = FALSE) | closing_before - pd$lag_newlines[to_break] <- ifelse( - pd$token[to_break] == "COMMENT", - pmin(1L, pd$lag_newlines[to_break]), - if (strict) 1L else pmax(1L, pd$lag_newlines[to_break]) - ) + if (is_curly_expr(pd)) { + n_row <- nrow(pd) + if (n_row > 2L) { + closing_before <- pd$token == "'}'" + opening_before <- (pd$token == "'{'") + to_break <- lag(opening_before, default = FALSE) | closing_before + pd$lag_newlines[to_break] <- ifelse( + pd$token[to_break] == "COMMENT", + pmin(1L, pd$lag_newlines[to_break]), + if (strict) 1L else pmax(1L, pd$lag_newlines[to_break]) + ) + } else if (n_row == 2L) { + # pd represents {} + pd$lag_newlines[2L] <- 0L + } } else { is_else <- pd$token == "ELSE" if (any(pd$token_before[is_else] == "'}'")) { @@ -230,15 +236,17 @@ remove_line_break_before_round_closing_after_curly <- function(pd) { remove_line_breaks_in_fun_dec <- function(pd) { if (is_function_declaration(pd)) { - is_double_indention <- is_double_indent_function_declaration(pd) + is_single_indention <- is_single_indent_function_declaration(pd) round_after <- ( pd$token == "')'" | pd$token_before == "'('" ) & pd$token_before != "COMMENT" pd$lag_newlines[pd$lag_newlines > 1L] <- 1L - pd$lag_newlines[round_after] <- 0L - if (is_double_indention) { + if (is_single_indention) { pd$lag_newlines[lag(pd$token == "'('")] <- 1L + pd$lag_newlines[round_after] <- 1L + } else { + pd$lag_newlines[round_after] <- 0L } } pd diff --git a/R/rules-spaces.R b/R/rules-spaces.R index c96584d6c..54f4bf289 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -174,8 +174,9 @@ add_space_after_for_if_while <- function(pd_flat) { #' @rdname set_line_break_around_curly_curly #' @keywords internal -set_space_in_curly_curly <- function(pd) { +set_space_in_curly <- function(pd) { if (is_curly_expr(pd)) { + # curly-curly after_inner_opening <- pd$token == "'{'" & pd$token_before == "'{'" before_inner_closing <- lead(pd$token == "'}'" & pd$token_after == "'}'") is_curly_curly_inner <- any(after_inner_opening, na.rm = TRUE) && @@ -193,6 +194,10 @@ set_space_in_curly_curly <- function(pd) { pd$spaces[after_outer_opening] <- 0L pd$spaces[before_outer_closing] <- 0L } + + # empty curly + after_is_empty_curly <- lead(pd$token == "'}'" & pd$token_before == "'{'") + pd$spaces[after_is_empty_curly] <- 0L } pd } diff --git a/R/style-guides.R b/R/style-guides.R index 1445586ac..39fc30118 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -122,7 +122,7 @@ tidyverse_style <- function(scope = "tokens", }, set_space_between_levels = set_space_between_levels, set_space_between_eq_sub_and_comma = set_space_between_eq_sub_and_comma, - set_space_in_curly_curly = set_space_in_curly_curly + set_space_in_curly = set_space_in_curly ) } @@ -209,7 +209,7 @@ tidyverse_style <- function(scope = "tokens", start_comments_with_space = "COMMENT", remove_space_after_unary_pm_nested = c("'+'", "'-'"), spacing_before_comments = "COMMENT", - set_space_in_curly_curly = c("'{'", "'}'") + set_space_in_curly = c("'{'", "'}'") ), indention = list( # indent_braces = c("'('", "'['", "'{'", "')'", "']'", "'}'"), diff --git a/R/transform-code.R b/R/transform-code.R index 91b495e3a..7e2cba4ff 100644 --- a/R/transform-code.R +++ b/R/transform-code.R @@ -100,8 +100,9 @@ identify_raw_chunks <- function(lines, if (filetype == "Rmd") { starts <- grep( - "^[\t >]*```+\\s*\\{([Rr]( *[ ,].*)?)\\}\\s*$", lines, - perl = TRUE + "^[\t >]*```+\\s*\\{((r|webr-r|webr)( *[ ,].*)?)\\}\\s*$", + lines, + perl = TRUE, ignore.case = TRUE ) ends <- grep("^[\t >]*```+\\s*$", lines, perl = TRUE) ends <- purrr::imap_int(starts, ~ ends[which(ends > .x)[1L]]) %>% diff --git a/inst/WORDLIST b/inst/WORDLIST index 3b67a1317..a6c3937ce 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -15,7 +15,6 @@ bootswatch BugReports bXj cancelling -cff ci cli CMD @@ -29,7 +28,6 @@ counterpair coventions cpp cre -ctb cyclocomp cynkra dec @@ -37,7 +35,6 @@ dependabot desc devtools dir -docsearch dont dontrun dontshow @@ -102,7 +99,6 @@ linters lintr lorenz lorenzwalthert -macOS magrittr mav md diff --git a/man/is_double_indent_function_declaration.Rd b/man/is_single_indent_function_declaration.Rd similarity index 60% rename from man/is_double_indent_function_declaration.Rd rename to man/is_single_indent_function_declaration.Rd index d9a36a367..b186ec201 100644 --- a/man/is_double_indent_function_declaration.Rd +++ b/man/is_single_indent_function_declaration.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rules-indention.R -\name{is_double_indent_function_declaration} -\alias{is_double_indent_function_declaration} -\title{Is the function declaration double indented?} +\name{is_single_indent_function_declaration} +\alias{is_single_indent_function_declaration} +\title{Is the function declaration single indented?} \usage{ -is_double_indent_function_declaration(pd, indent_by = 2L) +is_single_indent_function_declaration(pd, indent_by = 2L) } \arguments{ \item{pd}{A parse table.} @@ -14,7 +14,7 @@ operators such as '('.} } \description{ Assumes you already checked if it's a function with -\code{is_function_declaration}. It is double indented if the first token +\code{is_function_declaration}. It is single indented if the first token after the first line break that is a \code{"SYMBOL_FORMALS"}. } \keyword{internal} diff --git a/man/set_line_break_around_curly_curly.Rd b/man/set_line_break_around_curly_curly.Rd index 06fd2fa9e..1215ff6d4 100644 --- a/man/set_line_break_around_curly_curly.Rd +++ b/man/set_line_break_around_curly_curly.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/rules-line-breaks.R, R/rules-spaces.R \name{set_line_break_around_curly_curly} \alias{set_line_break_around_curly_curly} -\alias{set_space_in_curly_curly} +\alias{set_space_in_curly} \title{Styling around \verb{\\\{\\\{}} \usage{ set_line_break_around_curly_curly(pd) -set_space_in_curly_curly(pd) +set_space_in_curly(pd) } \arguments{ \item{pd}{A parse table.} diff --git a/tests/testthat/fun_dec/line_break_fun_dec-out.R b/tests/testthat/fun_dec/line_break_fun_dec-out.R index f9d494561..f910b6b43 100644 --- a/tests/testthat/fun_dec/line_break_fun_dec-out.R +++ b/tests/testthat/fun_dec/line_break_fun_dec-out.R @@ -40,8 +40,9 @@ a <- function(x, } a <- function( - # - x, - y) { + # + x, + y +) { x - 1 } diff --git a/tests/testthat/indention_multiple/edge_strict_mixed-out.R b/tests/testthat/indention_multiple/edge_strict_mixed-out.R index dcfe06a07..0d95d3468 100644 --- a/tests/testthat/indention_multiple/edge_strict_mixed-out.R +++ b/tests/testthat/indention_multiple/edge_strict_mixed-out.R @@ -23,5 +23,4 @@ ))) -function(x, y, z) { -} +function(x, y, z) {} diff --git a/tests/testthat/indention_operators/eq_formals_complex_indention-out.R b/tests/testthat/indention_operators/eq_formals_complex_indention-out.R index 305fe6e1c..a2e1d79b8 100644 --- a/tests/testthat/indention_operators/eq_formals_complex_indention-out.R +++ b/tests/testthat/indention_operators/eq_formals_complex_indention-out.R @@ -1,27 +1,27 @@ function(a = - 33, - b - ) {} + 33, + b +) {} function(a = - 33, - b) {} + 33, + b) {} function(a, - b, - c - ) {} + b, + c +) {} function(a, - b, - c) {} + b, + c) {} function(ss, - a = - 3, - er = - 4 - ) {} + a = + 3, + er = + 4 +) {} function(a = b, diff --git a/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R b/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R index 612a4beed..9c001e666 100644 --- a/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R +++ b/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R @@ -1,35 +1,38 @@ function( - a = - 33, - b) {} + a = + 33, + b +) {} function( - a = - 33, - b) {} + a = + 33, + b +) {} function( - a, - b, - c) {} + a, + b, + c +) {} function( - a, - b, - c) {} + a, + b, + c +) {} function( - ss, - a = - 3, - er = - 4) {} + ss, + a = + 3, + er = + 4 +) {} function(a = b, f = d, c = 3, d = - 4) { - -} + 4) {} diff --git a/tests/testthat/indention_operators/eq_sub_complex_indention-out.R b/tests/testthat/indention_operators/eq_sub_complex_indention-out.R index 02b322973..03c121d81 100644 --- a/tests/testthat/indention_operators/eq_sub_complex_indention-out.R +++ b/tests/testthat/indention_operators/eq_sub_complex_indention-out.R @@ -10,8 +10,8 @@ b # multiple nested levels { v <- function(x = - 122, - y) { + 122, + y) { } } diff --git a/tests/testthat/line_breaks_and_other/braces-fun-calls2-out.R b/tests/testthat/line_breaks_and_other/braces-fun-calls2-out.R index 14e0fadc3..340e1eaf8 100644 --- a/tests/testthat/line_breaks_and_other/braces-fun-calls2-out.R +++ b/tests/testthat/line_breaks_and_other/braces-fun-calls2-out.R @@ -1,8 +1,6 @@ test( "x", - { - - }, + {}, a + b, { s(x = sd) @@ -11,9 +9,7 @@ test( test( "x", - { - - }, + {}, a + b, { s(x = sd) @@ -22,9 +18,7 @@ test( test( "x", - { - - }, + {}, a + b, { s(x = sd) @@ -34,9 +28,7 @@ test( test( "x", - { - - }, + {}, a + b, { s(x = sd) @@ -45,9 +37,7 @@ test( test( "x", - { - - }, # h + {}, # h a + b, { s(x = sd) @@ -56,9 +46,7 @@ test( test( "x", - { - - }, # h + {}, # h a + b, # k { @@ -68,9 +56,7 @@ test( test( "x", - { - - }, + {}, a + b, # k { s(x = sd) diff --git a/tests/testthat/line_breaks_and_other/curly-in.R b/tests/testthat/line_breaks_and_other/curly-in.R index 9f44b5716..8da4db732 100644 --- a/tests/testthat/line_breaks_and_other/curly-in.R +++ b/tests/testthat/line_breaks_and_other/curly-in.R @@ -41,3 +41,21 @@ test_that( # comment expect_equal(1 + 1, 2) }) + + +while (TRUE) { } + +while (TRUE) + { } + +while (TRUE){ + + } + +while (TRUE){ +# + } + + +while (TRUE){# + } diff --git a/tests/testthat/line_breaks_and_other/curly-out.R b/tests/testthat/line_breaks_and_other/curly-out.R index c55508290..22730a44b 100644 --- a/tests/testthat/line_breaks_and_other/curly-out.R +++ b/tests/testthat/line_breaks_and_other/curly-out.R @@ -38,3 +38,18 @@ test_that( expect_equal(1 + 1, 2) } ) + + +while (TRUE) {} + +while (TRUE) {} + +while (TRUE) {} + +while (TRUE) { + # +} + + +while (TRUE) { # +} diff --git a/tests/testthat/line_breaks_fun_call/token_dependent_complex_non_strict-out.R b/tests/testthat/line_breaks_fun_call/token_dependent_complex_non_strict-out.R index 8ef14cf81..c4783fb6c 100644 --- a/tests/testthat/line_breaks_fun_call/token_dependent_complex_non_strict-out.R +++ b/tests/testthat/line_breaks_fun_call/token_dependent_complex_non_strict-out.R @@ -5,8 +5,7 @@ call(call( call(call(1, 2)) # multi-line: no indention based on first vall -call(a(b(c({ -})))) +call(a(b(c({})))) call(call( 2), diff --git a/tests/testthat/line_breaks_fun_call/token_dependent_complex_strict-out.R b/tests/testthat/line_breaks_fun_call/token_dependent_complex_strict-out.R index 093fd65cf..8e0309e98 100644 --- a/tests/testthat/line_breaks_fun_call/token_dependent_complex_strict-out.R +++ b/tests/testthat/line_breaks_fun_call/token_dependent_complex_strict-out.R @@ -7,8 +7,7 @@ call(call( 2 )) # multi-line: no indention based on first vall -call(a(b(c({ -})))) +call(a(b(c({})))) call( call( diff --git a/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R b/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R index 88ab28999..743269425 100644 --- a/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R +++ b/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R @@ -1,7 +1,5 @@ # A comment -a <- function() { - -} +a <- function() {} #+ chunk-label, opt1=value1 "chunk-content" diff --git a/tests/testthat/public-api/xyz-r-and-rmd-dir/subdir/random-script-in-sub-dir.R b/tests/testthat/public-api/xyz-r-and-rmd-dir/subdir/random-script-in-sub-dir.R index 1337474bf..4b6e446d9 100644 --- a/tests/testthat/public-api/xyz-r-and-rmd-dir/subdir/random-script-in-sub-dir.R +++ b/tests/testthat/public-api/xyz-r-and-rmd-dir/subdir/random-script-in-sub-dir.R @@ -1,4 +1,3 @@ # random this(is_a_call(x)) -if (x) { -} +if (x) {} diff --git a/tests/testthat/public-api/xyzdir/subdir/random-script-in-sub-dir.R b/tests/testthat/public-api/xyzdir/subdir/random-script-in-sub-dir.R index 1337474bf..4b6e446d9 100644 --- a/tests/testthat/public-api/xyzdir/subdir/random-script-in-sub-dir.R +++ b/tests/testthat/public-api/xyzdir/subdir/random-script-in-sub-dir.R @@ -1,4 +1,3 @@ # random this(is_a_call(x)) -if (x) { -} +if (x) {} diff --git a/tests/testthat/rmd/r_and_non_r_code_chunks-in.Rmd b/tests/testthat/rmd/r_and_non_r_code_chunks-in.Rmd index 8360de933..02dabe478 100644 --- a/tests/testthat/rmd/r_and_non_r_code_chunks-in.Rmd +++ b/tests/testthat/rmd/r_and_non_r_code_chunks-in.Rmd @@ -18,6 +18,14 @@ Some text. 1+1 ``` +```{webr} +1+1 +``` + +```{webr-r} +1+1 +``` + More text. ```{nonR} diff --git a/tests/testthat/rmd/r_and_non_r_code_chunks-out.Rmd b/tests/testthat/rmd/r_and_non_r_code_chunks-out.Rmd index 0e76de3f2..8188c5385 100644 --- a/tests/testthat/rmd/r_and_non_r_code_chunks-out.Rmd +++ b/tests/testthat/rmd/r_and_non_r_code_chunks-out.Rmd @@ -18,6 +18,14 @@ Some text. 1+1 ``` +```{webr} +1 + 1 +``` + +```{webr-r} +1 + 1 +``` + More text. ```{nonR} diff --git a/tests/testthat/spacing/round_curly-out.R b/tests/testthat/spacing/round_curly-out.R index e49f328b3..8f2a4c49a 100644 --- a/tests/testthat/spacing/round_curly-out.R +++ b/tests/testthat/spacing/round_curly-out.R @@ -1,5 +1,4 @@ -a <- function(x) { -} +a <- function(x) {} if (a) { 3 @@ -13,5 +12,4 @@ if (x) { y } else if (x) { x -} else { -} +} else {} diff --git a/tests/testthat/strict/non_strict-out.R b/tests/testthat/strict/non_strict-out.R index 08f773a73..64a698bb5 100644 --- a/tests/testthat/strict/non_strict-out.R +++ b/tests/testthat/strict/non_strict-out.R @@ -51,17 +51,13 @@ test <- function() { call }) - braced("unnamed reduces space", { - }) + braced("unnamed reduces space", {}) - braced("unnamed adds space space", { - }) + braced("unnamed adds space space", {}) - braced(named_reduces_space = { - }) + braced(named_reduces_space = {}) - braced(named_adds_space = { - }) + braced(named_adds_space = {}) braced({ empty_removes_space diff --git a/tests/testthat/strict/strict-out.R b/tests/testthat/strict/strict-out.R index 3422f4e5b..688cf7f88 100644 --- a/tests/testthat/strict/strict-out.R +++ b/tests/testthat/strict/strict-out.R @@ -34,17 +34,13 @@ test <- function() { call }) - braced("unnamed reduces space", { - }) + braced("unnamed reduces space", {}) - braced("unnamed adds space space", { - }) + braced("unnamed adds space space", {}) - braced(named_reduces_space = { - }) + braced(named_reduces_space = {}) - braced(named_adds_space = { - }) + braced(named_adds_space = {}) braced({ empty_removes_space diff --git a/tests/testthat/unindention/mixed-double-out.R b/tests/testthat/unindention/mixed-double-out.R index a1c7e24d2..44591e1f2 100644 --- a/tests/testthat/unindention/mixed-double-out.R +++ b/tests/testthat/unindention/mixed-double-out.R @@ -37,29 +37,33 @@ function(x, # double function( - x, - y) { + x, + y +) { 1 } function( - x, - y, - k) { + x, + y, + k +) { 1 } function( - x, - y) { + x, + y +) { 1 } function( - x, y) { + x, y +) { 1 } @@ -72,23 +76,23 @@ function(x, # last brace function( - x, y) { + x, y) { NULL } function( - x, y) { + x, y) { NULL } function( - x, - y) { + x, + y) { NULL } function( - x, - y) { + x, + y) { NULL }