From 9092498f4e27b1e4830baca4b719b49363af9397 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 19 Feb 2025 14:04:54 +0100 Subject: [PATCH] apply air to in files, then rename them to out and commit this does not include all files since air failed for some files --- .../overwrite-in-test-files-with-out-files.R | 31 +++ .../alignment/cols-with-one-row-out.R | 27 ++- tests/testthat/alignment/fun-decs-out.R | 39 ++-- tests/testthat/alignment/named-out.R | 189 +++++++++++------- .../alignment/one-col-some-named-out.R | 1 - tests/testthat/alignment/quoted-names-out.R | 3 +- tests/testthat/alignment/tribble-out.R | 43 ++-- .../alignment/tribble-three-cols-out.R | 12 +- .../cache-with-r-cache/mlflow-1-out.R | 99 +++++++++ tests/testthat/curly-curly/mixed-out.R | 47 +++-- tests/testthat/escaping/basic-escape-out.R | 16 +- tests/testthat/escaping/fail-parsing-1-out.R | 7 + tests/testthat/escaping/fail-parsing-2-out.R | 5 + tests/testthat/escaping/fail-parsing-3-out.R | 5 + tests/testthat/escaping/fail-parsing-4-out.R | 5 + .../fun_dec/fun_dec_scope_spaces-out.R | 30 ++- .../testthat/fun_dec/line_break_fun_dec-out.R | 46 +++-- .../indention_curly_brackets/custom-out.R | 7 +- .../multi_line_curly_round_only-out.R | 6 +- .../multi_line_curly_round_spacing-out.R | 6 +- .../multi_line_curly_while_for_if_fun-out.R | 1 - .../non_strict_calls-out.R | 28 +-- .../indention_multiple/curly_and_round-out.R | 43 ++-- .../edge_strict_mixed-out.R | 26 +-- .../edge_strict_random-out.R | 16 +- .../indention_multiple/fun_for_new_line-out.R | 7 +- .../indention_multiple/if_else_curly-out.R | 15 +- .../testthat/indention_multiple/overall-out.R | 30 ++- .../round_closing_on_same_line-out.R | 3 +- .../indention_multiple/round_only-out.R | 8 +- .../base_pipe_and_assignment-out.R | 4 +- ...base_pipe_and_assignment_and_comment-out.R | 17 +- .../base_pipe_and_assignment_and_math-out.R | 2 +- .../base_pipe_simple-out.R | 6 +- .../indention_operators/dollar_R6-out.R | 4 +- .../indention_operators/eq_assign-out.R | 7 +- .../eq_formal_simple-out.R | 6 +- .../eq_formals_complex_indention-out.R | 75 +++---- .../eq_formals_complex_tokens-out.R | 45 ++--- .../eq_sub_complex_indention-out.R | 23 +-- .../eq_sub_complex_tokens-out.R | 19 +- ...ction-multiline-no-braces-non-strict-out.R | 44 ++-- .../function-multiline-no-braces-strict-out.R | 32 +-- .../if-else-no-braces-not-strict-out.R | 37 ++-- .../logical_special_eq_sub-out.R | 6 +- .../testthat/indention_operators/mixed-out.R | 2 +- .../indention_operators/multiply_divide-out.R | 3 +- .../nested-for-spacing-scope-indention-out.R | 6 +- .../nested-for-spacing-scope-spaces-out.R | 6 +- .../not_first_trigger-out.R | 28 ++- .../indention_operators/overall-out.R | 24 ++- .../pipe_and_assignment-out.R | 4 +- .../pipe_and_assignment_and_comment-out.R | 17 +- .../pipe_and_assignment_and_math-out.R | 2 +- .../indention_operators/pipe_simple-out.R | 6 +- .../testthat/indention_operators/tilde-out.R | 6 +- ...hile_for_if_without_curly_non_strict-out.R | 56 +++--- .../while_for_if_without_curly_strict-out.R | 76 +++---- ...r_without_curly_same_line_non_strict-out.R | 50 +++-- .../arithmetic_no_start-out.R | 4 +- .../arithmetic_start-out.R | 11 +- .../multi_line-no-indention-out.R | 3 +- .../multi_line-random-out.R | 6 +- .../square_brackets_double_line_break-out.R | 16 +- .../square_brackets_line_break-out.R | 60 +++--- .../if_else_if_else_non_strict-out.R | 50 +++-- .../if_else_if_else_strict-out.R | 99 ++++----- .../if_else_non_strict-out.R | 27 ++- .../if_else_strict-out.R | 53 ++--- .../just_if_non_strict-out.R | 24 ++- .../just_if_strict-out.R | 25 +-- .../line_breaks_and_other/around-eq-sub-out.R | 34 ++-- .../line_breaks_and_other/assignment-out.R | 23 +-- .../base-pipe-line-breaks-out.R | 74 +++---- .../braces-fun-calls1-out.R | 1 - .../braces-fun-calls2-out.R | 54 +++-- .../line_breaks_and_other/comma-out.R | 16 +- .../comment-around-curly-out.R | 3 +- .../curly-brace-edge-out.R | 38 ++-- .../line_breaks_and_other/curly-out.R | 26 ++- .../edge_comment_and_curly-out.R | 4 +- .../line_breaks_and_other/ggplot2-out.R | 13 +- .../line_breaks_and_other/non_strict-out.R | 6 - .../pipe-line-breaks-out.R | 91 ++++----- .../line_breaks_fun_call/blank-strict-out.R | 3 +- .../line_breaks_and_comments-out.R | 10 +- .../named_arguments-out.R | 23 +-- .../switch_ifelse_etc_no_line_break-out.R | 58 ++---- .../token_dependent_comments-out.R | 20 +- .../token_dependent_complex_non_strict-out.R | 81 +++++--- .../token_dependent_complex_strict-out.R | 72 ++++--- .../token_dependent_mixed-out.R | 72 ++----- .../line_breaks_fun_call/unindent-out.R | 20 +- .../line_breaks_top_level_exprs/braces-out.R | 2 - .../conditionals-out.R | 9 +- .../function_defs_and_calls-out.R | 3 - .../non_strict-out.R | 14 -- .../piped_chains-out.R | 3 - .../non_strict_math_spacing_all-out.R | 2 +- ...rict_math_spacing_zero_all_but_power-out.R | 2 +- .../strict_math_spacing_zero_plus-out.R | 2 +- .../three_complex_expr-out.R | 4 +- .../parse_comments/just_comments-out.R | 1 - tests/testthat/parse_comments/mixed-out.R | 8 +- .../parse_comments/output-prefix-out.R | 1 - tests/testthat/parse_comments/shebang_1-out.R | 12 +- tests/testthat/parse_comments/shebang_2-out.R | 8 +- .../parse_comments/spacing_before-out.R | 3 +- .../spinning_code_chunk_headers-out.R | 7 +- .../parse_comments/with_indention-out.R | 13 +- .../within_spacing_with_force-out.R | 6 +- .../within_spacing_without_force-out.R | 4 +- tests/testthat/parse_comments/xaringan-out.R | 1 - tests/testthat/parsing/long_strings-out.R | 2 +- .../public-api/xyzaddin/addin_region-out.R | 4 +- .../eq_assign_ifelse_scope_line_breaks-out.R | 4 +- .../eq_assign_ifelse_scope_tokens-out.R | 8 +- .../eq_assign_multiple_tokens_eq_only-out.R | 14 +- .../eq_assign_multiple_tokens_mixed-out.R | 2 +- ...one-function-example-last-proper-run-out.R | 2 +- ...ne-function-examples-last-proper-run-out.R | 6 +- ...function-example-not-last-proper-run-out.R | 2 +- ...unction-examples-not-last-proper-run-out.R | 2 +- ...le-function-examples-last-proper-run-out.R | 6 +- ...ltiple-function-examples-no-last-run-out.R | 12 +- .../07-roxygen-no-dontrun-out.R | 21 +- .../08-roxygen-dontrun-out.R | 27 +-- ...09-styler-r-ui-style-string-multiple-out.R | 4 +- .../10-styler-r-ui-out.R | 127 +++++++----- .../11-start-with-dontrun-out.R | 28 ++- .../12-dontshow-dontrun-donttest-out.R | 45 +++-- .../12-fun-decs-in-examples-out.R | 13 +- .../13-empty-lines-out.R | 15 +- .../14-pipe-dontrun-out.R | 4 +- .../15-roxygen-dontrun-indention-out.R | 19 +- .../17-two-no-non-comment-out.R | 4 +- .../18-no-non-comment-out.R | 2 +- .../19-escaped-slash-out.R | 29 ++- .../20-exampleIf-simple-out.R | 4 +- .../21-exampleIf-multiple-out.R | 6 +- .../22-exampleIf-example-mixed-out.R | 12 +- .../23-exampleIf-multiline-cond-out.R | 8 +- .../24-exampleIf-spacing-out.R | 21 +- .../25-ordinary-comment-in-example-out.R | 13 +- .../26-empty-trailing-lines-out.R | 8 + .../27-no-code-block-after-example-out.R | 3 +- .../28-end-not-blank-out.R | 2 +- .../29-multiple-empty-lines-in-example-out.R | 1 - .../30-multiple-empty-lines-between-out.R | 2 - .../20-exampleIf-simple-out.R | 9 + .../21-exampleIf-multiple-out.R | 11 + .../testthat/scope-AsIs/scope_indention-out.R | 15 +- .../scope-AsIs/scope_indention_tokens-out.R | 18 +- .../scope-AsIs/scope_line_breaks-out.R | 15 +- tests/testthat/scope-AsIs/scope_none-out.R | 43 ++-- tests/testthat/scope-AsIs/scope_spaces-out.R | 6 +- .../scope-AsIs/scope_spaces_indention-out.R | 15 +- .../scope-AsIs/scope_spaces_line_breaks-out.R | 13 +- .../scope-AsIs/scope_spaces_tokens-out.R | 20 +- tests/testthat/scope-AsIs/scope_tokens-out.R | 20 +- .../scope-character/scope_indention-out.R | 15 +- .../scope-character/scope_line_breaks-out.R | 5 +- .../testthat/scope-character/scope_none-out.R | 43 ++-- .../scope-character/scope_spaces-out.R | 6 +- .../scope-character/scope_tokens-out.R | 7 +- .../serialize_tests/k2-another-in_file-out.R | 4 +- tests/testthat/serialize_tests/k2-out.R | 4 +- tests/testthat/serialize_tests/k3-out.R | 5 +- .../testthat/spacing/bang_bang_spacing-out.R | 4 +- tests/testthat/spacing/comments-out.R | 6 +- tests/testthat/spacing/round_curly-out.R | 6 +- tests/testthat/spacing/spacing-square-out.R | 2 - tests/testthat/spacing/spacing-tilde-out.R | 4 +- tests/testthat/spacing/spacing_comma2-out.R | 2 +- tests/testthat/start_line/comment-out.R | 2 +- tests/testthat/start_line/no_comment-out.R | 2 +- tests/testthat/strict/non_strict-out.R | 98 +++++---- tests/testthat/strict/strict-out.R | 53 +++-- .../stylerignore/adding-removing-out.R | 31 ++- tests/testthat/stylerignore/alignment-out.R | 10 +- tests/testthat/stylerignore/braces-out.R | 26 ++- .../crossing-with-expressions-out.R | 12 +- tests/testthat/stylerignore/simple-out.R | 15 +- tests/testthat/tidyeval/bang_bang-out.R | 8 +- .../add_brackets_in_pipe-out.R | 2 +- .../add_brackets_in_pipe-stylerignore-out.R | 13 +- .../token_adding_removing/double_braces-out.R | 8 +- .../for_while_stylerignore-out.R | 46 ++--- .../token_adding_removing/if-else-comma-out.R | 21 +- .../if_else_non_strict-out.R | 31 +-- .../if_else_strict-out.R | 43 +--- .../if_else_stylerignore-out.R | 56 +++--- .../token_adding_removing/mixed_token-out.R | 12 +- .../token_adding_removing/substitute-out.R | 7 +- .../unary_spacing/unary_indention-out.R | 1 - tests/testthat/unindention/mixed-double-out.R | 74 +++---- tests/testthat/unindention/mixed-out.R | 4 +- .../unindention/unindent_multi_line-out.R | 6 +- .../random_non_comment_indention-out.R | 2 +- .../regex_force_with_pattern-out.R | 8 +- 200 files changed, 2063 insertions(+), 1947 deletions(-) create mode 100644 inst/air/overwrite-in-test-files-with-out-files.R create mode 100644 tests/testthat/cache-with-r-cache/mlflow-1-out.R create mode 100644 tests/testthat/escaping/fail-parsing-1-out.R create mode 100644 tests/testthat/escaping/fail-parsing-2-out.R create mode 100644 tests/testthat/escaping/fail-parsing-3-out.R create mode 100644 tests/testthat/escaping/fail-parsing-4-out.R create mode 100644 tests/testthat/roxygen-examples-identify/20-exampleIf-simple-out.R create mode 100644 tests/testthat/roxygen-examples-identify/21-exampleIf-multiple-out.R diff --git a/inst/air/overwrite-in-test-files-with-out-files.R b/inst/air/overwrite-in-test-files-with-out-files.R new file mode 100644 index 000000000..8601a0018 --- /dev/null +++ b/inst/air/overwrite-in-test-files-with-out-files.R @@ -0,0 +1,31 @@ +# List all input files recursively that end with "-in.R" +input_files <- list.files( + path = "tests/testthat", + pattern = "-in\\.R$", + recursive = TRUE, + full.names = TRUE +) + +# Function to generate output filename by replacing -in.R with -out.R +get_output_filename <- function(input_file) { + gsub("-in\\.R$", "-out.R", input_file) +} + +# Process each file +for (input_file in input_files) { + output_file <- get_output_filename(input_file) + + # Create directory for output file if it doesn't exist + output_dir <- dirname(output_file) + if (!dir.exists(output_dir)) { + dir.create(output_dir, recursive = TRUE) + } + + # Read input file and write to output file + file.copy(input_file, output_file, overwrite = TRUE) + + # Print status + cat(sprintf("Processed: %s -> %s\n", input_file, output_file)) +} + +cat(sprintf("\nProcessed %d files\n", length(input_files))) diff --git a/tests/testthat/alignment/cols-with-one-row-out.R b/tests/testthat/alignment/cols-with-one-row-out.R index 30893a93e..d602271d4 100644 --- a/tests/testthat/alignment/cols-with-one-row-out.R +++ b/tests/testthat/alignment/cols-with-one-row-out.R @@ -1,16 +1,27 @@ c( - "x", "z", - "cgjhg", "thi", "z" + "x", + "z", + "cgjhg", + "thi", + "z" ) - c( - "x", "z", - "cgjhg", "thi", "z" + "x", + "z", + "cgjhg", + "thi", + "z" ) - c( - "x", "y", "z", "m", "n", "o", "p", - "c", "d" + "x", + "y", + "z", + "m", + "n", + "o", + "p", + "c", + "d" ) diff --git a/tests/testthat/alignment/fun-decs-out.R b/tests/testthat/alignment/fun-decs-out.R index fcefee559..8dd0ad913 100644 --- a/tests/testthat/alignment/fun-decs-out.R +++ b/tests/testthat/alignment/fun-decs-out.R @@ -1,38 +1,27 @@ # aligned -function(x = NULL, - tt = NULL, - ayz = NULL) {} - +function(x = NULL, tt = NULL, ayz = NULL) { +} # aligned -k <- function(x = NULL, - aq = NULL, - ayz = NULL) {} - +k <- function(x = NULL, aq = NULL, ayz = NULL) { +} # aligned, eq right -function(x = 2, - tt = 1, - ayz = 99) {} +function(x = 2, tt = 1, ayz = 99) { +} # aligned, eq left -function(x = 2, - tt = 1, - ayz = 99) {} - +function(x = 2, tt = 1, ayz = 99) { +} # not aligned -k <- function(x = fish, - aq = 21, - ayz = t(322)) {} +k <- function(x = fish, aq = 21, ayz = t(322)) { +} # aligned -k <- function(x = flus(we), - aq = x - 22, k = 22, - ayz = m(jk5), xfea = 3) {} - +k <- function(x = flus(we), aq = x - 22, k = 22, ayz = m(jk5), xfea = 3) { +} # aligned -k <- function(x = flus(we), - aq = x - 22, k = 22, - ayz = m(jk5), xfea = 3) {} +k <- function(x = flus(we), aq = x - 22, k = 22, ayz = m(jk5), xfea = 3) { +} diff --git a/tests/testthat/alignment/named-out.R b/tests/testthat/alignment/named-out.R index 35c3bb607..07bc66df9 100644 --- a/tests/testthat/alignment/named-out.R +++ b/tests/testthat/alignment/named-out.R @@ -1,107 +1,141 @@ # algorithm: aligned. human: aligned. call( - x = 1, kdd = 2, - xy = 2, n = 33, + x = 1, + kdd = 2, + xy = 2, + n = 33, ) # without trailing comma call( - x = 1, kdd = 2, - xy = 2, n = 33 + x = 1, + kdd = 2, + xy = 2, + n = 33 ) # algorithm: aligned. human: aligned. call( - x = 1, kdd = 2, - xy = 2, n = 33, + x = 1, + kdd = 2, + xy = 2, + n = 33, ) # algorithm: aligned. human: aligned. call( - x = 1, kdd = 2, - xy = 2, n = 33, + x = 1, + kdd = 2, + xy = 2, + n = 33, ) # algorithm: not aligned (spacing around =). human: aligned (fix: spacing around =). call( - x = 1, kdd = 2, - xy = 2, n = 33, + x = 1, + kdd = 2, + xy = 2, + n = 33, ) # algorithm: not aligned. human: not aligned. call( - x = 1, kdd = 2, - xy = 2, n = 33, + x = 1, + kdd = 2, + xy = 2, + n = 33, ) # algorithm: not aligned. human: not aligned. call( - x = 1, kdd = 2, - xy = 22, n = 33, + x = 1, + kdd = 2, + xy = 22, + n = 33, ) # algorithm: not aligned. human: not aligned. call( - x = 1, d = 2, - xy = 22, n = 33, + x = 1, + d = 2, + xy = 22, + n = 33, ) - # algorithm: aligned. human: aligned. call( - x = 1, kdd = 2, k = "abc", - xy = 2, n = 33, z = "333" + x = 1, + kdd = 2, + k = "abc", + xy = 2, + n = 33, + z = "333" ) - # algorithm: aligned. human: aligned. call( - x = 1, - xy = 2, n = 33, z = "333" + x = 1, + xy = 2, + n = 33, + z = "333" ) # algorithm: aligned. human: aligned. call( - x = 1, n = 33, z = "333", + x = 1, + n = 33, + z = "333", + xy = 2, ) # aligned. when spaces are spread accross different nests call( - k = ff("pk"), k = 3, - b = f(-g), 22 + 1, - 44, 323 + k = ff("pk"), + k = 3, + b = f(-g), + 22 + 1, + 44, + 323 ) # aligned. when spaces are spread accross different nests call( - k = ff("pk"), k = 3, - b = f(-g), 22 + 1, - 44, 323, + k = ff("pk"), + k = 3, + b = f(-g), + 22 + 1, + 44, + 323, ) # no trailing call( - k = ff("pk"), k = 3, - b = f(-g), 22 + 1, + k = ff("pk"), + k = 3, + b = f(-g), + 22 + 1, 44 ) # aligned: fewest arguments not on last line call( 44, - k = ff("pk"), k = 3, - b = f(-g), 22 + 1, + k = ff("pk"), + k = 3, + b = f(-g), + 22 + 1, ) # aligned: fewest arguments not on last line call( - k = ff("pk"), k = 3, + k = ff("pk"), + k = 3, 44, - b = f(-g), 22 + 1, + b = f(-g), + 22 + 1, ) - # if all col1 arguments are named, col1 must also be aligned # not aligned fell( @@ -112,55 +146,60 @@ fell( # aligned fell( - x = 1, - y = 23, + x = 1, + y = 23, zz = NULL ) # aligned but comma in the wrong line call( - a = 2, - bb = 3, + a = 2, + bb = 3, ) - # aligned (comments) call( - a = 2, x = 111, + a = 2, + x = 111, # another - bb = 3, # hi + bb = 3, # hi ) # aligned (comments) call( - a = 2, x = 111, - bb = 3, # hi + a = 2, + x = 111, + bb = 3, # hi ) # aligned (comments) call( # another one - a = 2, x = 111, - bb = 3, # hi + a = 2, + x = 111, + bb = 3, # hi ) # aligned (comments) call( # another one - a = 2, x = 111, - bb = 3 # hi + a = 2, + x = 111, + bb = 3 # hi ) # not aligned (comments) call( - a = 2, x = 111, + a = 2, + x = 111, bb = 3, # hi ) # not aligned (comments) call( # another one - a = 2, x = 111, + a = 2, + x = 111, bb = 3, # hi ) @@ -170,16 +209,15 @@ call( # in the second step, because all arguments are named and there is no alignment, # the extra spaces before `=` as of 29a010064257fa1a9caf32d182e7ee62008de98a. call( - x = 95232, - y = f(), + x = 95232, + y = f(), ) - # aligned (left after `=`) ca( - x = 23200, + x = 23200, y2 = "hi", - m = c(rm.na = 7) + m = c(rm.na = 7) ) # not aligned (left after `=`) @@ -191,30 +229,45 @@ ca( # aligned =, first all named fell( - x = 8, annoying = 3, - y = 23, # nothing in column 2 for row 2 - zz = NULL, finally = "stuff" + x = 8, + annoying = 3, + y = 23, # nothing in column 2 for row 2 + zz = NULL, + finally = "stuff" ) # aligned =, first not all named gell( - p = 2, g = gg(x), n = 3 * 3, # - 31, fds = -1, gz = f / 3 + 1, + p = 2, + g = gg(x), + n = 3 * 3, # + 31, + fds = -1, + gz = f / 3 + 1, ) xgle( - 1212, 232, f(n = 2), - 1, 2, "kFlya" + 1212, + 232, + f(n = 2), + 1, + 2, + "kFlya" ) # left aligned after , call( - x = 2, y = "another", - y = "hhjkjkbew", x = 3 + x = 2, + y = "another", + y = "hhjkjkbew", + x = 3 ) call( - k = ff("pk"), k = 3, - b = f(-g), 22 + 1, - 44, 323 + k = ff("pk"), + k = 3, + b = f(-g), + 22 + 1, + 44, + 323 ) diff --git a/tests/testthat/alignment/one-col-some-named-out.R b/tests/testthat/alignment/one-col-some-named-out.R index d19808116..871a3acda 100644 --- a/tests/testthat/alignment/one-col-some-named-out.R +++ b/tests/testthat/alignment/one-col-some-named-out.R @@ -5,7 +5,6 @@ foo( font = "xyz" ) - foo( img, # pkg = "abc", diff --git a/tests/testthat/alignment/quoted-names-out.R b/tests/testthat/alignment/quoted-names-out.R index 1b5c481df..78b9ba128 100644 --- a/tests/testthat/alignment/quoted-names-out.R +++ b/tests/testthat/alignment/quoted-names-out.R @@ -1,4 +1,5 @@ -df <- dplyr::rename(df, +df <- dplyr::rename( + df, "xValues" = "Time", "xUnit" = "TimeUnit", "yValues" = "simulationValues", diff --git a/tests/testthat/alignment/tribble-out.R b/tests/testthat/alignment/tribble-out.R index 2e618487e..1768b2901 100644 --- a/tests/testthat/alignment/tribble-out.R +++ b/tests/testthat/alignment/tribble-out.R @@ -1,30 +1,43 @@ tribble( - ~x, ~d, - "axa'fa", 1:6, - "b", 4:6 + ~x, + ~d, + "axa'fa", + 1:6, + "b", + 4:6 ) tribble( - ~x, ~d, - "axa'fa", 1:6, - "b", 4:6 + ~x, + ~d, + "axa'fa", + 1:6, + "b", + 4:6 ) - tribble( - ~x, ~d, - "axa'fa", 1:6, - "b", 4:6 + ~x, + ~d, + "axa'fa", + 1:6, + "b", + 4:6 ) tribble( - ~x, ~d, - "axa'fa", 1:6, - "b", 4:6 + ~x, + ~d, + "axa'fa", + 1:6, + "b", + 4:6 ) # has EQ_SUB which don't match, not tribble-like mlr3misc:::rowwise_table( - x = 23, zy = 3, - y = 1, k = 1, + x = 23, + zy = 3, + y = 1, + k = 1, ) diff --git a/tests/testthat/alignment/tribble-three-cols-out.R b/tests/testthat/alignment/tribble-three-cols-out.R index 958b370dc..4e52bd042 100644 --- a/tests/testthat/alignment/tribble-three-cols-out.R +++ b/tests/testthat/alignment/tribble-three-cols-out.R @@ -1,5 +1,11 @@ tribble( - ~x, ~y, ~z, - "one", TRUE, 1L, - "two", FALSE, 2L + ~x, + ~y, + ~z, + "one", + TRUE, + 1L, + "two", + FALSE, + 2L ) diff --git a/tests/testthat/cache-with-r-cache/mlflow-1-out.R b/tests/testthat/cache-with-r-cache/mlflow-1-out.R new file mode 100644 index 000000000..2f4b1e976 --- /dev/null +++ b/tests/testthat/cache-with-r-cache/mlflow-1-out.R @@ -0,0 +1,99 @@ +# Returns the current MLflow R package version +mlflow_version <- function() { + utils::packageVersion("mlflow") +} + +# Returns the name of a conda environment in which to install the Python MLflow package +mlflow_conda_env_name <- function() { + paste("r-mlflow", mlflow_version(), sep = "-") +} + +# Create conda env used by MLflow if it doesn't already exist +#' @importFrom reticulate conda_install conda_create conda_list +#' @param python_version Python version to use within conda environment created for +#' installing the MLflow CLI. +mlflow_maybe_create_conda_env <- function(python_version) { + packages <- c(paste("python", python_version, sep = "=")) + conda <- mlflow_conda_bin() + conda_env_name <- mlflow_conda_env_name() + if (!conda_env_name %in% conda_list(conda = conda)$name) { + conda_create(conda_env_name, conda = conda, packages = packages) + } +} + +#' Install MLflow +#' +#' Installs auxiliary dependencies of MLflow (e.g. the MLflow CLI). As a +#' one-time setup step, you must run install_mlflow() to install these +#' dependencies before calling other MLflow APIs. +#' +#' install_mlflow() requires Python and Conda to be installed. +#' See \url{https://www.python.org/getit/} and \url{https://docs.conda.io/projects/conda/en/latest/user-guide/install/}. +#' +#' Alternatively, you can set MLFLOW_PYTHON_BIN and MLFLOW_BIN environment variables +#' instead. MLFLOW_PYTHON_BIN should point to python executable and MLFLOW_BIN to mlflow cli +#' executable. These variables allow you to use custom mlflow installation. Note that there may be +#' some compatibility issues if the custom mlflow version does not match the version of the R +#' package. +#' +#' @examples +#' \dontrun{ +#' library(mlflow) +#' install_mlflow() +#' } +#' +#' @importFrom reticulate conda_install conda_create conda_list +#' @param python_version Optional Python version to use within conda environment created for +#' installing the MLflow CLI. If unspecified, defaults to using Python 3.6 +#' @export +install_mlflow <- function(python_version = "3.6") { + mlflow_maybe_create_conda_env(python_version) + # Install the Python MLflow package with version == the current R package version + packages <- c(paste("mlflow", "==", mlflow_version(), sep = "")) + conda <- mlflow_conda_bin() + conda_install( + packages, + envname = mlflow_conda_env_name(), + pip = TRUE, + conda = conda + ) +} + +#' Uninstall MLflow +#' +#' Uninstalls MLflow by removing the Conda environment. +#' +#' @examples +#' \dontrun{ +#' library(mlflow) +#' install_mlflow() +#' uninstall_mlflow() +#' } +#' +#' @importFrom reticulate conda_install conda_create conda_list +#' @export +uninstall_mlflow <- function() { + reticulate::conda_remove( + envname = mlflow_conda_env_name(), + conda = mlflow_conda_bin() + ) +} + +mlflow_conda_bin <- function() { + conda_home <- Sys.getenv("MLFLOW_CONDA_HOME", NA) + conda <- if (!is.na(conda_home)) + paste(conda_home, "bin", "conda", sep = "/") else "auto" + conda_try <- try(conda_binary(conda = conda), silent = TRUE) + if (class(conda_try) == "try-error") { + msg <- paste( + attributes(conda_try)$condition$message, + paste( + " If you are not using conda, you can set the environment variable", + "MLFLOW_PYTHON_BIN to the path of your python executable." + ), + sep = "\n" + ) + stop(msg) + } + conda_try +} diff --git a/tests/testthat/curly-curly/mixed-out.R b/tests/testthat/curly-curly/mixed-out.R index a18134391..89e6fbc77 100644 --- a/tests/testthat/curly-curly/mixed-out.R +++ b/tests/testthat/curly-curly/mixed-out.R @@ -36,7 +36,6 @@ call({{ x }}) # not removing spaces within {{ call({{ x }}) - # combine spaces and line breaks call({{ x }}) @@ -52,22 +51,19 @@ call({{ x }}) { { 1 + a - } + 1 + } + + 1 } # not curly-culry! - ## ............................................................................ ## multiple #### call("test", { 1 }) -call( - "test", - { - 1 - } -) +call("test", { + 1 +}) call("test", { 1 @@ -90,24 +86,31 @@ call( call({{ x }}, {{ y }}) call({{ x }}, {{ y }}) call( - {{ x }}, {{ y }} + {{ x }}, + {{ y }} ) call( {{ x }}, - {{ y }} := 3, f(bk) + {{ y }} := 3, + f(bk) ) -call({{ - # - 1 -}}) - -call({{ - # -}}) +call({ + { + # + 1 + } +}) +call({ + { + # + } +}) -{{ - # -}} +{ + { + # + } +} diff --git a/tests/testthat/escaping/basic-escape-out.R b/tests/testthat/escaping/basic-escape-out.R index c35989e3f..66d1e2df1 100644 --- a/tests/testthat/escaping/basic-escape-out.R +++ b/tests/testthat/escaping/basic-escape-out.R @@ -4,7 +4,6 @@ #' call("\\.") NULL - #' things #' #' @examples @@ -18,24 +17,23 @@ NULL #' ano("\\.", further = X) NULL - #' things #' #' @examples -#' call("\n") +#' call('\n') #' ano("\\.", further = X) NULL -"single quotes with -embedded and \n not embedded line breaks" +'single quotes with +embedded and \n not embedded line breaks' -x <- " 2" # there is a tab emebbed (created with writeLines("x <- '\t2'")) +x <- ' 2' # there is a tab emebbed (created with writeLines("x <- '\t2'")) -x <- "\001" -"\x01" +x <- '\001' +'\x01' "\001" -"\001" +'\001' #' things #' diff --git a/tests/testthat/escaping/fail-parsing-1-out.R b/tests/testthat/escaping/fail-parsing-1-out.R new file mode 100644 index 000000000..7acb65002 --- /dev/null +++ b/tests/testthat/escaping/fail-parsing-1-out.R @@ -0,0 +1,7 @@ +#' Example +#' +#' @examples +#' fun() { +#' +#' } +NULL diff --git a/tests/testthat/escaping/fail-parsing-2-out.R b/tests/testthat/escaping/fail-parsing-2-out.R new file mode 100644 index 000000000..c89ec52aa --- /dev/null +++ b/tests/testthat/escaping/fail-parsing-2-out.R @@ -0,0 +1,5 @@ +#' Example +#' +#' @examples +#' x <- +NULL diff --git a/tests/testthat/escaping/fail-parsing-3-out.R b/tests/testthat/escaping/fail-parsing-3-out.R new file mode 100644 index 000000000..aeb26e197 --- /dev/null +++ b/tests/testthat/escaping/fail-parsing-3-out.R @@ -0,0 +1,5 @@ +#' Example +#' +#' @examples +#' 1 _ +NULL diff --git a/tests/testthat/escaping/fail-parsing-4-out.R b/tests/testthat/escaping/fail-parsing-4-out.R new file mode 100644 index 000000000..212bc7988 --- /dev/null +++ b/tests/testthat/escaping/fail-parsing-4-out.R @@ -0,0 +1,5 @@ +#' Example +#' +#' @examples +#' 1 + } +NULL diff --git a/tests/testthat/fun_dec/fun_dec_scope_spaces-out.R b/tests/testthat/fun_dec/fun_dec_scope_spaces-out.R index 4b7ad4dc7..ae1a6a4f0 100644 --- a/tests/testthat/fun_dec/fun_dec_scope_spaces-out.R +++ b/tests/testthat/fun_dec/fun_dec_scope_spaces-out.R @@ -1,27 +1,23 @@ -a <- function(x, # -y +a <- function( + x, # + y ) { x - 1 } - -a <- function(x, # - y) # -{ +a <- function( + x, # + y +) { + # x } -function(a = - b, - c) {} - -function(a = - b, - c) { +function(a = b, c) { +} +function(a = b, c) { } -function(a = - b, - c -) {} +function(a = b, c) { +} 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 f910b6b43..baad30d64 100644 --- a/tests/testthat/fun_dec/line_break_fun_dec-out.R +++ b/tests/testthat/fun_dec/line_break_fun_dec-out.R @@ -1,41 +1,49 @@ -a <- function(x, # - y) { +a <- function( + x, # + y +) { x - 1 } - -a <- function(x, # - y) # -{ +a <- function( + x, # + y +) { + # x } -a <- function(x, # - y # +a <- function( + x, # + y # ) { y } - -a <- function(x, - y) { +a <- function(x, y) { x - 1 } -a <- function(x, - # - y) { +a <- function( + x, + # + y +) { x - 1 } -a <- function(x, - y) { +a <- function( + x, + + y +) { x - 1 } - -a <- function(x, - y) { +a <- function( + x, + y +) { x - 1 } diff --git a/tests/testthat/indention_curly_brackets/custom-out.R b/tests/testthat/indention_curly_brackets/custom-out.R index f68775003..da24a7a65 100644 --- a/tests/testthat/indention_curly_brackets/custom-out.R +++ b/tests/testthat/indention_curly_brackets/custom-out.R @@ -1,9 +1,6 @@ value <- 5 -if (value > 0) { - print(value) -} - +if (value > 0) print(value) if (value > 0) { - print(value) + print(value) } diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_round_only-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_round_only-out.R index 745c5b262..db3ede4ef 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_round_only-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_round_only-out.R @@ -1,9 +1,5 @@ a <- function(x) { - x <- c( - 1, - 2 + 3, - sin(pi) - ) + x <- c(1, 2 + 3, sin(pi)) if (x > 10) { return("done") diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_round_spacing-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_round_spacing-out.R index 851b79121..3fa6d9506 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_round_spacing-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_round_spacing-out.R @@ -1,9 +1,5 @@ b <- function(x) { - x <- c( - 1, - 2 + 3, - sin(pi) - ) + x <- c(1, 2 + 3, sin(pi)) if (x > 10) { return("done") diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R index f80ed3c8b..15e1b2d20 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R @@ -9,7 +9,6 @@ a <- function(x, y, z) { } } - if ( require("logspline") && require("rstanarm") diff --git a/tests/testthat/indention_fun_calls/non_strict_calls-out.R b/tests/testthat/indention_fun_calls/non_strict_calls-out.R index 3db1f68f7..d7afbee3e 100644 --- a/tests/testthat/indention_fun_calls/non_strict_calls-out.R +++ b/tests/testthat/indention_fun_calls/non_strict_calls-out.R @@ -1,18 +1,12 @@ -call(a, - b) +call(a, b) -call(a, - b = 3) +call(a, b = 3) -call(a = 1, b = - 3) +call(a = 1, b = 3) -call(a = - 1, b = 3) +call(a = 1, b = 3) -call(a = 1, - b = 3 -) +call(a = 1, b = 3) call( a = 1, @@ -20,18 +14,16 @@ call( ) call( - a = - 1, + a = 1, b = 3 ) call( - a = - 1, b = 3 + a = 1, + b = 3 ) call( - a = - 1, b = - 3 + a = 1, + b = 3 ) diff --git a/tests/testthat/indention_multiple/curly_and_round-out.R b/tests/testthat/indention_multiple/curly_and_round-out.R index f8a4acad2..70b9dd814 100644 --- a/tests/testthat/indention_multiple/curly_and_round-out.R +++ b/tests/testthat/indention_multiple/curly_and_round-out.R @@ -2,21 +2,30 @@ test_that("this is a text", { test(x, y, call(z)) }) -(({ - { - call( - 12, 1 + 1, - 26 - ) - } -})) +( + ( + { + { + call( + 12, + 1 + 1, + 26 + ) + } + } + ) +) - -(({ - { - call( - 12, 1 + 1, - 26 - ) - } -})) +( + ( + { + { + call( + 12, + 1 + 1, + 26 + ) + } + } + ) +) diff --git a/tests/testthat/indention_multiple/edge_strict_mixed-out.R b/tests/testthat/indention_multiple/edge_strict_mixed-out.R index 0d95d3468..a65bafac4 100644 --- a/tests/testthat/indention_multiple/edge_strict_mixed-out.R +++ b/tests/testthat/indention_multiple/edge_strict_mixed-out.R @@ -1,26 +1,22 @@ { ( - (( - { + ( + ( { { - c( - 99, - 1 + 1, - { + { + c(99, 1 + 1, { "within that suff" - } - ) + }) + } } } - })) + ) + ) ) } +(((1 + 2) * (3 + 4))) -((( - 1 + 2) * (3 + 4 -))) - - -function(x, y, z) {} +function(x, y, z) { +} diff --git a/tests/testthat/indention_multiple/edge_strict_random-out.R b/tests/testthat/indention_multiple/edge_strict_random-out.R index b91841440..4df392ec6 100644 --- a/tests/testthat/indention_multiple/edge_strict_random-out.R +++ b/tests/testthat/indention_multiple/edge_strict_random-out.R @@ -1,6 +1,6 @@ { { - ({ + ( { { { @@ -8,9 +8,9 @@ { { { - (( - 19 - )) + { + ((19)) + } } } } @@ -18,15 +18,11 @@ } } } - }) + ) } } - -( - c("x", "y", "z", "sin(x)") -) - +(c("x", "y", "z", "sin(x)")) { c("x", "y", "z", "sin(x)") diff --git a/tests/testthat/indention_multiple/fun_for_new_line-out.R b/tests/testthat/indention_multiple/fun_for_new_line-out.R index f9c4e703e..d9c8e423b 100644 --- a/tests/testthat/indention_multiple/fun_for_new_line-out.R +++ b/tests/testthat/indention_multiple/fun_for_new_line-out.R @@ -1,8 +1,5 @@ -function() { - NULL -} +function() NULL -for (i in 1:3) -{ +for (i in 1:3) { 2 } diff --git a/tests/testthat/indention_multiple/if_else_curly-out.R b/tests/testthat/indention_multiple/if_else_curly-out.R index bcd416cb5..a8602e8bf 100644 --- a/tests/testthat/indention_multiple/if_else_curly-out.R +++ b/tests/testthat/indention_multiple/if_else_curly-out.R @@ -1,21 +1,15 @@ { - if (TRUE) - 3 - else - 4 + if (TRUE) 3 else 4 } { if (TRUE) { 3 - } else - 4 + } else 4 } { - if (TRUE) - 3 - else { + if (TRUE) 3 else { 4 } } @@ -37,10 +31,9 @@ foo <- function(x) { } } - if (TRUE) { 3 -} else if (FALSE) { +} else if (FALSE) { 4 } diff --git a/tests/testthat/indention_multiple/overall-out.R b/tests/testthat/indention_multiple/overall-out.R index 4db2b90fc..4945f6aec 100644 --- a/tests/testthat/indention_multiple/overall-out.R +++ b/tests/testthat/indention_multiple/overall-out.R @@ -4,11 +4,15 @@ #' indented comments a <- function(x) { test_that("I want to test", { - out <- c(1, c( - 22 + 1 - )) + out <- c( + 1, + c( + 22 + 1 + ) + ) if (x > 10) { - for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%? + for (x in 22) { + # FIXME in operator only to be surrounded by one space. What about %in%? prin(x) } } @@ -16,16 +20,20 @@ a <- function(x) { # we like comments too c( list(x + 2), - c(c( - 26^2, - 8, - 7 - )) + c( + c( + 26^2, + 8, + 7 + ) + ) ) call( - 1, 2, - 23 + Inf - 99, call( + 1, + 2, + 23 + Inf - 99, + call( 16 ) ) diff --git a/tests/testthat/indention_multiple/round_closing_on_same_line-out.R b/tests/testthat/indention_multiple/round_closing_on_same_line-out.R index 52487327d..af183aac3 100644 --- a/tests/testthat/indention_multiple/round_closing_on_same_line-out.R +++ b/tests/testthat/indention_multiple/round_closing_on_same_line-out.R @@ -1,4 +1,5 @@ c( - call(2), 1, # comment + call(2), + 1, # comment 29 ) diff --git a/tests/testthat/indention_multiple/round_only-out.R b/tests/testthat/indention_multiple/round_only-out.R index 047992beb..83284f698 100644 --- a/tests/testthat/indention_multiple/round_only-out.R +++ b/tests/testthat/indention_multiple/round_only-out.R @@ -1,7 +1,3 @@ -((((( - 1 -))))) +(((((1))))) -((( - 2 -))) +(((2))) diff --git a/tests/testthat/indention_operators/base_pipe_and_assignment-out.R b/tests/testthat/indention_operators/base_pipe_and_assignment-out.R index 98fd88893..98c3ec12c 100644 --- a/tests/testthat/indention_operators/base_pipe_and_assignment-out.R +++ b/tests/testthat/indention_operators/base_pipe_and_assignment-out.R @@ -1,7 +1,7 @@ a <- b() |> - q() |> - g() + q() |> + g() a <- b() |> c() |> diff --git a/tests/testthat/indention_operators/base_pipe_and_assignment_and_comment-out.R b/tests/testthat/indention_operators/base_pipe_and_assignment_and_comment-out.R index 4ebdd39b0..c6d261875 100644 --- a/tests/testthat/indention_operators/base_pipe_and_assignment_and_comment-out.R +++ b/tests/testthat/indention_operators/base_pipe_and_assignment_and_comment-out.R @@ -1,18 +1,17 @@ a <- # b() |> - c() |> - d() + c() |> + d() a <- # b() |> - c() |> - d() - + c() |> + d() a <- b() |> - c() |> - d() + c() |> + d() a <- c |> b() |> @@ -21,5 +20,5 @@ a <- c |> a <- b() |> # - c() |> - d() # d + c() |> + d() # d diff --git a/tests/testthat/indention_operators/base_pipe_and_assignment_and_math-out.R b/tests/testthat/indention_operators/base_pipe_and_assignment_and_math-out.R index c8ed58735..242236db1 100644 --- a/tests/testthat/indention_operators/base_pipe_and_assignment_and_math-out.R +++ b/tests/testthat/indention_operators/base_pipe_and_assignment_and_math-out.R @@ -2,4 +2,4 @@ q <- a + -3 + 2 + g() |> - k() + k() diff --git a/tests/testthat/indention_operators/base_pipe_simple-out.R b/tests/testthat/indention_operators/base_pipe_simple-out.R index 4257a7917..fc5242ec3 100644 --- a/tests/testthat/indention_operators/base_pipe_simple-out.R +++ b/tests/testthat/indention_operators/base_pipe_simple-out.R @@ -4,12 +4,14 @@ a |> d(1 + e(sin(f))) |> g_out() -a <- function(jon_the_pipe) {} +a <- function(jon_the_pipe) { +} x |> + # break call() - y |> + call() # mor diff --git a/tests/testthat/indention_operators/dollar_R6-out.R b/tests/testthat/indention_operators/dollar_R6-out.R index 8111d3582..b43b32c36 100644 --- a/tests/testthat/indention_operators/dollar_R6-out.R +++ b/tests/testthat/indention_operators/dollar_R6-out.R @@ -1,4 +1,2 @@ -x$add(10)$ - add(10)$add(10)$ - add(10)$sum + +x$add(10)$add(10)$add(10)$add(10)$sum + 3 diff --git a/tests/testthat/indention_operators/eq_assign-out.R b/tests/testthat/indention_operators/eq_assign-out.R index f3853d96f..2927fd5ce 100644 --- a/tests/testthat/indention_operators/eq_assign-out.R +++ b/tests/testthat/indention_operators/eq_assign-out.R @@ -1,12 +1,11 @@ -switch(engine, +switch( + engine, pdftex = { if (any) { x } }, - new = ( - 2 - ) + new = (2) ) { diff --git a/tests/testthat/indention_operators/eq_formal_simple-out.R b/tests/testthat/indention_operators/eq_formal_simple-out.R index 01554a116..eeab6e235 100644 --- a/tests/testthat/indention_operators/eq_formal_simple-out.R +++ b/tests/testthat/indention_operators/eq_formal_simple-out.R @@ -1,7 +1,5 @@ -abbbb <- function(x = - 22) { +abbbb <- function(x = 22) { data_frame( - x = - long_long_long * x + x = long_long_long * x ) } 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 a2e1d79b8..bb9fcf7c8 100644 --- a/tests/testthat/indention_operators/eq_formals_complex_indention-out.R +++ b/tests/testthat/indention_operators/eq_formals_complex_indention-out.R @@ -1,60 +1,33 @@ -function(a = - 33, - b -) {} +function(a = 33, b) { +} + +function(a = 33, b) { +} -function(a = - 33, - b) {} +function(a, b, c) { +} -function(a, - b, - c -) {} +function(a, b, c) { +} + +function(ss, a = 3, er = 4) { +} -function(a, - b, - c) {} +function(a = b, f = d, c = 3, d = 4) { +} -function(ss, - a = - 3, - er = - 4 -) {} +# classical +function(a = 33, b) { +} -function(a = - b, - f = - d, c = - 3, d = - 4) { +function(a = 33, b) { +} +function(a, b, c) { } +function(a, b, c) { +} -# classical -function(a = - 33, - b -) {} - -function(a = - 33, - b) {} - -function(a, - b, - c -) {} - -function(a, - b, - c) {} - -function(ss, - a = - 3, - er = - 4 -) {} +function(ss, a = 3, er = 4) { +} 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 9c001e666..5a943f2f4 100644 --- a/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R +++ b/tests/testthat/indention_operators/eq_formals_complex_tokens-out.R @@ -1,38 +1,17 @@ -function( - a = - 33, - b -) {} +function(a = 33, b) { +} -function( - a = - 33, - b -) {} +function(a = 33, b) { +} -function( - a, - b, - c -) {} +function(a, b, c) { +} -function( - a, - b, - c -) {} +function(a, b, c) { +} -function( - ss, - a = - 3, - er = - 4 -) {} +function(ss, a = 3, er = 4) { +} -function(a = - b, - f = - d, c = - 3, d = - 4) {} +function(a = b, f = d, c = 3, d = 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 03c121d81..c59806675 100644 --- a/tests/testthat/indention_operators/eq_sub_complex_indention-out.R +++ b/tests/testthat/indention_operators/eq_sub_complex_indention-out.R @@ -1,32 +1,21 @@ -call(a = - 5, -b) +call(a = 5, b) -call(a = - 5, -b -) +call(a = 5, b) # multiple nested levels { - v <- function(x = - 122, - y) { + v <- function(x = 122, y) { } } - { - v <- function(x = 122, - y) { + v <- function(x = 122, y) { } } MyClass <- R6::R6Class( "MyClass", - public = list(initialize = function(my_arg, - my_named_arg = 1) { + public = list(initialize = function(my_arg, my_named_arg = 1) { return(invisible()) - } - ), + }), ) diff --git a/tests/testthat/indention_operators/eq_sub_complex_tokens-out.R b/tests/testthat/indention_operators/eq_sub_complex_tokens-out.R index 717a8a610..3a0e22910 100644 --- a/tests/testthat/indention_operators/eq_sub_complex_tokens-out.R +++ b/tests/testthat/indention_operators/eq_sub_complex_tokens-out.R @@ -1,18 +1,9 @@ -call( - a = - 5, - b -) +call(a = 5, b) -call( - a = - 5, - b -) +call(a = 5, b) c( - a = - 1, - b = # comment here - 2 + a = 1, + # comment here + b = 2 ) diff --git a/tests/testthat/indention_operators/function-multiline-no-braces-non-strict-out.R b/tests/testthat/indention_operators/function-multiline-no-braces-non-strict-out.R index 79d9acb95..2cad4b9ff 100644 --- a/tests/testthat/indention_operators/function-multiline-no-braces-non-strict-out.R +++ b/tests/testthat/indention_operators/function-multiline-no-braces-non-strict-out.R @@ -1,26 +1,28 @@ -g <- function(k) - NULL - - -g <- function(k) h( - NULL -) +g <- function(k) NULL +g <- function(k) + h( + NULL + ) -g <- function(k) h( # y - NULL # x -) - -g <- function(k) h( # y - NULL -) +g <- function(k) + h( + # y + NULL # x + ) +g <- function(k) + h( + # y + NULL + ) -g <- function(k) h( - NULL # 3jkö -) +g <- function(k) + h( + NULL # 3jkö + ) -g <- function(k) h( - if (TRUE) - x -) +g <- function(k) + h( + if (TRUE) x + ) diff --git a/tests/testthat/indention_operators/function-multiline-no-braces-strict-out.R b/tests/testthat/indention_operators/function-multiline-no-braces-strict-out.R index d4ed77f59..2cad4b9ff 100644 --- a/tests/testthat/indention_operators/function-multiline-no-braces-strict-out.R +++ b/tests/testthat/indention_operators/function-multiline-no-braces-strict-out.R @@ -1,38 +1,28 @@ -g <- function(k) { - NULL -} +g <- function(k) NULL - -g <- function(k) { +g <- function(k) h( NULL ) -} - -g <- function(k) { - h( # y +g <- function(k) + h( + # y NULL # x ) -} -g <- function(k) { - h( # y +g <- function(k) + h( + # y NULL ) -} - -g <- function(k) { +g <- function(k) h( NULL # 3jkö ) -} -g <- function(k) { +g <- function(k) h( - if (TRUE) { - x - } + if (TRUE) x ) -} diff --git a/tests/testthat/indention_operators/if-else-no-braces-not-strict-out.R b/tests/testthat/indention_operators/if-else-no-braces-not-strict-out.R index acddf4348..c11b1cd37 100644 --- a/tests/testthat/indention_operators/if-else-no-braces-not-strict-out.R +++ b/tests/testthat/indention_operators/if-else-no-braces-not-strict-out.R @@ -1,17 +1,24 @@ -if (TRUE) c( - 2 -) else c( - 1 -) +if (TRUE) + c( + 2 + ) else + c( + 1 + ) -if (TRUE) c( - 2 -) else c( # nothing - 1 -) +if (TRUE) + c( + 2 + ) else + c( + # nothing + 1 + ) -if (TRUE) c( - 2 # also nothing -) else c( - 1 -) +if (TRUE) + c( + 2 # also nothing + ) else + c( + 1 + ) diff --git a/tests/testthat/indention_operators/logical_special_eq_sub-out.R b/tests/testthat/indention_operators/logical_special_eq_sub-out.R index 2971b154b..683d627e8 100644 --- a/tests/testthat/indention_operators/logical_special_eq_sub-out.R +++ b/tests/testthat/indention_operators/logical_special_eq_sub-out.R @@ -1,8 +1,7 @@ a || b -a > - 4 +a > 4 a & 3 @@ -11,8 +10,7 @@ b %in% c data_frame( - a = - list() + a = list() ) b = 3 diff --git a/tests/testthat/indention_operators/mixed-out.R b/tests/testthat/indention_operators/mixed-out.R index 38ea020a7..81c2efe30 100644 --- a/tests/testthat/indention_operators/mixed-out.R +++ b/tests/testthat/indention_operators/mixed-out.R @@ -4,7 +4,7 @@ 1 + 2 / - 3 + 3 1 / 2 + diff --git a/tests/testthat/indention_operators/multiply_divide-out.R b/tests/testthat/indention_operators/multiply_divide-out.R index c623d698b..a135d2b7b 100644 --- a/tests/testthat/indention_operators/multiply_divide-out.R +++ b/tests/testthat/indention_operators/multiply_divide-out.R @@ -1,5 +1,6 @@ 1 / - 2 + 3 * + 2 + + 3 * 17 * 22222 / 19 * diff --git a/tests/testthat/indention_operators/nested-for-spacing-scope-indention-out.R b/tests/testthat/indention_operators/nested-for-spacing-scope-indention-out.R index 585942ace..ad35a3067 100644 --- a/tests/testthat/indention_operators/nested-for-spacing-scope-indention-out.R +++ b/tests/testthat/indention_operators/nested-for-spacing-scope-indention-out.R @@ -1,11 +1,9 @@ for (x in 1) { x - for (x in k) - 3 + for (x in k) 3 } for (x in 1) { x - for (x in k) - 3 + for (x in k) 3 } diff --git a/tests/testthat/indention_operators/nested-for-spacing-scope-spaces-out.R b/tests/testthat/indention_operators/nested-for-spacing-scope-spaces-out.R index 4016945fe..ad35a3067 100644 --- a/tests/testthat/indention_operators/nested-for-spacing-scope-spaces-out.R +++ b/tests/testthat/indention_operators/nested-for-spacing-scope-spaces-out.R @@ -1,11 +1,9 @@ for (x in 1) { x - for (x in k) - 3 + for (x in k) 3 } for (x in 1) { x - for (x in k) - 3 + for (x in k) 3 } diff --git a/tests/testthat/indention_operators/not_first_trigger-out.R b/tests/testthat/indention_operators/not_first_trigger-out.R index c5569c8ce..416c5c56a 100644 --- a/tests/testthat/indention_operators/not_first_trigger-out.R +++ b/tests/testthat/indention_operators/not_first_trigger-out.R @@ -1,19 +1,15 @@ -1 + ( - 3 -) %>% - j() +1 + + (3) %>% + j() -a <- c( - x, y, - z -) %>% +a <- c(x, y, z) %>% k() -a + ( - c -) + ( - c( - 2 - ) -) %>% - j() +a + + (c) + + ( + c( + 2 + ) + ) %>% + j() diff --git a/tests/testthat/indention_operators/overall-out.R b/tests/testthat/indention_operators/overall-out.R index 04b16ba30..0faf92530 100644 --- a/tests/testthat/indention_operators/overall-out.R +++ b/tests/testthat/indention_operators/overall-out.R @@ -4,16 +4,20 @@ pd %>% ggplot(aes(x = new, y = old)) + geom_point() -1 + ( - 22 - (1 / - 2718 / - 23 * 29 * ( - 2 * (22 * -1) + - 1) - - 18) + - sin(pi) - - 2 -) +1 + + ( + 22 - + ( + 1 / + 2718 / + 23 * + 29 * + (2 * (22 * -1) + 1) - + 18 + ) + + sin(pi) - + 2 + ) a <- function(z) { a %>% diff --git a/tests/testthat/indention_operators/pipe_and_assignment-out.R b/tests/testthat/indention_operators/pipe_and_assignment-out.R index de72fdec5..8ff7b59c0 100644 --- a/tests/testthat/indention_operators/pipe_and_assignment-out.R +++ b/tests/testthat/indention_operators/pipe_and_assignment-out.R @@ -1,7 +1,7 @@ a <- b() %>% - q() %>% - g() + q() %>% + g() a <- b() %>% c() %>% diff --git a/tests/testthat/indention_operators/pipe_and_assignment_and_comment-out.R b/tests/testthat/indention_operators/pipe_and_assignment_and_comment-out.R index 4a8a97ac6..b440c92a2 100644 --- a/tests/testthat/indention_operators/pipe_and_assignment_and_comment-out.R +++ b/tests/testthat/indention_operators/pipe_and_assignment_and_comment-out.R @@ -1,18 +1,17 @@ a <- # b() %>% - c() %>% - d() + c() %>% + d() a <- # b() %>% - c() %>% - d() - + c() %>% + d() a <- b() %>% - c() %>% - d() + c() %>% + d() a <- c %>% b() %>% @@ -21,5 +20,5 @@ a <- c %>% a <- b() %>% # - c() %>% - d() # d + c() %>% + d() # d diff --git a/tests/testthat/indention_operators/pipe_and_assignment_and_math-out.R b/tests/testthat/indention_operators/pipe_and_assignment_and_math-out.R index 172735d82..b43a97a1b 100644 --- a/tests/testthat/indention_operators/pipe_and_assignment_and_math-out.R +++ b/tests/testthat/indention_operators/pipe_and_assignment_and_math-out.R @@ -2,4 +2,4 @@ q <- a + -3 + 2 + g() %>% - k() + k() diff --git a/tests/testthat/indention_operators/pipe_simple-out.R b/tests/testthat/indention_operators/pipe_simple-out.R index bb3ff2a43..b1a498858 100644 --- a/tests/testthat/indention_operators/pipe_simple-out.R +++ b/tests/testthat/indention_operators/pipe_simple-out.R @@ -4,12 +4,14 @@ a %>% d(1 + e(sin(f))) %>% g_out() -a <- function(jon_the_pipe) {} +a <- function(jon_the_pipe) { +} x %>% + # break call() - y %>% + call() # mor diff --git a/tests/testthat/indention_operators/tilde-out.R b/tests/testthat/indention_operators/tilde-out.R index 094eee463..fe079b6c8 100644 --- a/tests/testthat/indention_operators/tilde-out.R +++ b/tests/testthat/indention_operators/tilde-out.R @@ -1,7 +1,5 @@ y ~ x + - y + y - -x ~ - 1 + (x | b) +x ~ 1 + (x | b) diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R index 00490d0db..d8459851c 100644 --- a/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R +++ b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R @@ -1,61 +1,61 @@ -while (x > 3) - return(FALSE) +while (x > 3) return(FALSE) -for (i in 1:3) - print(i) +for (i in 1:3) print(i) -if (x) - call2(3) +if (x) call2(3) for (i in 1:3) # print(i) -for (i in - 1:3) # +for (i in 1:3) # print(i) -for (i in # - 1:3) # +for (i in 1:3) # # print(i) -for ( # - i in # - 1:3 # -) # +for (# +i in 1:3) # # # print(i) - -while (x > 3) # +while (x > 3) + # return(FALSE) -while (x > 3 # +while ( + x > 3 # ) return(FALSE) -while ( # test - x > 3) # another +while ( + # test + x > 3 +) + # another return(FALSE) while ( - 2 > # here + 2 > #here 3 # -) # +) + # FALSE while ( - 2 > # here + 2 > #here 3 # ) FALSE while ( - 2 > # here + 2 > #here 3 -) # +) + # FALSE -while ( # - 2 > - 3 -) # +while ( + # + 2 > 3 +) + # FALSE diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R b/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R index e759975fc..d8459851c 100644 --- a/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R +++ b/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R @@ -1,75 +1,61 @@ -while (x > 3) { - return(FALSE) -} +while (x > 3) return(FALSE) -for (i in 1:3) { - print(i) -} +for (i in 1:3) print(i) -if (x) { - call2(3) -} +if (x) call2(3) -for (i in 1:3) { # +for (i in 1:3) # print(i) -} -for (i in - 1:3) { # +for (i in 1:3) # print(i) -} -for (i in # - 1:3) { # +for (i in 1:3) # # print(i) -} -for ( # - i in # - 1:3 # -) { # +for (# +i in 1:3) # # # print(i) -} - -while (x > 3) { # +while (x > 3) + # return(FALSE) -} -while (x > 3 # -) { +while ( + x > 3 # +) return(FALSE) -} -while ( # test - x > 3) { # another +while ( + # test + x > 3 +) + # another return(FALSE) -} while ( - 2 > # here + 2 > #here 3 # -) { # +) + # FALSE -} while ( - 2 > # here + 2 > #here 3 # -) { +) FALSE -} while ( - 2 > # here + 2 > #here 3 -) { # +) + # FALSE -} -while ( # - 2 > - 3 -) { # +while ( + # + 2 > 3 +) + # FALSE -} diff --git a/tests/testthat/indention_operators/while_for_without_curly_same_line_non_strict-out.R b/tests/testthat/indention_operators/while_for_without_curly_same_line_non_strict-out.R index 7342282c8..939beb481 100644 --- a/tests/testthat/indention_operators/while_for_without_curly_same_line_non_strict-out.R +++ b/tests/testthat/indention_operators/while_for_without_curly_same_line_non_strict-out.R @@ -1,31 +1,41 @@ -while (x == 2) h( - 2 -) +while (x == 2) + h( + 2 + ) -while (x == 2) h( # comment - 2 -) +while (x == 2) + h( + # comment + 2 + ) -while (x == 2 && - 2 + 2 == 2) h( - 2 +while ( + x == 2 && + 2 + 2 == 2 ) + h( + 2 + ) +for (x in 1:22) + h( + 2 + ) -for (x in 1:22) h( - 2 -) - -for (x in 1:22) h( # comment - 2 -) +for (x in 1:22) + h( + # comment + 2 + ) for (k in f( 2:22 -)) h( - 2 -) +)) + h( + 2 + ) for (k in f( 2:22 # comment -)) h(2) +)) + h(2) diff --git a/tests/testthat/indention_round_brackets/arithmetic_no_start-out.R b/tests/testthat/indention_round_brackets/arithmetic_no_start-out.R index 99760e3af..4d3af4728 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_no_start-out.R +++ b/tests/testthat/indention_round_brackets/arithmetic_no_start-out.R @@ -1,3 +1,3 @@ 1 + - 2 + ( - 3 + 4) + 2 + + (3 + 4) diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-out.R b/tests/testthat/indention_round_brackets/arithmetic_start-out.R index efaf16e7b..b1be117c3 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-out.R +++ b/tests/testthat/indention_round_brackets/arithmetic_start-out.R @@ -1,12 +1,13 @@ -(1 + - 2 + ( - 3 + 4 - ) +( + 1 + + 2 + + (3 + 4) ) ( 1 + - 2 + ( + 2 + + ( # the space below is intentional 3 + 4 diff --git a/tests/testthat/indention_round_brackets/multi_line-no-indention-out.R b/tests/testthat/indention_round_brackets/multi_line-no-indention-out.R index e960a3d0d..99ec45a29 100644 --- a/tests/testthat/indention_round_brackets/multi_line-no-indention-out.R +++ b/tests/testthat/indention_round_brackets/multi_line-no-indention-out.R @@ -1,7 +1,8 @@ call( 1, call2( - 2, 3, + 2, + 3, call3(1, 2, 22), 5 ), diff --git a/tests/testthat/indention_round_brackets/multi_line-random-out.R b/tests/testthat/indention_round_brackets/multi_line-random-out.R index 98b2950bd..708ab28a4 100644 --- a/tests/testthat/indention_round_brackets/multi_line-random-out.R +++ b/tests/testthat/indention_round_brackets/multi_line-random-out.R @@ -1,7 +1,8 @@ call( 1, call2( - 2, 3, + 2, + 3, call3(1, 2, 22), 5 ), @@ -11,7 +12,8 @@ call( call( 1, call2( - 2, 3, + 2, + 3, call3(1, 2, 22), 5 ), diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R index 378cb936b..322d25bf5 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R @@ -12,26 +12,34 @@ a[[ a[[ - 2 -]] +2 + ]] a[[ 2 - ] # +] # ] a[[ + 2 + + ]] a[[ + # this comment shouldn't mess 1, c( + 1, 2 # neither should this one - ) + + ) + + ]] diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R index f888e3398..ecae35ca3 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R @@ -5,53 +5,54 @@ ranges[ fak[a, b] -fac[ - a, - b -] +fac[a, b] fac[ a, b ] -fac[ - , `:`(a = b) +fac[, + `:`(a = b) ] -fac[ - , `:`(a = b) +fac[, + `:`(a = b) ] fac[, `:`(a = c)] -fac[ - , `:`(a = c) +fac[, + `:`(a = c) ] -x[a == 3 | - b == v, ] +x[ + a == 3 | + b == v, +] -x[a == 3 | - b == v, ] +x[a == 3 | b == v, ] -x[a == 3 || - b == v, ] +x[ + a == 3 || + b == v, +] -x[a == 3 || - b == v, ] +x[a == 3 || b == v, ] -x[a == 3 && - b == v, ] +x[a == 3 && b == v, ] -x[a == 3 & - b == v, ] +x[a == 3 & b == v, ] -x[a == 3 && - b == v, ] +x[ + a == 3 && + b == v, +] -x[a == 3 & - b == v, ] +x[ + a == 3 & + b == v, +] x[ # comments above @@ -60,7 +61,6 @@ x[ # or below shouldn't be an issue ] - x[ a, b @@ -68,8 +68,10 @@ x[ x[ # this comment shouldn't be an issue - 1, c( - 1, 2 + 1, + c( + 1, + 2 # neither should this one ) diff --git a/tests/testthat/insertion_comment_interaction/if_else_if_else_non_strict-out.R b/tests/testthat/insertion_comment_interaction/if_else_if_else_non_strict-out.R index b1cbc8852..29848ddbf 100644 --- a/tests/testthat/insertion_comment_interaction/if_else_if_else_non_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/if_else_if_else_non_strict-out.R @@ -2,24 +2,33 @@ if (TRUE) NULL else if (FALSE) NULL else NULL if (TRUE) NULL else if (FALSE) NULL else NULL # comment - -if (TRUE) NULL else if (FALSE) NULL else # comment +if (TRUE) NULL else if (FALSE) NULL else + # comment NULL # if(TRUE)NULL else if(FALSE)NULL # comment # else NULL -if (TRUE) NULL else if (FALSE) # comment +if (TRUE) NULL else if (FALSE) + # comment NULL else NULL -if (TRUE) NULL else if (FALSE # comment -) NULL else NULL +if (TRUE) NULL else if ( + FALSE # comment +) + NULL else NULL -if (TRUE) NULL else if ( # comment - FALSE) NULL else NULL +if (TRUE) NULL else if ( + # comment + FALSE +) + NULL else NULL -if (TRUE) NULL else if # comment -(FALSE) NULL else NULL +if (TRUE) NULL else if ( + # comment + FALSE +) + NULL else NULL if (TRUE) NULL else # comment if (FALSE) NULL else NULL @@ -27,14 +36,23 @@ if (FALSE) NULL else NULL # if(TRUE)NULL # comment # else if(FALSE)NULL else NULL -if (TRUE) # comment +if (TRUE) + # comment NULL else if (FALSE) NULL else NULL -if (TRUE # comment -) NULL else if (FALSE) NULL else NULL +if ( + TRUE # comment +) + NULL else if (FALSE) NULL else NULL -if ( # comment - TRUE) NULL else if (FALSE) NULL else NULL +if ( + # comment + TRUE +) + NULL else if (FALSE) NULL else NULL -if # comment -(TRUE) NULL else if (FALSE) NULL else NULL +if ( + # comment + TRUE +) + NULL else if (FALSE) NULL else NULL diff --git a/tests/testthat/insertion_comment_interaction/if_else_if_else_strict-out.R b/tests/testthat/insertion_comment_interaction/if_else_if_else_strict-out.R index e20e8c9c8..29848ddbf 100644 --- a/tests/testthat/insertion_comment_interaction/if_else_if_else_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/if_else_if_else_strict-out.R @@ -2,76 +2,57 @@ if (TRUE) NULL else if (FALSE) NULL else NULL if (TRUE) NULL else if (FALSE) NULL else NULL # comment - -if (TRUE) { - NULL -} else if (FALSE) { - NULL -} else { # comment +if (TRUE) NULL else if (FALSE) NULL else + # comment NULL -} # if(TRUE)NULL else if(FALSE)NULL # comment # else NULL -if (TRUE) { - NULL -} else if (FALSE) { # comment - NULL -} else { - NULL -} +if (TRUE) NULL else if (FALSE) + # comment + NULL else NULL -if (TRUE) { - NULL -} else if (FALSE # comment -) { - NULL -} else { - NULL -} +if (TRUE) NULL else if ( + FALSE # comment +) + NULL else NULL -if (TRUE) { - NULL -} else if ( # comment - FALSE) { - NULL -} else { - NULL -} +if (TRUE) NULL else if ( + # comment + FALSE +) + NULL else NULL -if (TRUE) { - NULL -} else if # comment -(FALSE) { - NULL -} else { - NULL -} +if (TRUE) NULL else if ( + # comment + FALSE +) + NULL else NULL -if (TRUE) { - NULL -} else # comment +if (TRUE) NULL else # comment if (FALSE) NULL else NULL # if(TRUE)NULL # comment # else if(FALSE)NULL else NULL -if (TRUE) { # comment - NULL -} else if (FALSE) NULL else NULL - -if (TRUE # comment -) { - NULL -} else if (FALSE) NULL else NULL - -if ( # comment - TRUE) { - NULL -} else if (FALSE) NULL else NULL - -if # comment -(TRUE) { - NULL -} else if (FALSE) NULL else NULL +if (TRUE) + # comment + NULL else if (FALSE) NULL else NULL + +if ( + TRUE # comment +) + NULL else if (FALSE) NULL else NULL + +if ( + # comment + TRUE +) + NULL else if (FALSE) NULL else NULL + +if ( + # comment + TRUE +) + NULL else if (FALSE) NULL else NULL diff --git a/tests/testthat/insertion_comment_interaction/if_else_non_strict-out.R b/tests/testthat/insertion_comment_interaction/if_else_non_strict-out.R index e728573e5..de31b028f 100644 --- a/tests/testthat/insertion_comment_interaction/if_else_non_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/if_else_non_strict-out.R @@ -2,21 +2,30 @@ if (TRUE) NULL else NULL if (TRUE) NULL else NULL # comment - -if (TRUE) NULL else # comment +if (TRUE) NULL else + # comment NULL # if(TRUE)NULL # comment # else NULL -if (TRUE) # comment +if (TRUE) + # comment NULL else NULL -if (TRUE # comment -) NULL else NULL +if ( + TRUE # comment +) + NULL else NULL -if ( # comment - TRUE) NULL else NULL +if ( + # comment + TRUE +) + NULL else NULL -if # comment -(TRUE) NULL else NULL +if ( + # comment + TRUE +) + NULL else NULL diff --git a/tests/testthat/insertion_comment_interaction/if_else_strict-out.R b/tests/testthat/insertion_comment_interaction/if_else_strict-out.R index 27af5497e..de31b028f 100644 --- a/tests/testthat/insertion_comment_interaction/if_else_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/if_else_strict-out.R @@ -2,39 +2,30 @@ if (TRUE) NULL else NULL if (TRUE) NULL else NULL # comment - -if (TRUE) { - NULL -} else { # comment +if (TRUE) NULL else + # comment NULL -} # if(TRUE)NULL # comment # else NULL -if (TRUE) { # comment - NULL -} else { - NULL -} - -if (TRUE # comment -) { - NULL -} else { - NULL -} - -if ( # comment - TRUE) { - NULL -} else { - NULL -} - -if # comment -(TRUE) { - NULL -} else { - NULL -} +if (TRUE) + # comment + NULL else NULL + +if ( + TRUE # comment +) + NULL else NULL + +if ( + # comment + TRUE +) + NULL else NULL + +if ( + # comment + TRUE +) + NULL else NULL diff --git a/tests/testthat/insertion_comment_interaction/just_if_non_strict-out.R b/tests/testthat/insertion_comment_interaction/just_if_non_strict-out.R index 4056cbac8..5dc076c2b 100644 --- a/tests/testthat/insertion_comment_interaction/just_if_non_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/just_if_non_strict-out.R @@ -2,15 +2,23 @@ if (TRUE) NULL if (TRUE) NULL # comment - -if (TRUE) # comment +if (TRUE) + # comment NULL -if (TRUE # comment -) NULL +if ( + TRUE # comment +) + NULL -if ( # comment - TRUE) NULL +if ( + # comment + TRUE +) + NULL -if # comment -(TRUE) NULL +if ( + # comment + TRUE +) + NULL diff --git a/tests/testthat/insertion_comment_interaction/just_if_strict-out.R b/tests/testthat/insertion_comment_interaction/just_if_strict-out.R index ce265b218..5dc076c2b 100644 --- a/tests/testthat/insertion_comment_interaction/just_if_strict-out.R +++ b/tests/testthat/insertion_comment_interaction/just_if_strict-out.R @@ -2,22 +2,23 @@ if (TRUE) NULL if (TRUE) NULL # comment - -if (TRUE) { # comment +if (TRUE) + # comment NULL -} -if (TRUE # comment -) { +if ( + TRUE # comment +) NULL -} -if ( # comment - TRUE) { +if ( + # comment + TRUE +) NULL -} -if # comment -(TRUE) { +if ( + # comment + TRUE +) NULL -} diff --git a/tests/testthat/line_breaks_and_other/around-eq-sub-out.R b/tests/testthat/line_breaks_and_other/around-eq-sub-out.R index 29fe9894c..64f0964d9 100644 --- a/tests/testthat/line_breaks_and_other/around-eq-sub-out.R +++ b/tests/testthat/line_breaks_and_other/around-eq-sub-out.R @@ -1,39 +1,29 @@ c(x = 2) -c( - x = - 2 -) - -c( - x = 2 -) +c(x = 2) c( x = 2 ) -c( - x = 2, - a = - 1 -) +c(x = 2) +c(x = 2, a = 1) c( x = 2, - a = # stuff - 1 + # stuff + a = 1 ) - c( - b = 4, x # comment - = 2 + b = 4, + # comment + x = 2 ) - c( - x = # comment - 2, c = - ) + # comment + x = 2, + c = +) diff --git a/tests/testthat/line_breaks_and_other/assignment-out.R b/tests/testthat/line_breaks_and_other/assignment-out.R index 5c16559ed..7af9557d7 100644 --- a/tests/testthat/line_breaks_and_other/assignment-out.R +++ b/tests/testthat/line_breaks_and_other/assignment-out.R @@ -1,35 +1,32 @@ x <- 2 - x <- 3 - x <- # the culprit 3 - -x <- # +x = # 2 +x = 3 -x <- 3 - -x <- +x = # comment 3 - ImportantDataFrame$ImportantColumn1 <- ImportantDataFrame$ImportantColumn2 <- - ComplicatedFunction(ImportantDataFrame$InputColumn) - + ComplicatedFunction(ImportantDataFrame$InputColumn) ImportantDataFrame$ImportantColumn1 <- - ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction(ImportantDataFrame$InputColumn) - + ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction( + ImportantDataFrame$InputColumn + ) ImportantDataFrame$ImportantColumn1 <- - ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction(ImportantDataFrame$InputColumn) + ImportantDataFrame$ImportantColumn2 <- ComplicatedFunction( + ImportantDataFrame$InputColumn + ) diff --git a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R index 346e0303c..eda18817d 100644 --- a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R +++ b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R @@ -2,7 +2,6 @@ c(a |> b()) c(a + b |> c()) - c(a |> b()) c( @@ -14,21 +13,28 @@ c( ) c( - a + b |> - c() + a + + b |> + c() ) -c(a + b |> - c()) +c( + a + + b |> + c() +) c( - a + b |> # 654 - c() + a + + b |> # 654 + c() ) -c( # rr - a + b |> - c() +c( + # rr + a + + b |> + c() ) c( @@ -36,53 +42,47 @@ c( b |> c() ) -c(a + - b |> c()) +c( + a + + b |> c() +) a |> b() -a |> - b() |> - q() +a |> b() |> q() a |> b() -a |> - b() |> - c() +a |> b() |> c() # short pipes < 2 can stay on one line a |> b() -fun( - x, - a |> b() -) +fun(x, a |> b()) -fun(x, - gg = a |> b(), - tt |> q() -) +fun(x, gg = a |> b(), tt |> q()) fun(x, gg = a |> b(), tt |> q()) -z <- a |> b() +z = a |> b() -fun( - s = g(x), - gg = a(n == 2) |> b(), - tt |> q(r = 3) -) +fun(s = g(x), gg = a(n == 2) |> b(), tt |> q(r = 3)) # FIXME closing brace could go on ntext line. Alternative: remove lin breaks completely. -blew(x |> - c(), y = 2) +blew( + x |> -# FIXME closing brace could go on ntext line. Alternative: move c() up. -blew(y = 2, x |> - c()) + c(), + y = 2 +) +# FIXME closing brace could go on ntext line. Alternative: move c() up. +blew( + y = 2, + x |> + c() +) { a |> c() + 1 diff --git a/tests/testthat/line_breaks_and_other/braces-fun-calls1-out.R b/tests/testthat/line_breaks_and_other/braces-fun-calls1-out.R index df9b2137d..695755ea7 100644 --- a/tests/testthat/line_breaks_and_other/braces-fun-calls1-out.R +++ b/tests/testthat/line_breaks_and_other/braces-fun-calls1-out.R @@ -7,7 +7,6 @@ test_that(x, { hh }) - # there are multiple brace expressions that spread over multiple lines # (classical tryCatch) tryCatch( 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 340e1eaf8..ddc4e3d26 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,6 +1,7 @@ test( "x", - {}, + { + }, a + b, { s(x = sd) @@ -9,7 +10,8 @@ test( test( "x", - {}, + { + }, a + b, { s(x = sd) @@ -18,17 +20,18 @@ test( test( "x", - {}, + { + }, a + b, { s(x = sd) } ) - test( "x", - {}, + { + }, a + b, { s(x = sd) @@ -37,7 +40,8 @@ test( test( "x", - {}, # h + { + }, # h a + b, { s(x = sd) @@ -46,7 +50,8 @@ test( test( "x", - {}, # h + { + }, # h a + b, # k { @@ -56,7 +61,8 @@ test( test( "x", - {}, + { + }, a + b, # k { s(x = sd) @@ -71,26 +77,34 @@ tetst( 1 + +1 ) -while ({ - x -}) { +while ( + { + x + } +) { f() } -while ({ - x -}) { +while ( + { + x + } +) { f() } -while ({ - x -}) { +while ( + { + x + } +) { f() } -while ({ - x -}) { +while ( + { + x + } +) { f() } diff --git a/tests/testthat/line_breaks_and_other/comma-out.R b/tests/testthat/line_breaks_and_other/comma-out.R index 14842c18e..b15ca36c9 100644 --- a/tests/testthat/line_breaks_and_other/comma-out.R +++ b/tests/testthat/line_breaks_and_other/comma-out.R @@ -1,13 +1,6 @@ -call( - a, - b, - c -) +call(a, b, c) -call( - a, b, - c -) +call(a, b, c) call(a, ) call(a, ) @@ -22,10 +15,7 @@ mpg %>% n_class = n_distinct(class) ) - 1:4 %>% { - ( - . + 1 - ) + (. + 1) } diff --git a/tests/testthat/line_breaks_and_other/comment-around-curly-out.R b/tests/testthat/line_breaks_and_other/comment-around-curly-out.R index c664d7ba2..79b71b4b3 100644 --- a/tests/testthat/line_breaks_and_other/comment-around-curly-out.R +++ b/tests/testthat/line_breaks_and_other/comment-around-curly-out.R @@ -1,2 +1,3 @@ -X_and_F_symbol_linter <- function() { # nolint: object_name. +X_and_F_symbol_linter <- function() { + # nolint: object_name. } diff --git a/tests/testthat/line_breaks_and_other/curly-brace-edge-out.R b/tests/testthat/line_breaks_and_other/curly-brace-edge-out.R index 4e88ef2ec..7a875365a 100644 --- a/tests/testthat/line_breaks_and_other/curly-brace-edge-out.R +++ b/tests/testthat/line_breaks_and_other/curly-brace-edge-out.R @@ -1,24 +1,34 @@ -function(y = {}) NULL +function( + y = { + } +) NULL -function(y = - {}) { - NULL -} +function( + y = { + } +) NULL -function(yyy = { - 1 - }) { +function( + yyy = { + 1 + } +) { 1 } -function(yyy = { - 1 - }) { +function( + yyy = { + 1 + } +) { 1 } -f1 <- function(x = { - 1 - }, y = 0) { +f1 <- function( + x = { + 1 + }, + y = 0 +) { c(x, y) } diff --git a/tests/testthat/line_breaks_and_other/curly-out.R b/tests/testthat/line_breaks_and_other/curly-out.R index 22730a44b..a64650ace 100644 --- a/tests/testthat/line_breaks_and_other/curly-out.R +++ b/tests/testthat/line_breaks_and_other/curly-out.R @@ -9,7 +9,6 @@ test_that("I am here", { a_test(x) }) - # A { should always be followed by a new line if (x > 3) { "x" @@ -31,25 +30,24 @@ test_that("I am here", { a_test(x) }) -test_that( - desc = "bla", - code = { - # comment - expect_equal(1 + 1, 2) - } -) - +test_that(desc = "bla", code = { + # comment + expect_equal(1 + 1, 2) +}) -while (TRUE) {} +while (TRUE) { +} -while (TRUE) {} +while (TRUE) { +} -while (TRUE) {} +while (TRUE) { +} while (TRUE) { # } - -while (TRUE) { # +while (TRUE) { + # } diff --git a/tests/testthat/line_breaks_and_other/edge_comment_and_curly-out.R b/tests/testthat/line_breaks_and_other/edge_comment_and_curly-out.R index 39202e3fa..2588bfe53 100644 --- a/tests/testthat/line_breaks_and_other/edge_comment_and_curly-out.R +++ b/tests/testthat/line_breaks_and_other/edge_comment_and_curly-out.R @@ -1,4 +1,4 @@ -a <- function(x) # this is a comment and the bracket below should not be moved one line up after the comment. -{ +a <- function(x) { + # this is a comment and the bracket below should not be moved one line up after the comment. x } diff --git a/tests/testthat/line_breaks_and_other/ggplot2-out.R b/tests/testthat/line_breaks_and_other/ggplot2-out.R index 9a46ec2b4..fed377e08 100644 --- a/tests/testthat/line_breaks_and_other/ggplot2-out.R +++ b/tests/testthat/line_breaks_and_other/ggplot2-out.R @@ -2,26 +2,20 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + geom_point() - # add when unmasked -ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + - geom_point() - +ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + geom_point() # add when masked -ggplot2::ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + - geom_point() +ggplot2::ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + geom_point() # add when masked -ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + - ggplot2::geom_point() +ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + ggplot2::geom_point() # add when comment ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + # comment ggplot2::geom_point() + g() - # add when comment ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + ggplot2::geom_point() + @@ -32,7 +26,6 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + ggplot2::geom_point() + g() # comment - # add when comment ggplot(data = mtcars, mapping = aes(x = mpg, y = vs)) + ggplot2::geom_point() + diff --git a/tests/testthat/line_breaks_and_other/non_strict-out.R b/tests/testthat/line_breaks_and_other/non_strict-out.R index 71c76061b..a9c245068 100644 --- a/tests/testthat/line_breaks_and_other/non_strict-out.R +++ b/tests/testthat/line_breaks_and_other/non_strict-out.R @@ -3,11 +3,5 @@ a <- { } a <- { - - 3 + 1 - - - - } diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R index 093655a80..0616f6074 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R @@ -1,11 +1,11 @@ -c(a %>% b()) +c(a %>% b) c(a %>% b()) -c(a + b %>% c()) +c(a + b %>% c) c( - a %>% b() + a %>% b ) c(a %>% b()) @@ -15,91 +15,90 @@ c( ) c( - a + b %>% c() + a + b %>% c ) c( - a + b %>% - c() + a + + b %>% + c ) -c(a + b %>% - c()) +c( + a + + b %>% + c +) c( - a + b %>% # 654 - c() + a + + b %>% # 654 + c ) -c( # rr - a + b %>% - c() +c( + # rr + a + + b %>% + c ) c( a + - b %>% c() + b %>% c ) -c(a + - b %>% c()) +c( + a + + b %>% c +) a %>% b() -a %>% - b() %>% - q() +a %>% b() %>% q a %>% b() -a %>% - b() %>% - c() +a %>% b() %>% c # short pipes < 2 can stay on one line a %>% b() -fun( - x, - a %>% b() -) +fun(x, a %>% b) -fun(x, - gg = a %>% b(), - tt %>% q() -) +fun(x, gg = a %>% b, tt %>% q) -fun(x, gg = a %>% b(), tt %>% q()) +fun(x, gg = a %>% b, tt %>% q) -z <- a %>% b() +z = a %>% b() -fun( - s = g(x), - gg = a(n == 2) %>% b(), - tt %>% q(r = 3) -) +fun(s = g(x), gg = a(n == 2) %>% b, tt %>% q(r = 3)) # FIXME closing brace could go on ntext line. Alternative: remove lin breaks completely. -blew(x %>% - c(), y = 2) +blew( + x %>% -# FIXME closing brace could go on ntext line. Alternative: move c() up. -blew(y = 2, x %>% - c()) + c(), + y = 2 +) +# FIXME closing brace could go on ntext line. Alternative: move c() up. +blew( + y = 2, + x %>% + c() +) { - a %>% c() + 1 + a %>% c + 1 } - b %>% f() %>% # never move comment to next line as it can be styler: off or nolint k() %>% x() - # line break before { inserted inside and outside function calls c( data %>% @@ -134,6 +133,7 @@ data %>% c( data %>% filter(bar) %>% + { cor(.$col1, .$col2, use = "complete.obs") } @@ -141,6 +141,7 @@ c( data %>% filter(bar) %>% + { cor(.$col1, .$col2, use = "complete.obs") } diff --git a/tests/testthat/line_breaks_fun_call/blank-strict-out.R b/tests/testthat/line_breaks_fun_call/blank-strict-out.R index 19232c9fa..89faa04eb 100644 --- a/tests/testthat/line_breaks_fun_call/blank-strict-out.R +++ b/tests/testthat/line_breaks_fun_call/blank-strict-out.R @@ -11,6 +11,7 @@ call( call( x = 2, 1, + "w" ) @@ -18,10 +19,10 @@ call( 1, 2, - # comment 1, 2, + 3 ) diff --git a/tests/testthat/line_breaks_fun_call/line_breaks_and_comments-out.R b/tests/testthat/line_breaks_fun_call/line_breaks_and_comments-out.R index d2498155b..96e6a179d 100644 --- a/tests/testthat/line_breaks_fun_call/line_breaks_and_comments-out.R +++ b/tests/testthat/line_breaks_fun_call/line_breaks_and_comments-out.R @@ -1,4 +1,5 @@ -call( # comment +call( + # comment am ) @@ -16,7 +17,6 @@ call( pm ) - call(b) call( @@ -27,12 +27,14 @@ call( a # b ) -call( # +call( + # ) call( a # b ) -call( # b +call( + # b a ) diff --git a/tests/testthat/line_breaks_fun_call/named_arguments-out.R b/tests/testthat/line_breaks_fun_call/named_arguments-out.R index 485e4d609..56a30a76d 100644 --- a/tests/testthat/line_breaks_fun_call/named_arguments-out.R +++ b/tests/testthat/line_breaks_fun_call/named_arguments-out.R @@ -1,24 +1,11 @@ -call(3, - b = 2, c -) +call(3, b = 2, c) -gs(3, - b = 2, - c -) +gs(3, b = 2, c) call(3, b = 2, c) -map(data, fun, - x = 3, z = 33 -) +map(data, fun, x = 3, z = 33) -map2( - dat1, data2, fun, x, y, - z -) +map2(dat1, data2, fun, x, y, z) -map2(dat1, data2, fun, - x = 1, y = 2, - z -) +map2(dat1, data2, fun, x = 1, y = 2, z) diff --git a/tests/testthat/line_breaks_fun_call/switch_ifelse_etc_no_line_break-out.R b/tests/testthat/line_breaks_fun_call/switch_ifelse_etc_no_line_break-out.R index 4c108e249..21c2ff9df 100644 --- a/tests/testthat/line_breaks_fun_call/switch_ifelse_etc_no_line_break-out.R +++ b/tests/testthat/line_breaks_fun_call/switch_ifelse_etc_no_line_break-out.R @@ -3,77 +3,63 @@ call( 3 ) -switch(x, +switch( + x, a = 2, y = 3 ) - -switch( # +switch( + # x, a = 2, y = 3 ) - -switch(x, +switch( + x, a = 2, # - y = 3 -) - -switch(x, - a = 2, y = 3 ) -switch(x, +switch( + x, a = 2, y = 3 ) -switch(x, - a = 2, - y = 3 -) +switch(x, a = 2, y = 3) -switch(x, - a = 2, - y = 3 -) # +switch(x, a = 2, y = 3) + +switch(x, a = 2, y = 3) # -switch(x, +switch( + x, a = 2, y = 3 # ) -if_else(a, - c, v -) - -ifelse(x, - y, z -) +if_else(a, c, v) +ifelse(x, y, z) # namespacing -base::switch(f, - x = 2, - y = 3 -) +base::switch(f, x = 2, y = 3) -base::switch(f, +base::switch( + f, x = 2, y = 3 ) -dplyr::ifelse(x, - 1, 32 -) +dplyr::ifelse(x, 1, 32) dplyr::ifelse( x, - 1, 32 + 1, + 32 ) # variable name 'switch' is different diff --git a/tests/testthat/line_breaks_fun_call/token_dependent_comments-out.R b/tests/testthat/line_breaks_fun_call/token_dependent_comments-out.R index 68cb70a94..b6ded86e6 100644 --- a/tests/testthat/line_breaks_fun_call/token_dependent_comments-out.R +++ b/tests/testthat/line_breaks_fun_call/token_dependent_comments-out.R @@ -1,8 +1,14 @@ -call(call( # comment - 3, 4 -)) +call( + call( + # comment + 3, + 4 + ) +) -call(call( - 1, # comment - 3 -)) +call( + call( + 1, # comment + 3 + ) +) 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 c4783fb6c..bed844710 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 @@ -1,38 +1,67 @@ -call(call( - 2 -)) +call( + call( + 2 + ) +) -call(call(1, - 2)) +call(call(1, 2)) # multi-line: no indention based on first vall -call(a(b(c({})))) - -call(call( - 2), -5) - +call( + a( + b( + c({ + }) + ) + ) +) -call(call(1, - 2, c( - 3 -))) +call( + call( + 2 + ), + 5 +) -call(1, - call2(3, 4, call(3, - 4, call(5, 6, call( - 2 - ) +call( + call( + 1, + 2, + c( + 3 ) ) +) + +call( + 1, + call2( + 3, + 4, + call( + 3, + 4, + call( + 5, + 6, + call( + 2 + ) + ) + ) ) ) # comment lala -call(call( - 2 -)) +call( + call( + 2 + ) +) -call(1, call( - 23 -)) +call( + 1, + call( + 23 + ) +) 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 8e0309e98..bed844710 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 @@ -1,13 +1,19 @@ -call(call( - 2 -)) +call( + call( + 2 + ) +) -call(call( - 1, - 2 -)) +call(call(1, 2)) # multi-line: no indention based on first vall -call(a(b(c({})))) +call( + a( + b( + c({ + }) + ) + ) +) call( call( @@ -16,30 +22,46 @@ call( 5 ) - -call(call( - 1, - 2, c( - 3 +call( + call( + 1, + 2, + c( + 3 + ) ) -)) +) call( 1, - call2(3, 4, call( + call2( 3, - 4, call(5, 6, call( - 2 - )) - )) + 4, + call( + 3, + 4, + call( + 5, + 6, + call( + 2 + ) + ) + ) + ) ) # comment lala -call(call( - 2 -)) +call( + call( + 2 + ) +) -call(1, call( - 23 -)) +call( + 1, + call( + 23 + ) +) diff --git a/tests/testthat/line_breaks_fun_call/token_dependent_mixed-out.R b/tests/testthat/line_breaks_fun_call/token_dependent_mixed-out.R index 1bd68278f..8ef441c87 100644 --- a/tests/testthat/line_breaks_fun_call/token_dependent_mixed-out.R +++ b/tests/testthat/line_breaks_fun_call/token_dependent_mixed-out.R @@ -1,76 +1,42 @@ -call(call( - call3(), call, - 4433, - 55 -)) - -call(call( - call3(), call, - 4433, - 55 -)) -call(call( - call3(), call, - 4433, - 55 -)) +call(call(call3(), call, 4433, 55)) +call(call(call3(), call, 4433, 55)) +call(call(call3(), call, 4433, 55)) # no more barcket on same line -> -call(call( - 3, 4 -)) - - call( - 3, - 3 + call( + 3, + 4 + ) ) +call(3, 3) -call(call( - call3(), call, - 44, - 55 -)) +call(call(call3(), call, 44, 55)) # +call(call, call(), 3, 4) + call( - call, call(), - 3, - 4 + call( + 3, + 4 + ) ) -call(call( - 3, 4 -)) - -call(call( - 1, - 3 -)) +call(call(1, 3)) # if a multiline expression follows -> don't indent - call( 2 ) -cjaldfjadf( - 1, - 3 -) - -jclakjdscs(call(call( - 2, - 4 -))) -fjadlksfj( - casl(), - 1 -) +cjaldfjadf(1, 3) +jclakjdscs(call(call(2, 4))) +fjadlksfj(casl(), 1) test_that("hi", { "there" diff --git a/tests/testthat/line_breaks_fun_call/unindent-out.R b/tests/testthat/line_breaks_fun_call/unindent-out.R index 6452a6c74..0d7687114 100644 --- a/tests/testthat/line_breaks_fun_call/unindent-out.R +++ b/tests/testthat/line_breaks_fun_call/unindent-out.R @@ -1,7 +1,3 @@ -test_that(key( - s -), x = 1) - test_that( key( s @@ -9,11 +5,19 @@ test_that( x = 1 ) +test_that( + key( + s + ), + x = 1 +) -test_that(key( - s -), x = 1) - +test_that( + key( + s + ), + x = 1 +) test_that( key(s), diff --git a/tests/testthat/line_breaks_top_level_exprs/braces-out.R b/tests/testthat/line_breaks_top_level_exprs/braces-out.R index 9fd7a480d..8ce059a5c 100644 --- a/tests/testthat/line_breaks_top_level_exprs/braces-out.R +++ b/tests/testthat/line_breaks_top_level_exprs/braces-out.R @@ -2,10 +2,8 @@ 1 + 1 } - ### some comment - { NULL } diff --git a/tests/testthat/line_breaks_top_level_exprs/conditionals-out.R b/tests/testthat/line_breaks_top_level_exprs/conditionals-out.R index 54104e290..bae1b23ff 100644 --- a/tests/testthat/line_breaks_top_level_exprs/conditionals-out.R +++ b/tests/testthat/line_breaks_top_level_exprs/conditionals-out.R @@ -1,11 +1,10 @@ -for (i in 1:10) {} - +for (i in 1:10) { +} # some comment - -while (TRUE) {} - +while (TRUE) { +} # some comment if (TRUE) NULL diff --git a/tests/testthat/line_breaks_top_level_exprs/function_defs_and_calls-out.R b/tests/testthat/line_breaks_top_level_exprs/function_defs_and_calls-out.R index 741c47309..4751fcec6 100644 --- a/tests/testthat/line_breaks_top_level_exprs/function_defs_and_calls-out.R +++ b/tests/testthat/line_breaks_top_level_exprs/function_defs_and_calls-out.R @@ -1,12 +1,9 @@ f <- function() NULL - g <- function() NULL - f() # comment - g() diff --git a/tests/testthat/line_breaks_top_level_exprs/non_strict-out.R b/tests/testthat/line_breaks_top_level_exprs/non_strict-out.R index 4a18af903..4751fcec6 100644 --- a/tests/testthat/line_breaks_top_level_exprs/non_strict-out.R +++ b/tests/testthat/line_breaks_top_level_exprs/non_strict-out.R @@ -1,23 +1,9 @@ f <- function() NULL - - - - - - - g <- function() NULL - - - f() # comment - - - - g() diff --git a/tests/testthat/line_breaks_top_level_exprs/piped_chains-out.R b/tests/testthat/line_breaks_top_level_exprs/piped_chains-out.R index b424cbba1..de9d49459 100644 --- a/tests/testthat/line_breaks_top_level_exprs/piped_chains-out.R +++ b/tests/testthat/line_breaks_top_level_exprs/piped_chains-out.R @@ -1,10 +1,7 @@ f %>% g() - h %>% i() - # some comment - j %>% k() diff --git a/tests/testthat/math_token_spacing/non_strict_math_spacing_all-out.R b/tests/testthat/math_token_spacing/non_strict_math_spacing_all-out.R index 1c1a997f0..d259e95fc 100644 --- a/tests/testthat/math_token_spacing/non_strict_math_spacing_all-out.R +++ b/tests/testthat/math_token_spacing/non_strict_math_spacing_all-out.R @@ -1 +1 @@ -1 + +1 - 3 / 23 * 3^4 +1 + +1 - 3 / 23 * 3^4 diff --git a/tests/testthat/math_token_spacing/strict_math_spacing_zero_all_but_power-out.R b/tests/testthat/math_token_spacing/strict_math_spacing_zero_all_but_power-out.R index 1f561bdb8..d259e95fc 100644 --- a/tests/testthat/math_token_spacing/strict_math_spacing_zero_all_but_power-out.R +++ b/tests/testthat/math_token_spacing/strict_math_spacing_zero_all_but_power-out.R @@ -1 +1 @@ -1++1-3/23*3 ^ 4 +1 + +1 - 3 / 23 * 3^4 diff --git a/tests/testthat/math_token_spacing/strict_math_spacing_zero_plus-out.R b/tests/testthat/math_token_spacing/strict_math_spacing_zero_plus-out.R index ac744cc2a..d259e95fc 100644 --- a/tests/testthat/math_token_spacing/strict_math_spacing_zero_plus-out.R +++ b/tests/testthat/math_token_spacing/strict_math_spacing_zero_plus-out.R @@ -1 +1 @@ -1++1 - 3 / 23 * 3 ^ 4 +1 + +1 - 3 / 23 * 3^4 diff --git a/tests/testthat/multiple_expressions/three_complex_expr-out.R b/tests/testthat/multiple_expressions/three_complex_expr-out.R index 43a7c38ea..04d03d924 100644 --- a/tests/testthat/multiple_expressions/three_complex_expr-out.R +++ b/tests/testthat/multiple_expressions/three_complex_expr-out.R @@ -1,5 +1,3 @@ x 1 + 1 -y + ( - 2 * z -) +y + (2 * z) diff --git a/tests/testthat/parse_comments/just_comments-out.R b/tests/testthat/parse_comments/just_comments-out.R index 1821c1db7..1549c427b 100644 --- a/tests/testthat/parse_comments/just_comments-out.R +++ b/tests/testthat/parse_comments/just_comments-out.R @@ -2,5 +2,4 @@ #' A roxygen comment #' - # some blank lines diff --git a/tests/testthat/parse_comments/mixed-out.R b/tests/testthat/parse_comments/mixed-out.R index f954a0563..e89194c12 100644 --- a/tests/testthat/parse_comments/mixed-out.R +++ b/tests/testthat/parse_comments/mixed-out.R @@ -1,7 +1,7 @@ # A file with text a <- function(x, y, z) { -if (1>10) { -# this is a comment -} -#' another comment + if (1 > 10) { + # this is a comment + } + #' another comment } diff --git a/tests/testthat/parse_comments/output-prefix-out.R b/tests/testthat/parse_comments/output-prefix-out.R index 62c97ec65..4ab2ff86b 100644 --- a/tests/testthat/parse_comments/output-prefix-out.R +++ b/tests/testthat/parse_comments/output-prefix-out.R @@ -1,7 +1,6 @@ this() #> is output - this() #> is not this() diff --git a/tests/testthat/parse_comments/shebang_1-out.R b/tests/testthat/parse_comments/shebang_1-out.R index a145d2c47..02f2b1043 100644 --- a/tests/testthat/parse_comments/shebang_1-out.R +++ b/tests/testthat/parse_comments/shebang_1-out.R @@ -1,10 +1,10 @@ -# A comment -# !/usr/bin/env Rscript -# !/usr/bin/env Rscript +#A comment +#!/usr/bin/env Rscript +#!/usr/bin/env Rscript a <- 3 -# !/usr/bin /env Rscript -m --set "W" +#!/usr/bin /env Rscript -m --set "W" dd <- 33 -# !/usr/bin\ /env Rscript -m --set "W" +#!/usr/bin\ /env Rscript -m --set "W" c() -# !NEED TO REMOVE THIS +#!NEED TO REMOVE THIS diff --git a/tests/testthat/parse_comments/shebang_2-out.R b/tests/testthat/parse_comments/shebang_2-out.R index 8e8f5ac04..c47bec7a3 100644 --- a/tests/testthat/parse_comments/shebang_2-out.R +++ b/tests/testthat/parse_comments/shebang_2-out.R @@ -1,9 +1,9 @@ #!/usr/bin/env Rscript -# !/usr/bin/env Rscript +#!/usr/bin/env Rscript a <- 3 -# !/usr/bin /env Rscript -m --set "W" +#!/usr/bin /env Rscript -m --set "W" dd <- 33 -# !/usr/bin\ /env Rscript -m --set "W" +#!/usr/bin\ /env Rscript -m --set "W" c() -# !NEED TO REMOVE THIS +#!NEED TO REMOVE THIS diff --git a/tests/testthat/parse_comments/spacing_before-out.R b/tests/testthat/parse_comments/spacing_before-out.R index fee7cfd36..35bc82d2d 100644 --- a/tests/testthat/parse_comments/spacing_before-out.R +++ b/tests/testthat/parse_comments/spacing_before-out.R @@ -1,4 +1,5 @@ -a <- function(x) { # test +a <- function(x) { + # test # indnted comment } 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 743269425..77185f4f8 100644 --- a/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R +++ b/tests/testthat/parse_comments/spinning_code_chunk_headers-out.R @@ -1,9 +1,10 @@ -# A comment -a <- function() {} +#A comment +a <- function() { +} #+ chunk-label, opt1=value1 "chunk-content" #- chunk-label, opt1=value1 call(2, 3) -# 21 +#21 diff --git a/tests/testthat/parse_comments/with_indention-out.R b/tests/testthat/parse_comments/with_indention-out.R index 526802374..0ed4629aa 100644 --- a/tests/testthat/parse_comments/with_indention-out.R +++ b/tests/testthat/parse_comments/with_indention-out.R @@ -2,12 +2,15 @@ call( 1, call2( - 2, 3, - call3( # zero + 2, + 3, + call3( + # zero # one # two2 - 1, 2 # two - , 22 # comment + 1, + 2, # two + 22 # comment ), 5 ), #' A roxygen comment @@ -17,12 +20,10 @@ call( # new comment - a() # I think it gets boring # new_line here b(x, y, 7) # hidden? # comments belong to previous token. - # last comemnt EOF diff --git a/tests/testthat/parse_comments/within_spacing_with_force-out.R b/tests/testthat/parse_comments/within_spacing_with_force-out.R index 3c3c758b2..c4b481961 100644 --- a/tests/testthat/parse_comments/within_spacing_with_force-out.R +++ b/tests/testthat/parse_comments/within_spacing_with_force-out.R @@ -1,6 +1,6 @@ -####### A comment -#' roxygen +####### A comment +#'roxygen -# rox +#rox # a #-ish within a comment diff --git a/tests/testthat/parse_comments/within_spacing_without_force-out.R b/tests/testthat/parse_comments/within_spacing_without_force-out.R index bae46d588..c4b481961 100644 --- a/tests/testthat/parse_comments/within_spacing_without_force-out.R +++ b/tests/testthat/parse_comments/within_spacing_without_force-out.R @@ -1,6 +1,6 @@ ####### A comment -#' roxygen +#'roxygen -# rox +#rox # a #-ish within a comment diff --git a/tests/testthat/parse_comments/xaringan-out.R b/tests/testthat/parse_comments/xaringan-out.R index abd3dbcb0..8ac8a5b1a 100644 --- a/tests/testthat/parse_comments/xaringan-out.R +++ b/tests/testthat/parse_comments/xaringan-out.R @@ -4,7 +4,6 @@ foo( y = wt #<< ) - library(ggplot2) ggplot(aes(x, y), data) + diff --git a/tests/testthat/parsing/long_strings-out.R b/tests/testthat/parsing/long_strings-out.R index 9af67f0ee..3e9f51009 100644 --- a/tests/testthat/parsing/long_strings-out.R +++ b/tests/testthat/parsing/long_strings-out.R @@ -30,7 +30,7 @@ g <- "'test'" 99 + 1 -"test" +'test' 'test"ji"' # comment 1 diff --git a/tests/testthat/public-api/xyzaddin/addin_region-out.R b/tests/testthat/public-api/xyzaddin/addin_region-out.R index adc33e62d..3af23ca16 100644 --- a/tests/testthat/public-api/xyzaddin/addin_region-out.R +++ b/tests/testthat/public-api/xyzaddin/addin_region-out.R @@ -1 +1,3 @@ -fjkdsfa 2jy+wj/ 1 + 1= 5) - y = TRUE else - y = FALSE +if (x >= 5) y = TRUE else y = FALSE diff --git a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-out.R b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-out.R index b618f464b..420630f60 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-out.R +++ b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-out.R @@ -1,7 +1,3 @@ -x <- 5 +x = 5 -if (x >= 5) { - y <- TRUE -} else { - y <- FALSE -} +if (x >= 5) y = TRUE else y = FALSE diff --git a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-out.R b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-out.R index ecf0b9bc0..b3d97f7e4 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-out.R +++ b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-out.R @@ -1,9 +1,9 @@ -a <- b <- c <- d <- e <- f <- g <- 4 +a = b = c = d = e = f = g = 4 a <- 3 -b <- c <- d <- ey <- 4 +b = c = d = ey <- 4 a <- 3 -b <- c <- d <- ey <- 4 -ff <- 3 -b <- c <- d <- 3 -g <- 4 -ge <- 5 +b = c = d <- ey = 4 +ff = 3 +b = c = d = 3 +g = 4 +ge = 5 diff --git a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-out.R b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-out.R index 43d200b0e..5498e078b 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-out.R +++ b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-out.R @@ -1 +1 @@ -a <- b <- c <- d <- e <- f <- g <- 4 +a = b = c = d = e = f = g <- 4 diff --git a/tests/testthat/roxygen-examples-complete/01-one-function-example-last-proper-run-out.R b/tests/testthat/roxygen-examples-complete/01-one-function-example-last-proper-run-out.R index f8e0f4624..5087af071 100644 --- a/tests/testthat/roxygen-examples-complete/01-one-function-example-last-proper-run-out.R +++ b/tests/testthat/roxygen-examples-complete/01-one-function-example-last-proper-run-out.R @@ -3,5 +3,5 @@ #' Performs various substitutions in all `.R` files in a package #' (code and tests). #' Carefully examine the results after running this function! -#' @examples style_pkg(style = tidyverse_style, strict = TRUE) +#'@examples style_pkg(style= tidyverse_style, strict = TRUE) a <- 2 diff --git a/tests/testthat/roxygen-examples-complete/02-one-function-examples-last-proper-run-out.R b/tests/testthat/roxygen-examples-complete/02-one-function-examples-last-proper-run-out.R index 5d3d4873e..7cf13d129 100644 --- a/tests/testthat/roxygen-examples-complete/02-one-function-examples-last-proper-run-out.R +++ b/tests/testthat/roxygen-examples-complete/02-one-function-examples-last-proper-run-out.R @@ -6,7 +6,7 @@ #' @examples #' style_pkg(style = tidyverse_style, strict = TRUE) #' style_pkg( -#' scope = "line_breaks", -#' math_token_spacing = specify_math_token_spacing(zero = "'+'") +#' scope ="line_breaks", +#' math_token_spacing = specify_math_token_spacing( zero = "'+'") #' ) -a <- call +a = call diff --git a/tests/testthat/roxygen-examples-complete/03-one-function-example-not-last-proper-run-out.R b/tests/testthat/roxygen-examples-complete/03-one-function-example-not-last-proper-run-out.R index 5c4814dbf..199270aca 100644 --- a/tests/testthat/roxygen-examples-complete/03-one-function-example-not-last-proper-run-out.R +++ b/tests/testthat/roxygen-examples-complete/03-one-function-example-not-last-proper-run-out.R @@ -2,6 +2,6 @@ #' #' Performs various substitutions in all `.R` files in a package... #' Carefully examine the results after running this function! -#' @examples style_pkg(style = tidyverse_style, strict = TRUE) +#' @examples style_pkg(style = tidyverse_style , strict =TRUE) #' @name k a <- 2 diff --git a/tests/testthat/roxygen-examples-complete/04-one-function-examples-not-last-proper-run-out.R b/tests/testthat/roxygen-examples-complete/04-one-function-examples-not-last-proper-run-out.R index 81a774367..bdb18827b 100644 --- a/tests/testthat/roxygen-examples-complete/04-one-function-examples-not-last-proper-run-out.R +++ b/tests/testthat/roxygen-examples-complete/04-one-function-examples-not-last-proper-run-out.R @@ -5,7 +5,7 @@ #' @examples #' style_text("call( 1)", style = tidyverse_style, scope = "spaces") #' style_text("call( 1)", transformers = tidyverse_style(strict = TRUE)) -#' style_text(c("ab <- 3", "a <-3"), strict = FALSE) # keeps alignment of "<-" +#' style_text(c("ab <- 3","a <-3"), strict = FALSE) # keeps alignment of "<-" #' style_text(c("ab <- 3", "a <-3"), strict = TRUE) # drops alignment of "<-" #' @importFrom purrr partial #' @export diff --git a/tests/testthat/roxygen-examples-complete/05-multiple-function-examples-last-proper-run-out.R b/tests/testthat/roxygen-examples-complete/05-multiple-function-examples-last-proper-run-out.R index c35de4e6e..0b8c3748d 100644 --- a/tests/testthat/roxygen-examples-complete/05-multiple-function-examples-last-proper-run-out.R +++ b/tests/testthat/roxygen-examples-complete/05-multiple-function-examples-last-proper-run-out.R @@ -5,8 +5,8 @@ #' @examples #' style_text("call( 1)", style = tidyverse_style, scope = "spaces") #' style_text("call( 1)", transformers = tidyverse_style(strict = TRUE)) -#' style_text(c("ab <- 3", "a <-3"), strict = FALSE) # keeps alignment of "<-" -#' style_text(c("ab <- 3", "a <-3"), strict = TRUE) # drops alignment of "<-" +#' style_text(c("ab <- 3", "a <-3"), strict = FALSE)# keeps alignment of "<-" +#' style_text(c("ab <- 3", "a <-3"), strict = TRUE) # drops alignment of "<-" a <- call #' Prettify R source code @@ -15,4 +15,4 @@ a <- call #' (code and tests). #' Carefully examine the results after running this function! #' @examples style_pkg(style = tidyverse_style, strict = TRUE) -a <- 2 +a <- 2 diff --git a/tests/testthat/roxygen-examples-complete/06-multiple-function-examples-no-last-run-out.R b/tests/testthat/roxygen-examples-complete/06-multiple-function-examples-no-last-run-out.R index edda23f97..9b8c45923 100644 --- a/tests/testthat/roxygen-examples-complete/06-multiple-function-examples-no-last-run-out.R +++ b/tests/testthat/roxygen-examples-complete/06-multiple-function-examples-no-last-run-out.R @@ -2,10 +2,8 @@ #' #' Performs various substitutions in all `.R` files in a package... #' Carefully examine the results after running this function! -#' @examples style_pkg( -#' style = -#' tidyverse_style, strict = TRUE -#' ) +#' @examples style_pkg(style = +#' tidyverse_style, strict = TRUE) #' @name k a <- 2 @@ -17,10 +15,8 @@ a <- 2 #' style_text("call( 1)", style = tidyverse_style, scope = "spaces") #' style_text("call( 1)", transformers = tidyverse_style(strict = TRUE)) #' style_text( -#' c("ab <- 3", "a <-3"), -#' strict = FALSE -#' ) # keeps alignment of "<-" +#' c("ab <- 3", "a <-3"), strict = FALSE) # keeps alignment of "<-" #' style_text(c("ab <- 3", "a <-3"), strict = TRUE) # drops alignment of "<-" #' @importFrom purrr partial #' @export -a <- call +a <- call; diff --git a/tests/testthat/roxygen-examples-complete/07-roxygen-no-dontrun-out.R b/tests/testthat/roxygen-examples-complete/07-roxygen-no-dontrun-out.R index 993d3eaa3..e7b4a67e6 100644 --- a/tests/testthat/roxygen-examples-complete/07-roxygen-no-dontrun-out.R +++ b/tests/testthat/roxygen-examples-complete/07-roxygen-no-dontrun-out.R @@ -9,24 +9,23 @@ #' @inheritSection style_pkg Roundtrip Validation #' @examples #' # the following is identical but the former is more convenient: -#' file <- tempfile("styler", -#' fileext = ".R" -#' ) +#' file<- tempfile("styler", +#' fileext = ".R") #' xfun::write_utf8("1++1", file) #' style_file( -#' file, -#' style = tidyverse_style, strict = TRUE -#' ) +#' file, style = tidyverse_style, strict = TRUE) #' style_file(file, transformers = tidyverse_style(strict = TRUE)) #' xfun::read_utf8(file) #' unlink(file2) #' @family stylers #' @export -style_file <- function(path, - ..., - style = tidyverse_style, - transformers = style(...), - include_roxygen_examples = TRUE) { +style_file <- function( + path, + ..., + style = tidyverse_style, + transformers = style(...), + include_roxygen_examples = TRUE +) { changed <- withr::with_dir( dirname(path), transform_files(basename(path), transformers) diff --git a/tests/testthat/roxygen-examples-complete/08-roxygen-dontrun-out.R b/tests/testthat/roxygen-examples-complete/08-roxygen-dontrun-out.R index 8e92f97cd..e44d4ec34 100644 --- a/tests/testthat/roxygen-examples-complete/08-roxygen-dontrun-out.R +++ b/tests/testthat/roxygen-examples-complete/08-roxygen-dontrun-out.R @@ -9,36 +9,29 @@ #' @inheritSection style_pkg Roundtrip Validation #' @examples #' # the following is identical but the former is more convenient: -#' file <- tempfile("styler", -#' fileext = ".R" -#' ) -#' \dontrun{ -#' xfun::write_utf8("1++1", file) -#' } +#' file<- tempfile("styler", +#' fileext = ".R") +#' \dontrun{xfun::write_utf8("1++1",file)} #' style_file( -#' file, -#' style = tidyverse_style, strict = TRUE -#' ) +#' file, style = tidyverse_style, strict = TRUE) #' style_file(file, transformers = tidyverse_style(strict = TRUE)) #' xfun::read_utf8(file) +#' \dontrun{unlink(file2)} #' \dontrun{ -#' unlink(file2) -#' } -#' \dontrun{ -#' { -#' x +#' { x #' } #' unlink(file2) #' } #' @family stylers #' @export style_file <- function(path, - ..., + ... , style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE) { - changed <- withr::with_dir( - dirname(path), + changed<- withr::with_dir( + dirname(path + ), transform_files(basename(path), transformers) ) invisible(changed) diff --git a/tests/testthat/roxygen-examples-complete/09-styler-r-ui-style-string-multiple-out.R b/tests/testthat/roxygen-examples-complete/09-styler-r-ui-style-string-multiple-out.R index 743afba45..3fe6ac77b 100644 --- a/tests/testthat/roxygen-examples-complete/09-styler-r-ui-style-string-multiple-out.R +++ b/tests/testthat/roxygen-examples-complete/09-styler-r-ui-style-string-multiple-out.R @@ -14,9 +14,7 @@ #' # the following is identical but the former is more convenient: #' style_text("a<-3++1", style = tidyverse_style, strict = TRUE) #' @examples -#' \dontrun{ -#' style_text("a<-3++1", transformers = tidyverse_style(strict = TRUE)) -#' } +#' \dontrun{style_text("a<-3++1", transformers = tidyverse_style(strict = TRUE))} #' @export style_text <- function(text, ..., diff --git a/tests/testthat/roxygen-examples-complete/10-styler-r-ui-out.R b/tests/testthat/roxygen-examples-complete/10-styler-r-ui-out.R index a7cbf3aca..be1243525 100644 --- a/tests/testthat/roxygen-examples-complete/10-styler-r-ui-out.R +++ b/tests/testthat/roxygen-examples-complete/10-styler-r-ui-out.R @@ -65,38 +65,54 @@ NULL #' ) #' } #' @export -style_pkg <- function(pkg = ".", - ..., - style = tidyverse_style, - transformers = style(...), - filetype = "R", - exclude_files = "R/RcppExports.R", - include_roxygen_examples = TRUE) { +style_pkg <- function( + pkg = ".", + ..., + style = tidyverse_style, + transformers = style(...), + filetype = "R", + exclude_files = "R/RcppExports.R", + include_roxygen_examples = TRUE +) { pkg_root <- rprojroot::find_package_root_file(path = pkg) - changed <- withr::with_dir(pkg_root, prettify_pkg( - transformers, filetype, exclude_files, include_roxygen_examples - )) + changed <- withr::with_dir( + pkg_root, + prettify_pkg( + transformers, + filetype, + exclude_files, + include_roxygen_examples + ) + ) invisible(changed) } -prettify_pkg <- function(transformers, - filetype, - exclude_files, - include_roxygen_examples) { +prettify_pkg <- function( + transformers, + filetype, + exclude_files, + include_roxygen_examples +) { filetype <- set_and_assert_arg_filetype(filetype) r_files <- vignette_files <- readme <- NULL if ("\\.r" %in% filetype) { r_files <- dir( - path = c("R", "tests", "data-raw"), pattern = "\\.r$", - ignore.case = TRUE, recursive = TRUE, full.names = TRUE + path = c("R", "tests", "data-raw"), + pattern = "\\.r$", + ignore.case = TRUE, + recursive = TRUE, + full.names = TRUE ) } if ("\\.rmd" %in% filetype) { vignette_files <- dir( - path = "vignettes", pattern = "\\.rmd$", - ignore.case = TRUE, recursive = TRUE, full.names = TRUE + path = "vignettes", + pattern = "\\.rmd$", + ignore.case = TRUE, + recursive = TRUE, + full.names = TRUE ) readme <- dir(pattern = "^readme\\.rmd$", ignore.case = TRUE) } @@ -105,7 +121,6 @@ prettify_pkg <- function(transformers, transform_files(files, transformers, include_roxygen_examples) } - #' Style a string #' #' Styles a character vector. Each element of the character vector corresponds @@ -123,11 +138,13 @@ prettify_pkg <- function(transformers, #' style_text("a<-3++1", style = tidyverse_style, strict = TRUE) #' style_text("a<-3++1", transformers = tidyverse_style(strict = TRUE)) #' @export -style_text <- function(text, - ..., - style = tidyverse_style, - transformers = style(...), - include_roxygen_examples = TRUE) { +style_text <- function( + text, + ..., + style = tidyverse_style, + transformers = style(...), + include_roxygen_examples = TRUE +) { transformer <- make_transformer(transformers, include_roxygen_examples) styled_text <- transformer(text) construct_vertical(styled_text) @@ -150,17 +167,24 @@ style_text <- function(text, #' style_dir(file_type = "r") #' } #' @export -style_dir <- function(path = ".", - ..., - style = tidyverse_style, - transformers = style(...), - filetype = "R", - recursive = TRUE, - exclude_files = NULL, - include_roxygen_examples = TRUE) { +style_dir <- function( + path = ".", + ..., + style = tidyverse_style, + transformers = style(...), + filetype = "R", + recursive = TRUE, + exclude_files = NULL, + include_roxygen_examples = TRUE +) { changed <- withr::with_dir( - path, prettify_any( - transformers, filetype, recursive, exclude_files, include_roxygen_examples + path, + prettify_any( + transformers, + filetype, + recursive, + exclude_files, + include_roxygen_examples ) ) invisible(changed) @@ -173,17 +197,24 @@ style_dir <- function(path = ".", #' @param recursive A logical value indicating whether or not files in subdirectories #' should be styled as well. #' @keywords internal -prettify_any <- function(transformers, - filetype, - recursive, - exclude_files, - include_roxygen_examples) { +prettify_any <- function( + transformers, + filetype, + recursive, + exclude_files, + include_roxygen_examples +) { files <- dir( - path = ".", pattern = map_filetype_to_pattern(filetype), - ignore.case = TRUE, recursive = recursive, full.names = TRUE + path = ".", + pattern = map_filetype_to_pattern(filetype), + ignore.case = TRUE, + recursive = recursive, + full.names = TRUE ) transform_files( - setdiff(files, exclude_files), transformers, include_roxygen_examples + setdiff(files, exclude_files), + transformers, + include_roxygen_examples ) } @@ -209,11 +240,13 @@ prettify_any <- function(transformers, #' unlink(file) #' @family stylers #' @export -style_file <- function(path, - ..., - style = tidyverse_style, - transformers = style(...), - include_roxygen_examples = TRUE) { +style_file <- function( + path, + ..., + style = tidyverse_style, + transformers = style(...), + include_roxygen_examples = TRUE +) { changed <- withr::with_dir( dirname(path), transform_files(basename(path), transformers, include_roxygen_examples) diff --git a/tests/testthat/roxygen-examples-complete/11-start-with-dontrun-out.R b/tests/testthat/roxygen-examples-complete/11-start-with-dontrun-out.R index 35a804639..e9b6732ff 100644 --- a/tests/testthat/roxygen-examples-complete/11-start-with-dontrun-out.R +++ b/tests/testthat/roxygen-examples-complete/11-start-with-dontrun-out.R @@ -10,16 +10,24 @@ #' ) #' } #' @export -style_pkg <- function(pkg = ".", - ..., - style = tidyverse_style, - transformers = style(...), - filetype = "R", - exclude_files = "R/RcppExports.R", - include_roxygen_examples = TRUE) { +style_pkg <- function( + pkg = ".", + ..., + style = tidyverse_style, + transformers = style(...), + filetype = "R", + exclude_files = "R/RcppExports.R", + include_roxygen_examples = TRUE +) { pkg_root <- rprojroot::find_package_root_file(path = pkg) - changed <- withr::with_dir(pkg_root, prettify_pkg( - transformers, filetype, exclude_files, include_roxygen_examples - )) + changed <- withr::with_dir( + pkg_root, + prettify_pkg( + transformers, + filetype, + exclude_files, + include_roxygen_examples + ) + ) invisible(changed) } diff --git a/tests/testthat/roxygen-examples-complete/12-dontshow-dontrun-donttest-out.R b/tests/testthat/roxygen-examples-complete/12-dontshow-dontrun-donttest-out.R index 3a260d018..52f38c0fa 100644 --- a/tests/testthat/roxygen-examples-complete/12-dontshow-dontrun-donttest-out.R +++ b/tests/testthat/roxygen-examples-complete/12-dontshow-dontrun-donttest-out.R @@ -24,13 +24,15 @@ #' } #' @importFrom purrr compact #' @export -create_style_guide <- function(initialize = default_style_guide_attributes, - line_break = NULL, - space = NULL, - token = NULL, - indention = NULL, - use_raw_indention = FALSE, - reindention = tidyverse_reindention()) { +create_style_guide <- function( + initialize = default_style_guide_attributes, + line_break = NULL, + space = NULL, + token = NULL, + indention = NULL, + use_raw_indention = FALSE, + reindention = tidyverse_reindention() +) { list( # transformer functions initialize = list(initialize), @@ -45,7 +47,6 @@ create_style_guide <- function(initialize = default_style_guide_attributes, map(compact) } - #' Create a style guide #' #' @param reindention A list of parameters for regex re-indention, most @@ -58,29 +59,29 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' } #' @examples #' \dontshow{ -#' { -#' x +#' {x #' } #' } #' set_line_break_before_curly_opening_style <- function() { -#' create_style_guide(line_break = list(set_line_break_before_curly_opening)) +#' create_style_guide(line_break= list(set_line_break_before_curly_opening)) #' } #' @examples -#' \donttest{ -#' style_text("a <- function(x) { x } +#' \donttest{style_text("a <- function(x) { x } #' ", style = set_line_break_before_curly_opening_style) -#' } +#' } #' @importFrom purrr compact #' @export -create_style_guide <- function(initialize = default_style_guide_attributes, - line_break = NULL, - space = NULL, - token = NULL, - indention = NULL, - use_raw_indention = FALSE, - reindention = tidyverse_reindention()) { +create_style_guide <- function( + initialize = default_style_guide_attributes, + line_break = NULL, + space = NULL, + token = NULL, + indention = NULL, + use_raw_indention = FALSE, + reindention = tidyverse_reindention() +) { list( - # transformer functions + #transformer functions initialize = list(initialize), line_break, space, diff --git a/tests/testthat/roxygen-examples-complete/12-fun-decs-in-examples-out.R b/tests/testthat/roxygen-examples-complete/12-fun-decs-in-examples-out.R index 0188f0cca..aa4c21362 100644 --- a/tests/testthat/roxygen-examples-complete/12-fun-decs-in-examples-out.R +++ b/tests/testthat/roxygen-examples-complete/12-fun-decs-in-examples-out.R @@ -1,3 +1,4 @@ + #' Create a style guide #' #' @param reindention A list of parameters for regex re-indention, most @@ -46,13 +47,13 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' Another #' @examples #' \donttest{ -#' op <- pd_flat$token %in% "'('" +#' op= pd_flat$token %in% "'('" #' } #' \donttest{ #' op <- pd_flat$token %in% "')'" #' } #' \donttest{ -#' op <- pd_flat$token %in% "(" +#' op <- pd_flat$token %in% "(" #' } #' \donttest{ #' op <- pd_flat$token %in% ")" @@ -61,16 +62,16 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' op <- pd_flat$token %in% "{" #' } #' \donttest{ -#' op <- pd_flat$token %in% "}" +#' op<- pd_flat$token %in% "}" #' } -#' op <- pd_flat$token %in% "'['" +#' op <-pd_flat$token %in% "'['" #' \donttest{ #' op <- pd_flat$token %in% "']'" #' } #' \donttest{ -#' op <- pd_flat$token %in% "[" +#' op <- pd_flat$token%in% "[" #' } #' \donttest{ -#' op <- pd_flat$token %in% "]" +#' op <- pd_flat$token %in%"]" #' } NULL diff --git a/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R b/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R index 460600158..1af04bba3 100644 --- a/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R +++ b/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R @@ -1,3 +1,4 @@ + #' Create a style guide #' #' @param reindention A list of parameters for regex re-indention, most @@ -9,14 +10,21 @@ #' # two #' #' +#' +#' #' ( -#' # more -#' a <- 3 +#' +#' +#' # more +#' a <- 3 +#' #' ) #' # a comment #' \dontrun{ #' { -#' x +#' +#' x +#' #' } #' #' y # hi @@ -24,6 +32,7 @@ #' # more #' #' a <- 3 +#' #' } #' @importFrom purrr compact #' @export diff --git a/tests/testthat/roxygen-examples-complete/14-pipe-dontrun-out.R b/tests/testthat/roxygen-examples-complete/14-pipe-dontrun-out.R index 6915ef964..ffbb6e1ec 100644 --- a/tests/testthat/roxygen-examples-complete/14-pipe-dontrun-out.R +++ b/tests/testthat/roxygen-examples-complete/14-pipe-dontrun-out.R @@ -3,13 +3,13 @@ #' x #' @examples #' a %>% -#' x(b = 3) %>% +#' x(b =3) %>% #' ff() #' \dontrun{ #' style_pkg( #' scope = "line_breaks", #' math_token_spacing = specfy_math_token_spacing(zero = "'+'") -#' ) %>% +#' )%>% #' there() #' } #' call("\\n", x = 3) diff --git a/tests/testthat/roxygen-examples-complete/15-roxygen-dontrun-indention-out.R b/tests/testthat/roxygen-examples-complete/15-roxygen-dontrun-indention-out.R index ae29dec1f..d9540f770 100644 --- a/tests/testthat/roxygen-examples-complete/15-roxygen-dontrun-indention-out.R +++ b/tests/testthat/roxygen-examples-complete/15-roxygen-dontrun-indention-out.R @@ -1,24 +1,21 @@ #' Bla #' #' @examples -#' \dontrun{ -#' xfun::write_utf8("1++1", file) -#' } +#' \dontrun{xfun::write_utf8("1++1",file)} #' style_file( #' file, -#' style = tidyverse_style, strict = TRUE +#' style = tidyverse_style,strict =TRUE #' ) -#' \dontrun{ -#' style_file( +#' \dontrun{style_file( #' file, -#' style = tidyverse_style, strict = TRUE +#' style = tidyverse_style,strict =TRUE #' ) #' } #' if (TRUE) #' return(X) #' -#' if (TRUE) -#' return(X) -#' if (TRUE) -#' return(X) +#' if (TRUE ) +#' return(X ) +#'if (TRUE ) +#'return(X ) x <- y diff --git a/tests/testthat/roxygen-examples-complete/17-two-no-non-comment-out.R b/tests/testthat/roxygen-examples-complete/17-two-no-non-comment-out.R index d68e7623d..514cf3433 100644 --- a/tests/testthat/roxygen-examples-complete/17-two-no-non-comment-out.R +++ b/tests/testthat/roxygen-examples-complete/17-two-no-non-comment-out.R @@ -1,12 +1,12 @@ #' @examples -#' my_fun <- function() { +#' my_fun <- function() { #' print("hello world!") #' } #' # before this comment is a left-over space #' another_function <- function() NULL #' @examples -#' my_fun <- function() { +#' my_fun <- function() { #' print("hello world!") #' } #' # before this comment is a left-over space diff --git a/tests/testthat/roxygen-examples-complete/18-no-non-comment-out.R b/tests/testthat/roxygen-examples-complete/18-no-non-comment-out.R index 433d122ab..ee22aef1e 100644 --- a/tests/testthat/roxygen-examples-complete/18-no-non-comment-out.R +++ b/tests/testthat/roxygen-examples-complete/18-no-non-comment-out.R @@ -1,5 +1,5 @@ #' @examples -#' my_fun <- function() { +#' my_fun <- function() { #' print("hello world!") #' } #' # before this comment is a left-over space diff --git a/tests/testthat/roxygen-examples-complete/19-escaped-slash-out.R b/tests/testthat/roxygen-examples-complete/19-escaped-slash-out.R index a7502d319..00509bacf 100644 --- a/tests/testthat/roxygen-examples-complete/19-escaped-slash-out.R +++ b/tests/testthat/roxygen-examples-complete/19-escaped-slash-out.R @@ -1,25 +1,24 @@ #' Data frame and Tables Pretty Formatting #' #' @examples -#' c("\nA \\nyellow \\\nline", "yellow") -#' c("\ A \\ nyellow \\\ nline", "yellow") +#' c("\nA \\nyellow \\\nline", "yellow") +#' c("\ A \\ nyellow \\\ nline", "yellow") #' \dontrun{ -#' c("\nA \\nyellow \\\nline", "yellow") -#' c("\ A \\ nyellow \\\ nline", "yellow") +#' c("\nA \\nyellow \\\nline", "yellow") +#' c("\ A \\ nyellow \\\ nline", "yellow") #' } #' @export NULL - one <- "\t" -two <- "\\t" -three <- "\\\t" -four <- "\\\\t" -five <- "\\\\\t" -six <- "\\\\\\t" +two = "\\t" +three = "\\\t" +four = "\\\\t" +five = "\\\\\t" +six = "\\\\\\t" -two <- "\\" -four <- "\\\\" -five <- "\\\\." -six <- "\\\\\\w" -six <- "\\\\\\" +two = "\\" +four = "\\\\" +five = "\\\\." +six = "\\\\\\w" +six = "\\\\\\" diff --git a/tests/testthat/roxygen-examples-complete/20-exampleIf-simple-out.R b/tests/testthat/roxygen-examples-complete/20-exampleIf-simple-out.R index 34427f9a0..1541e5ed3 100644 --- a/tests/testthat/roxygen-examples-complete/20-exampleIf-simple-out.R +++ b/tests/testthat/roxygen-examples-complete/20-exampleIf-simple-out.R @@ -3,7 +3,7 @@ #' Style code according to the tidyverse style guide. #' @family style_guides #' @examplesIf TRUE -#' c() +#' c( ) #' @importFrom purrr partial #' @export -a <- call +a <- call; diff --git a/tests/testthat/roxygen-examples-complete/21-exampleIf-multiple-out.R b/tests/testthat/roxygen-examples-complete/21-exampleIf-multiple-out.R index b06074393..5af339a2b 100644 --- a/tests/testthat/roxygen-examples-complete/21-exampleIf-multiple-out.R +++ b/tests/testthat/roxygen-examples-complete/21-exampleIf-multiple-out.R @@ -3,9 +3,9 @@ #' Style code according to the tidyverse style guide. #' @family style_guides #' @examplesIf TRUE -#' c() +#' c( ) #' @examplesIf TRUE -#' x <- 2 +#' x=2 #' @importFrom purrr partial #' @export -a <- call +a <- call; diff --git a/tests/testthat/roxygen-examples-complete/22-exampleIf-example-mixed-out.R b/tests/testthat/roxygen-examples-complete/22-exampleIf-example-mixed-out.R index 887d501fa..ea4b22613 100644 --- a/tests/testthat/roxygen-examples-complete/22-exampleIf-example-mixed-out.R +++ b/tests/testthat/roxygen-examples-complete/22-exampleIf-example-mixed-out.R @@ -3,9 +3,9 @@ #' Style code according to the bli blauuu2 guide. #' @family some #' @examplesIf TRUE -#' c() +#' c( ) #' @examples -#' x <- 2 +#' x=2 #' @importFrom purrr partial #' @export x <- 3 @@ -15,10 +15,8 @@ x <- 3 #' Style code according to the bli blauuu2 guide. #' @family not #' @examples -#' x <- 2 +#' x=2 #' @examplesIf TRUE -#' c() +#' c( ) #' @export -function() { - NULL -} +function() NULL diff --git a/tests/testthat/roxygen-examples-complete/23-exampleIf-multiline-cond-out.R b/tests/testthat/roxygen-examples-complete/23-exampleIf-multiline-cond-out.R index 1c08dcd61..8d96ab40a 100644 --- a/tests/testthat/roxygen-examples-complete/23-exampleIf-multiline-cond-out.R +++ b/tests/testthat/roxygen-examples-complete/23-exampleIf-multiline-cond-out.R @@ -3,9 +3,9 @@ #' fjd;kzj lorem impesum #' @family xj2lkj #' @examplesIf { -#' "this-is-a-cond" +#' 'this-is-a-cond' #' } -#' c() +#' c( ) #' @importFrom purrr partial #' @export x <- 3 @@ -15,7 +15,7 @@ x <- 3 #' #' fjd;kzj lorem impesum #' @examplesIf { -#' "this-is-a-cond" %>% c() +#' 'this-is-a-cond' %>% c() #' } -#' c() +#' c( ) x <- 3 diff --git a/tests/testthat/roxygen-examples-complete/24-exampleIf-spacing-out.R b/tests/testthat/roxygen-examples-complete/24-exampleIf-spacing-out.R index 50ea30701..5adc13a6e 100644 --- a/tests/testthat/roxygen-examples-complete/24-exampleIf-spacing-out.R +++ b/tests/testthat/roxygen-examples-complete/24-exampleIf-spacing-out.R @@ -2,27 +2,26 @@ #' #' Style code according to the bli blauuu2 guide. #' @family some -#' @examplesIf TRUE # tab -#' c() +#' @examplesIf TRUE # tab +#' c( ) #' @examplesIf TRUE -#' c() -#' @examplesIf TRUE -#' c() +#' c( ) +#' @examplesIf TRUE +#' c( ) #' @importFrom purrr partial #' @export x <- 3 - #' Now with needs_rd_emulation #' #' Style code according to the bli blauuu2 guide. #' @family some -#' @examplesIf TRUE # tab -#' a %>% b() -#' @examplesIf TRUE -#' a %>% d() +#' @examplesIf TRUE # tab +#' a %>%b #' @examplesIf TRUE -#' a %>% c() +#' a %>%d +#' @examplesIf TRUE +#' a %>%c #' @importFrom purrr partial #' @export x <- 33 diff --git a/tests/testthat/roxygen-examples-complete/25-ordinary-comment-in-example-out.R b/tests/testthat/roxygen-examples-complete/25-ordinary-comment-in-example-out.R index b3fa7b05a..8132ad6f0 100644 --- a/tests/testthat/roxygen-examples-complete/25-ordinary-comment-in-example-out.R +++ b/tests/testthat/roxygen-examples-complete/25-ordinary-comment-in-example-out.R @@ -5,7 +5,6 @@ #' 1 + 1 NULL - #' Example # Random comment #' Roxygen @@ -61,8 +60,7 @@ NULL # There #' \dontrun{ #' 1 + 1 -#' # comment -#' } +#' } # comment # more NULL @@ -97,8 +95,8 @@ NULL # There #' \dontrun{ #' call( -#' # comment -#' 1 + 1 +# comment +#' 1 + 1 #' ) #' } # more @@ -110,14 +108,13 @@ NULL #' df %>% func() func <- function() NULL - #' Hi # Comment #' @examples #' 1 + 1 # this # this -# this +#this # thi3 #' c() NULL @@ -128,7 +125,7 @@ NULL #' 1 + 1 # this # this -# this +#this # thi3 #' c() NULL diff --git a/tests/testthat/roxygen-examples-complete/26-empty-trailing-lines-out.R b/tests/testthat/roxygen-examples-complete/26-empty-trailing-lines-out.R index dc44475aa..5808ced9c 100644 --- a/tests/testthat/roxygen-examples-complete/26-empty-trailing-lines-out.R +++ b/tests/testthat/roxygen-examples-complete/26-empty-trailing-lines-out.R @@ -13,6 +13,12 @@ NULL #' @examples #' 2 + 1 #' +#' +#' +#' +#' +#' +#' NULL @@ -24,9 +30,11 @@ NULL NULL + #' this #' #' empty line after example #' @examples #' 2 + 1 + NULL diff --git a/tests/testthat/roxygen-examples-complete/27-no-code-block-after-example-out.R b/tests/testthat/roxygen-examples-complete/27-no-code-block-after-example-out.R index 409108981..43a440f7b 100644 --- a/tests/testthat/roxygen-examples-complete/27-no-code-block-after-example-out.R +++ b/tests/testthat/roxygen-examples-complete/27-no-code-block-after-example-out.R @@ -4,7 +4,8 @@ #' is stuff #' #' @examples -#' 1 + 1 +#' 1+1 + # nolint start #' @examplesIf long_condition_line #' 32 / 3 diff --git a/tests/testthat/roxygen-examples-complete/28-end-not-blank-out.R b/tests/testthat/roxygen-examples-complete/28-end-not-blank-out.R index beb09105b..75f99fa88 100644 --- a/tests/testthat/roxygen-examples-complete/28-end-not-blank-out.R +++ b/tests/testthat/roxygen-examples-complete/28-end-not-blank-out.R @@ -1,3 +1,3 @@ #' @export #' @examples -#' x <- 1 +#' x=1 diff --git a/tests/testthat/roxygen-examples-complete/29-multiple-empty-lines-in-example-out.R b/tests/testthat/roxygen-examples-complete/29-multiple-empty-lines-in-example-out.R index 1061151d6..578ca3363 100644 --- a/tests/testthat/roxygen-examples-complete/29-multiple-empty-lines-in-example-out.R +++ b/tests/testthat/roxygen-examples-complete/29-multiple-empty-lines-in-example-out.R @@ -7,6 +7,5 @@ #' #' @examples #' \dontrun{ -#' #' } 2 diff --git a/tests/testthat/roxygen-examples-complete/30-multiple-empty-lines-between-out.R b/tests/testthat/roxygen-examples-complete/30-multiple-empty-lines-between-out.R index 8871734b8..578ca3363 100644 --- a/tests/testthat/roxygen-examples-complete/30-multiple-empty-lines-between-out.R +++ b/tests/testthat/roxygen-examples-complete/30-multiple-empty-lines-between-out.R @@ -3,11 +3,9 @@ #' @examples 1 - #' Empty line in examples #' #' @examples #' \dontrun{ -#' #' } 2 diff --git a/tests/testthat/roxygen-examples-identify/20-exampleIf-simple-out.R b/tests/testthat/roxygen-examples-identify/20-exampleIf-simple-out.R new file mode 100644 index 000000000..1541e5ed3 --- /dev/null +++ b/tests/testthat/roxygen-examples-identify/20-exampleIf-simple-out.R @@ -0,0 +1,9 @@ +#' The tidyverse style +#' +#' Style code according to the tidyverse style guide. +#' @family style_guides +#' @examplesIf TRUE +#' c( ) +#' @importFrom purrr partial +#' @export +a <- call; diff --git a/tests/testthat/roxygen-examples-identify/21-exampleIf-multiple-out.R b/tests/testthat/roxygen-examples-identify/21-exampleIf-multiple-out.R new file mode 100644 index 000000000..5af339a2b --- /dev/null +++ b/tests/testthat/roxygen-examples-identify/21-exampleIf-multiple-out.R @@ -0,0 +1,11 @@ +#' The tidyverse style +#' +#' Style code according to the tidyverse style guide. +#' @family style_guides +#' @examplesIf TRUE +#' c( ) +#' @examplesIf TRUE +#' x=2 +#' @importFrom purrr partial +#' @export +a <- call; diff --git a/tests/testthat/scope-AsIs/scope_indention-out.R b/tests/testthat/scope-AsIs/scope_indention-out.R index fe39c346a..a3ae26d99 100644 --- a/tests/testthat/scope-AsIs/scope_indention-out.R +++ b/tests/testthat/scope-AsIs/scope_indention-out.R @@ -1,11 +1,14 @@ # not adding line-break -if (x) {1+1++1} else{3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # not removing line-break # FIXME If linebreaks are not touched: Do not indent token-dependent before '{' -test_that("x", - { - my_test(call) +test_that("x", { + my_test(call) }) # do not replace assignment @@ -13,7 +16,9 @@ a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-AsIs/scope_indention_tokens-out.R b/tests/testthat/scope-AsIs/scope_indention_tokens-out.R index 47df4b7fc..15b55f3c0 100644 --- a/tests/testthat/scope-AsIs/scope_indention_tokens-out.R +++ b/tests/testthat/scope-AsIs/scope_indention_tokens-out.R @@ -1,15 +1,17 @@ # adding line-break -if (x) {1 + 1 + +1} else {3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # removing line-break -test_that("x", - { - my_test(call) +test_that("x", { + my_test(call) }) - # do not replace assignment -a <-3 +a = 3 data_frame(a = 3) # do not resolve semicolon @@ -19,5 +21,5 @@ c # don't add brackets in pipes a %>% - b() %>% - c() + b %>% + c diff --git a/tests/testthat/scope-AsIs/scope_line_breaks-out.R b/tests/testthat/scope-AsIs/scope_line_breaks-out.R index c5dd80a84..15b55f3c0 100644 --- a/tests/testthat/scope-AsIs/scope_line_breaks-out.R +++ b/tests/testthat/scope-AsIs/scope_line_breaks-out.R @@ -1,22 +1,23 @@ # adding line-break if (x) { -1 + 1 + +1 + 1 + 1 + +1 } else { -3 + 3 } # removing line-break -test_that("x", { - my_test(call) - }) - +test_that("x", { + my_test(call) +}) # do not replace assignment a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-AsIs/scope_none-out.R b/tests/testthat/scope-AsIs/scope_none-out.R index 2c770501f..38121db88 100644 --- a/tests/testthat/scope-AsIs/scope_none-out.R +++ b/tests/testthat/scope-AsIs/scope_none-out.R @@ -2,29 +2,40 @@ #' #' @param x a parameter. #' indented comments -a<- function(x){ - test_that("I want to test",{ - out <- c(1,c( - 22 +1 - )) +a <- function(x) { + test_that("I want to test", { + out <- c( + 1, + c( + 22 + 1 + ) + ) if (x > 10) { - for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%? + for (x in 22) { + # FIXME in operator only to be surrounded by one space. What about %in%? prin(x) } } - } ) + }) #we like comments too - c(list(x + 2), - c( c( - 26 ^ 2, # FIXME ^ operator has to be surrounded by one space (or none?!), never multiple - 8, - 7 - ) ) ) + c( + list(x + 2), + c( + c( + 26^2, # FIXME ^ operator has to be surrounded by one space (or none?!), never multiple + 8, + 7 + ) + ) + ) call( - 1, 2, - 23+Inf - 99, call( + 1, + 2, + 23 + Inf - 99, + call( 16 - )) + ) + ) } # comments everywhere diff --git a/tests/testthat/scope-AsIs/scope_spaces-out.R b/tests/testthat/scope-AsIs/scope_spaces-out.R index 4036923a9..809766f83 100644 --- a/tests/testthat/scope-AsIs/scope_spaces-out.R +++ b/tests/testthat/scope-AsIs/scope_spaces-out.R @@ -1,4 +1,4 @@ a <- function() { - 1 + 1 -d = 3 - } + 1 + 1 + d = 3 +} diff --git a/tests/testthat/scope-AsIs/scope_spaces_indention-out.R b/tests/testthat/scope-AsIs/scope_spaces_indention-out.R index cb3b1ebea..a3ae26d99 100644 --- a/tests/testthat/scope-AsIs/scope_spaces_indention-out.R +++ b/tests/testthat/scope-AsIs/scope_spaces_indention-out.R @@ -1,11 +1,14 @@ # not adding line-break -if (x) {1 + 1 + +1} else {3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # not removing line-break # FIXME If linebreaks are not touched: Do not indent token-dependent before '{' -test_that("x", - { - my_test(call) +test_that("x", { + my_test(call) }) # do not replace assignment @@ -13,7 +16,9 @@ a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-AsIs/scope_spaces_line_breaks-out.R b/tests/testthat/scope-AsIs/scope_spaces_line_breaks-out.R index 721ffc0af..15b55f3c0 100644 --- a/tests/testthat/scope-AsIs/scope_spaces_line_breaks-out.R +++ b/tests/testthat/scope-AsIs/scope_spaces_line_breaks-out.R @@ -1,22 +1,23 @@ # adding line-break if (x) { -1 + 1 + +1 + 1 + 1 + +1 } else { -3 + 3 } # removing line-break test_that("x", { - my_test(call) - }) - + my_test(call) +}) # do not replace assignment a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-AsIs/scope_spaces_tokens-out.R b/tests/testthat/scope-AsIs/scope_spaces_tokens-out.R index 4e71757fd..15b55f3c0 100644 --- a/tests/testthat/scope-AsIs/scope_spaces_tokens-out.R +++ b/tests/testthat/scope-AsIs/scope_spaces_tokens-out.R @@ -1,15 +1,17 @@ # adding line-break -if (x) {1 + 1 + +1} else {3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # removing line-break -test_that("x", - { - my_test(call) - }) - +test_that("x", { + my_test(call) +}) # do not replace assignment -a <- 3 +a = 3 data_frame(a = 3) # do not resolve semicolon @@ -19,5 +21,5 @@ c # don't add brackets in pipes a %>% - b() %>% - c() + b %>% + c diff --git a/tests/testthat/scope-AsIs/scope_tokens-out.R b/tests/testthat/scope-AsIs/scope_tokens-out.R index 4e71757fd..15b55f3c0 100644 --- a/tests/testthat/scope-AsIs/scope_tokens-out.R +++ b/tests/testthat/scope-AsIs/scope_tokens-out.R @@ -1,15 +1,17 @@ # adding line-break -if (x) {1 + 1 + +1} else {3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # removing line-break -test_that("x", - { - my_test(call) - }) - +test_that("x", { + my_test(call) +}) # do not replace assignment -a <- 3 +a = 3 data_frame(a = 3) # do not resolve semicolon @@ -19,5 +21,5 @@ c # don't add brackets in pipes a %>% - b() %>% - c() + b %>% + c diff --git a/tests/testthat/scope-character/scope_indention-out.R b/tests/testthat/scope-character/scope_indention-out.R index cb3b1ebea..a3ae26d99 100644 --- a/tests/testthat/scope-character/scope_indention-out.R +++ b/tests/testthat/scope-character/scope_indention-out.R @@ -1,11 +1,14 @@ # not adding line-break -if (x) {1 + 1 + +1} else {3} +if (x) { + 1 + 1 + +1 +} else { + 3 +} # not removing line-break # FIXME If linebreaks are not touched: Do not indent token-dependent before '{' -test_that("x", - { - my_test(call) +test_that("x", { + my_test(call) }) # do not replace assignment @@ -13,7 +16,9 @@ a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-character/scope_line_breaks-out.R b/tests/testthat/scope-character/scope_line_breaks-out.R index 6a8af3216..15b55f3c0 100644 --- a/tests/testthat/scope-character/scope_line_breaks-out.R +++ b/tests/testthat/scope-character/scope_line_breaks-out.R @@ -10,13 +10,14 @@ test_that("x", { my_test(call) }) - # do not replace assignment a = 3 data_frame(a = 3) # do not resolve semicolon -a <- function(x) x + 1;b;c +a <- function(x) x + 1 +b +c # don't add brackets in pipes a %>% diff --git a/tests/testthat/scope-character/scope_none-out.R b/tests/testthat/scope-character/scope_none-out.R index 2c770501f..38121db88 100644 --- a/tests/testthat/scope-character/scope_none-out.R +++ b/tests/testthat/scope-character/scope_none-out.R @@ -2,29 +2,40 @@ #' #' @param x a parameter. #' indented comments -a<- function(x){ - test_that("I want to test",{ - out <- c(1,c( - 22 +1 - )) +a <- function(x) { + test_that("I want to test", { + out <- c( + 1, + c( + 22 + 1 + ) + ) if (x > 10) { - for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%? + for (x in 22) { + # FIXME in operator only to be surrounded by one space. What about %in%? prin(x) } } - } ) + }) #we like comments too - c(list(x + 2), - c( c( - 26 ^ 2, # FIXME ^ operator has to be surrounded by one space (or none?!), never multiple - 8, - 7 - ) ) ) + c( + list(x + 2), + c( + c( + 26^2, # FIXME ^ operator has to be surrounded by one space (or none?!), never multiple + 8, + 7 + ) + ) + ) call( - 1, 2, - 23+Inf - 99, call( + 1, + 2, + 23 + Inf - 99, + call( 16 - )) + ) + ) } # comments everywhere diff --git a/tests/testthat/scope-character/scope_spaces-out.R b/tests/testthat/scope-character/scope_spaces-out.R index 4036923a9..809766f83 100644 --- a/tests/testthat/scope-character/scope_spaces-out.R +++ b/tests/testthat/scope-character/scope_spaces-out.R @@ -1,4 +1,4 @@ a <- function() { - 1 + 1 -d = 3 - } + 1 + 1 + d = 3 +} diff --git a/tests/testthat/scope-character/scope_tokens-out.R b/tests/testthat/scope-character/scope_tokens-out.R index 22b26a9cf..15b55f3c0 100644 --- a/tests/testthat/scope-character/scope_tokens-out.R +++ b/tests/testthat/scope-character/scope_tokens-out.R @@ -10,9 +10,8 @@ test_that("x", { my_test(call) }) - # do not replace assignment -a <- 3 +a = 3 data_frame(a = 3) # do not resolve semicolon @@ -22,5 +21,5 @@ c # don't add brackets in pipes a %>% - b() %>% - c() + b %>% + c diff --git a/tests/testthat/serialize_tests/k2-another-in_file-out.R b/tests/testthat/serialize_tests/k2-another-in_file-out.R index 9f77f05f3..72da5ec56 100644 --- a/tests/testthat/serialize_tests/k2-another-in_file-out.R +++ b/tests/testthat/serialize_tests/k2-another-in_file-out.R @@ -1,3 +1 @@ -call(1, - call2(call(3, 1, 2), - 4)) +call(1, call2(call(3, 1, 2), 4)) diff --git a/tests/testthat/serialize_tests/k2-out.R b/tests/testthat/serialize_tests/k2-out.R index f11cd5450..72da5ec56 100644 --- a/tests/testthat/serialize_tests/k2-out.R +++ b/tests/testthat/serialize_tests/k2-out.R @@ -1,3 +1 @@ -call(1, -call2(call(3, 1, 2), - 4)) +call(1, call2(call(3, 1, 2), 4)) diff --git a/tests/testthat/serialize_tests/k3-out.R b/tests/testthat/serialize_tests/k3-out.R index e2c34c1f4..ab6efe08a 100644 --- a/tests/testthat/serialize_tests/k3-out.R +++ b/tests/testthat/serialize_tests/k3-out.R @@ -1,4 +1 @@ -#k3 -call(1, -call2(call(3, 1, 2), - 4)) +call() diff --git a/tests/testthat/spacing/bang_bang_spacing-out.R b/tests/testthat/spacing/bang_bang_spacing-out.R index 164ecb48a..8f4b8e899 100644 --- a/tests/testthat/spacing/bang_bang_spacing-out.R +++ b/tests/testthat/spacing/bang_bang_spacing-out.R @@ -1,5 +1,5 @@ -a(! !!x) +a(!!!x) k(!!g) a(!!!x) -a(!! !x) +a(!!!x) a(!b) diff --git a/tests/testthat/spacing/comments-out.R b/tests/testthat/spacing/comments-out.R index a965d0822..4129b727e 100644 --- a/tests/testthat/spacing/comments-out.R +++ b/tests/testthat/spacing/comments-out.R @@ -1,4 +1,4 @@ a # comment -b # comment -c # comment -dejk # comment +b #comment +c # comment +dejk #comment diff --git a/tests/testthat/spacing/round_curly-out.R b/tests/testthat/spacing/round_curly-out.R index 8f2a4c49a..e49f328b3 100644 --- a/tests/testthat/spacing/round_curly-out.R +++ b/tests/testthat/spacing/round_curly-out.R @@ -1,4 +1,5 @@ -a <- function(x) {} +a <- function(x) { +} if (a) { 3 @@ -12,4 +13,5 @@ if (x) { y } else if (x) { x -} else {} +} else { +} diff --git a/tests/testthat/spacing/spacing-square-out.R b/tests/testthat/spacing/spacing-square-out.R index 6fc7288f6..4651cd5ff 100644 --- a/tests/testthat/spacing/spacing-square-out.R +++ b/tests/testthat/spacing/spacing-square-out.R @@ -5,7 +5,6 @@ a[[2]] a[[2]] - a[2] a[2] @@ -13,6 +12,5 @@ a[2] a[2] - a[[2]] a[1] diff --git a/tests/testthat/spacing/spacing-tilde-out.R b/tests/testthat/spacing/spacing-tilde-out.R index 5f7d6e484..24ff47f69 100644 --- a/tests/testthat/spacing/spacing-tilde-out.R +++ b/tests/testthat/spacing/spacing-tilde-out.R @@ -1,9 +1,9 @@ a ~ b ~b -~ b + c +~b + c a + b ~ c a ~ b ~b -~ b + c +~b + c a + b ~ c diff --git a/tests/testthat/spacing/spacing_comma2-out.R b/tests/testthat/spacing/spacing_comma2-out.R index d726bd931..31c3cd5c3 100644 --- a/tests/testthat/spacing/spacing_comma2-out.R +++ b/tests/testthat/spacing/spacing_comma2-out.R @@ -1,2 +1,2 @@ call(arg, , more_args) -a[, , drop = FALSE] +a[,, drop = FALSE] diff --git a/tests/testthat/start_line/comment-out.R b/tests/testthat/start_line/comment-out.R index abcdeb35e..40cd9cdc0 100644 --- a/tests/testthat/start_line/comment-out.R +++ b/tests/testthat/start_line/comment-out.R @@ -1,4 +1,4 @@ # a comment a <- function(x) { -x + x } diff --git a/tests/testthat/start_line/no_comment-out.R b/tests/testthat/start_line/no_comment-out.R index b32a8442e..6fa60faf1 100644 --- a/tests/testthat/start_line/no_comment-out.R +++ b/tests/testthat/start_line/no_comment-out.R @@ -1,3 +1,3 @@ a <- function(x) { -x + x } diff --git a/tests/testthat/strict/non_strict-out.R b/tests/testthat/strict/non_strict-out.R index 64a698bb5..bfb65ae1b 100644 --- a/tests/testthat/strict/non_strict-out.R +++ b/tests/testthat/strict/non_strict-out.R @@ -1,32 +1,32 @@ test <- function() { "Double quotes remain as they are" - "Single quotes are converted to double quotes" - "even if the string contains an escaped ' single quote" + 'Single quotes are converted to double quotes' + 'even if the string contains an escaped \' single quote' 'but not if it contains a "double quote' "multi-line quotes remain multi-line " - "That also holds true + 'That also holds true if single quotes are used - ." + .' - "strings with embedded\nline breaks are handled correctly" + 'strings with embedded\nline breaks are handled correctly' - "\\" - "\\'" - "\\\\" - "\\\\'" - "'\\\\'" + '\\' + '\\\'' + '\\\\' + '\\\\\'' + '\'\\\\\'' # Comments are always preserved function_calls(get_spaces = around_equal) no_space(after_opening(), paren((1 + 2))) - no_space (before_opening (), paren ((1 + 2))) + no_space(before_opening(), paren((1 + 2))) no_space(before(closing), paren((1 + 2))) multi( line, @@ -34,7 +34,7 @@ test <- function() { ) multi_line_empty_call() - one_space(after, comma("in", "function", args)) + one_space(after, comma("in", "function", args)) { braced @@ -51,13 +51,17 @@ 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 @@ -73,7 +77,7 @@ test <- function() { a >= b a <- b a -> b - a <- b + a = b a < b a > b a * b @@ -99,9 +103,12 @@ test <- function() { # Only with conservative settings: call( - preserves, distance, - after, commas, - given_has, one + preserves, + distance, + after, + commas, + given_has, + one ) if (TRUE) { @@ -118,43 +125,54 @@ test <- function() { FALSE } - single_line ("function", call) + single_line("function", call) - multiline ( - "function", call) + multiline( + "function", + call + ) - nested (function_call ("in", one, line)) + nested(function_call("in", one, line)) - nested (function_call ( - "in", - multiple, lines)) + nested( + function_call( + "in", + multiple, + lines + ) + ) nested( - function_call (with), + function_call(with), many, - first_level_args) + first_level_args + ) nested( - function_call (with), # a comment and - many # more - , first_level_args) - - difficult(nested( - "function", call - ), - with, more, args + function_call(with), # a comment and + many, #more + first_level_args ) -} + difficult( + nested( + "function", + call + ), + with, + more, + args + ) +} # formula lm(a ~ b + c, data = NA) lm(a ~ . - 1, data = NA) a ~ b:c a ~ b:c -a ~ b:c +a ~ b:c ~a ~gg -b ~ k +b ~ k call(1, ~qq) diff --git a/tests/testthat/strict/strict-out.R b/tests/testthat/strict/strict-out.R index 688cf7f88..fb125b7bd 100644 --- a/tests/testthat/strict/strict-out.R +++ b/tests/testthat/strict/strict-out.R @@ -1,7 +1,7 @@ test <- function() { "Double quotes remain as they are" - "Single quotes are converted to double quotes" - "even if the string contains an escaped ' single quote" + 'Single quotes are converted to double quotes' + 'even if the string contains an escaped \' single quote' 'but not if it contains a "double quote' # Comments are always preserved @@ -34,13 +34,17 @@ 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 @@ -56,7 +60,7 @@ test <- function() { a >= b a <- b a -> b - a <- b + a = b a < b a > b a * b @@ -82,9 +86,12 @@ test <- function() { # Only with conservative settings: call( - preserves, distance, - after, commas, - given_has, one + preserves, + distance, + after, + commas, + given_has, + one ) if (TRUE) { @@ -104,15 +111,19 @@ test <- function() { single_line("function", call) multiline( - "function", call + "function", + call ) nested(function_call("in", one, line)) - nested(function_call( - "in", - multiple, lines - )) + nested( + function_call( + "in", + multiple, + lines + ) + ) nested( function_call(with), @@ -122,19 +133,21 @@ test <- function() { nested( function_call(with), # a comment and - many # more - , first_level_args + many, #more + first_level_args ) difficult( nested( - "function", call + "function", + call ), - with, more, args + with, + more, + args ) } - # formula lm(a ~ b + c, data = NA) lm(a ~ . - 1, data = NA) diff --git a/tests/testthat/stylerignore/adding-removing-out.R b/tests/testthat/stylerignore/adding-removing-out.R index ce516fe16..a1fbbc75d 100644 --- a/tests/testthat/stylerignore/adding-removing-out.R +++ b/tests/testthat/stylerignore/adding-removing-out.R @@ -1,13 +1,12 @@ # styler: off -1 +1;3 +1 + 1 +3 # styler: on # a comment c(z) - # styler: off -if (FALSE) - 3 +if (FALSE) 3 x = 3 y = 2 # comment @@ -17,44 +16,38 @@ if (FALSE) { 3 } - # styler: off -function() - NULL +function() NULL # styler: on - # styler: off if (f(x)) { 3 -} else - 4 +} else 4 # styler: on - # styler: off while (x < 4) n() # styler: on - # styler: off -for(i in 1:3) { +for (i in 1:3) { i } # styler: on # styler: off -for (i in 1:3) - g(i) - 2 +for (i in 1:3) g(i) - 2 # styler: on 1 + 547809 +1 + 1 # styler: off -1 +1 # styler: off - -1;1 # styler: off +1 +1 # styler: off # styler: off -1 +1;3 # commnet +1 + 1 +3 # commnet # styler: on diff --git a/tests/testthat/stylerignore/alignment-out.R b/tests/testthat/stylerignore/alignment-out.R index b128cbac5..ed8d13164 100644 --- a/tests/testthat/stylerignore/alignment-out.R +++ b/tests/testthat/stylerignore/alignment-out.R @@ -1,5 +1,11 @@ ps( interaction_constraints = p_uty(tgs = "train"), - monotone_constraints = p_uty(dfault = 0, tags = c("train", "control"), custom_check = function(x) { checkmate::check_integerish(x, lower = -1, upper = 1, any.missing = FALSE) }), # styler: off - normalize_type = p_fct(c("tee", "forest"), default = "tree", tags = "train"), + monotone_constraints = p_uty( + dfault = 0, + tags = c("train", "control"), + custom_check = function(x) { + checkmate::check_integerish(x, lower = -1, upper = 1, any.missing = FALSE) + } + ), # styler: off + normalize_type = p_fct(c("tee", "forest"), default = "tree", tags = "train"), ) diff --git a/tests/testthat/stylerignore/braces-out.R b/tests/testthat/stylerignore/braces-out.R index 72d284060..191895a02 100644 --- a/tests/testthat/stylerignore/braces-out.R +++ b/tests/testthat/stylerignore/braces-out.R @@ -1,25 +1,23 @@ -x <- function() -3 # styler: off +x <- function() 3 # styler: off -x<- function() # styler: off +x <- function() + # styler: off 3 - -if (x) # styler: off - 3 else - 4 +if (x) + # styler: off + 3 else 4 if (x) { 3 -} else # styler: off +} else + # styler: off 4 -if (x) - 3 else 4 # styler: off +if (x) 3 else 4 # styler: off -while (x) # styler: off +while (x) + # styler: off "x" - -while (x) - "x"# styler: off +while (x) "x" # styler: off diff --git a/tests/testthat/stylerignore/crossing-with-expressions-out.R b/tests/testthat/stylerignore/crossing-with-expressions-out.R index 52cfa0e9f..2d0f4e95a 100644 --- a/tests/testthat/stylerignore/crossing-with-expressions-out.R +++ b/tests/testthat/stylerignore/crossing-with-expressions-out.R @@ -1,16 +1,14 @@ call( # styler: off - 1+ 1, test_xkj("hier", na.rm = 3 ,py = 43 - ) + 1 + 1, + test_xkj("hier", na.rm = 3, py = 43) ) # also if there are more comments -test_xkj("hier", na.rm = 3, py = 43 - ) - +test_xkj("hier", na.rm = 3, py = 43) -x="new" # styler: off -y=1 # none +x = "new" # styler: off +y = 1 # none more_calls( # styler: on diff --git a/tests/testthat/stylerignore/simple-out.R b/tests/testthat/stylerignore/simple-out.R index a1986de7a..0d3652db1 100644 --- a/tests/testthat/stylerignore/simple-out.R +++ b/tests/testthat/stylerignore/simple-out.R @@ -1,22 +1,19 @@ -call(1 ) # styler: off +call(1) # styler: off # styler: off # also if there are more comments -test_xkj("hier", na.rm = 3, py = 43 - ) +test_xkj("hier", na.rm = 3, py = 43) - -x="new" # styler: off -y=1 # none +x = "new" # styler: off +y = 1 # none more_calls(with(arguments)) # styler: on 1 + 1 a(!b) - # -------- -x="new" # styler: off -y <- 1 # none +x = "new" # styler: off +y = 1 # none more_calls(with(arguments)) # styler: off diff --git a/tests/testthat/tidyeval/bang_bang-out.R b/tests/testthat/tidyeval/bang_bang-out.R index 755c3210f..3e02be31f 100644 --- a/tests/testthat/tidyeval/bang_bang-out.R +++ b/tests/testthat/tidyeval/bang_bang-out.R @@ -1,9 +1,9 @@ -nameshift <- c(SL = "Sepal.Length") -head(dplyr::rename(iris[, 1:2], ! ! !nameshift), 3) -head(dplyr::rename(iris[, 1:2], !! !nameshift), 3) +nameshift <- c(SL = 'Sepal.Length') +head(dplyr::rename(iris[, 1:2], !!!nameshift), 3) +head(dplyr::rename(iris[, 1:2], !!!nameshift), 3) head(dplyr::rename(iris[, 1:2], !!!nameshift), 3) my_summarise <- function(df, group_var) { df %>% - group_by(! !group_var) %>% + group_by(!!group_var) %>% summarise(a = mean(a)) } diff --git a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R index 3bb029b9f..a803abadb 100644 --- a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R +++ b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R @@ -1,5 +1,5 @@ 1 %>% 2 1 %x% 1 1 %x% y -1 %>% x() +1 %>% x 1 %s% 1 diff --git a/tests/testthat/token_adding_removing/add_brackets_in_pipe-stylerignore-out.R b/tests/testthat/token_adding_removing/add_brackets_in_pipe-stylerignore-out.R index cdf6879f5..913c1e7da 100644 --- a/tests/testthat/token_adding_removing/add_brackets_in_pipe-stylerignore-out.R +++ b/tests/testthat/token_adding_removing/add_brackets_in_pipe-stylerignore-out.R @@ -11,7 +11,6 @@ aflh({ }) # styler: on - aflh({ isfris %>% # comment @@ -23,7 +22,6 @@ aflh({ yyexprzB() }) - # styler: off aflh({ isfris %>% @@ -39,16 +37,15 @@ aflh({ }) # styler: on - aflh({ isfris %>% # comment - tjnfaxasf12af7987A() %>% - tjnfaxdfaasfaf7987A() %>% - tjnfxasfaf798fA() %>% + tjnfaxasf12af7987A %>% + tjnfaxdfaasfaf7987A %>% + tjnfxasfaf798fA %>% # more - tf797A() %>% # comments + tf797A %>% # comments # here - yyexprzB() # + yyexprzB # # whatnot }) diff --git a/tests/testthat/token_adding_removing/double_braces-out.R b/tests/testthat/token_adding_removing/double_braces-out.R index 4df1c6536..2b57ca577 100644 --- a/tests/testthat/token_adding_removing/double_braces-out.R +++ b/tests/testthat/token_adding_removing/double_braces-out.R @@ -1,7 +1,3 @@ -if (X) { - return(TRUE) -} +if (X) return(TRUE) -if (X) { - return(FALSE) -} +if (X) return(FALSE) diff --git a/tests/testthat/token_adding_removing/for_while_stylerignore-out.R b/tests/testthat/token_adding_removing/for_while_stylerignore-out.R index 1234fec74..f6f06dffb 100644 --- a/tests/testthat/token_adding_removing/for_while_stylerignore-out.R +++ b/tests/testthat/token_adding_removing/for_while_stylerignore-out.R @@ -1,10 +1,7 @@ -while (TRUE) { - 3 -} +while (TRUE) 3 # styler: off -while(TRUE) - 3 +while (TRUE) 3 # styler: on while (TRUE) @@ -13,42 +10,34 @@ while (TRUE) # styler: on -for (i # styler: off - in 3) +for (i in 3) # styler: off 3 # styler: off -for (i - in 3) - 3 +for (i in 3) 3 # styler: on - # styler: off -for (i - in 3) { - 3} +for (i in 3) { + 3 +} # styler: on +for (i in 3) { + 3 +} # styler: off -for (i - in 3) { - 3} # styler: off - -for (i - in 3) {# styler: off +for (i in 3) { + # styler: off 3 } -for (i# styler: off - in 3) { +for (i in 3) { + # styler: off 3 } - -while ( - FALSE -) { +while (FALSE) { # styler: off 1 # styler: on @@ -62,7 +51,8 @@ while ( # styler: on } -while( # styler: off +while ( + # styler: off FALSE ) { 1 @@ -72,8 +62,6 @@ while ( # styler: off FALSE ) { - 1 - } # styler: on diff --git a/tests/testthat/token_adding_removing/if-else-comma-out.R b/tests/testthat/token_adding_removing/if-else-comma-out.R index 4bbf4bdee..ba4264881 100644 --- a/tests/testthat/token_adding_removing/if-else-comma-out.R +++ b/tests/testthat/token_adding_removing/if-else-comma-out.R @@ -1,23 +1,10 @@ -call( - if (x) { - y - }, - if (x) { - z - } -) - call( if (x) y, if (x) z ) -call( - if (x) y, - if (x) z -) +call(if (x) y, if (x) z) -call( - if (x) y, - if (x) z -) +call(if (x) y, if (x) z) + +call(if (x) y, if (x) z) diff --git a/tests/testthat/token_adding_removing/if_else_non_strict-out.R b/tests/testthat/token_adding_removing/if_else_non_strict-out.R index 26362f481..fc9c737ae 100644 --- a/tests/testthat/token_adding_removing/if_else_non_strict-out.R +++ b/tests/testthat/token_adding_removing/if_else_non_strict-out.R @@ -1,32 +1,23 @@ { - if (TRUE) - 3 - else - 5 + if (TRUE) 3 else 5 } - { if (TRUE) { 3 a + b - } else - 5 + } else 5 c() } - { - if (TRUE) - 3 - else { + if (TRUE) 3 else { h() 5 } } - { if (TRUE) { 3 @@ -36,18 +27,10 @@ } } -if (TRUE) - 1 else - 3 - -if (FALSE) - 1 + a * (31 / 2) else - 3^k +if (TRUE) 1 else 3 +if (FALSE) 1 + a * (31 / 2) else 3^k -if (TRUE) - 1 + 1 else - 3 +if (TRUE) 1 + 1 else 3 -if (TRUE) - 1 + 1 else a + 4 +if (TRUE) 1 + 1 else a + 4 diff --git a/tests/testthat/token_adding_removing/if_else_strict-out.R b/tests/testthat/token_adding_removing/if_else_strict-out.R index 45cae9432..fc9c737ae 100644 --- a/tests/testthat/token_adding_removing/if_else_strict-out.R +++ b/tests/testthat/token_adding_removing/if_else_strict-out.R @@ -1,34 +1,23 @@ { - if (TRUE) { - 3 - } else { - 5 - } + if (TRUE) 3 else 5 } - { if (TRUE) { 3 a + b - } else { - 5 - } + } else 5 c() } - { - if (TRUE) { - 3 - } else { + if (TRUE) 3 else { h() 5 } } - { if (TRUE) { 3 @@ -38,28 +27,10 @@ } } -if (TRUE) { - 1 -} else { - 3 -} - -if (FALSE) { - 1 + a * (31 / 2) -} else { - 3^k -} +if (TRUE) 1 else 3 +if (FALSE) 1 + a * (31 / 2) else 3^k -if (TRUE) { - 1 + 1 -} else { - 3 -} +if (TRUE) 1 + 1 else 3 - -if (TRUE) { - 1 + 1 -} else { - a + 4 -} +if (TRUE) 1 + 1 else a + 4 diff --git a/tests/testthat/token_adding_removing/if_else_stylerignore-out.R b/tests/testthat/token_adding_removing/if_else_stylerignore-out.R index 2daff00f6..afba25f46 100644 --- a/tests/testthat/token_adding_removing/if_else_stylerignore-out.R +++ b/tests/testthat/token_adding_removing/if_else_stylerignore-out.R @@ -1,33 +1,30 @@ -a <- 1 -b <- 3 -k <- 9 +a = 1 +b = 3 +k = 9 h <- function() 1 s <- h { - if (TRUE) # styler: off - 3 - else - 5 # styler: off + if (TRUE) + # styler: off + 3 else 5 # styler: off } - { - if (TRUE) { # styler: off + if (TRUE) { + # styler: off 3 a + b - } else - 5 # styler: off + } else 5 # styler: off c() } # styler: off { - if (TRUE) - 3 - else { + if (TRUE) 3 else { h() - 5 } + 5 + } } # styler: on @@ -40,29 +37,22 @@ s <- h } } -if (TRUE) # styler: off - 1 else - 3 - -if (FALSE) # styler: off - 1 + a * (31 / 2) else - 3^k +if (TRUE) + # styler: off + 1 else 3 +if (FALSE) + # styler: off + 1 + a * (31 / 2) else 3^k -if (TRUE) - 1+1 else # styler: off +if (TRUE) 1 + 1 else + # styler: off 3 -if (TRUE) { - 1 + 1 -} else { - a + 4 -} +if (TRUE) 1 + 1 else a + 4 # styler: off -{if (TRUE) - 3 -else - 5 +{ + if (TRUE) 3 else 5 } # styler: on diff --git a/tests/testthat/token_adding_removing/mixed_token-out.R b/tests/testthat/token_adding_removing/mixed_token-out.R index 068ab64ef..7db93c189 100644 --- a/tests/testthat/token_adding_removing/mixed_token-out.R +++ b/tests/testthat/token_adding_removing/mixed_token-out.R @@ -1,5 +1,5 @@ # = replaced with <- -a <- 3 +a = 3 data_frame(a = 3) # semicolon @@ -8,18 +8,14 @@ b c d - # quotes "text with 'quotes'" 'text with "quotes"' - # adding brackets in pipes a %>% - b() %>% - c() + b %>% + c # adding brackets in pipes combined with line breaks -a %>% - b() %>% - c() +a %>% b %>% c diff --git a/tests/testthat/token_adding_removing/substitute-out.R b/tests/testthat/token_adding_removing/substitute-out.R index 415d84d87..ac84a3f24 100644 --- a/tests/testthat/token_adding_removing/substitute-out.R +++ b/tests/testthat/token_adding_removing/substitute-out.R @@ -1,3 +1,6 @@ -expr <- substitute(airquality %>% FUN_EXPR, env = list(FUN_EXPR = call("FUN_head"))) +expr <- substitute( + airquality %>% FUN_EXPR, + env = list(FUN_EXPR = call("FUN_head")) +) a %>% - x() + x diff --git a/tests/testthat/unary_spacing/unary_indention-out.R b/tests/testthat/unary_spacing/unary_indention-out.R index 0a70a334d..132db0b7a 100644 --- a/tests/testthat/unary_spacing/unary_indention-out.R +++ b/tests/testthat/unary_spacing/unary_indention-out.R @@ -4,7 +4,6 @@ 5 + 13 - 1 + +1 - -1 / diff --git a/tests/testthat/unindention/mixed-double-out.R b/tests/testthat/unindention/mixed-double-out.R index 44591e1f2..0b5826c00 100644 --- a/tests/testthat/unindention/mixed-double-out.R +++ b/tests/testthat/unindention/mixed-double-out.R @@ -1,57 +1,44 @@ # classical -function(x, - y) { +function(x, y) { 1 } - -function(x, - y, - k) { +function(x, y, k) { 1 } - -function(x, - y) { +function(x, y) { 1 } -function(x, - y) { +function( + x, + y +) { 1 } - function(x, y) { 1 } -function(x, - # - y) { - 1 -} - - -# double function( x, + # y ) { 1 } - -function( - x, - y, - k -) { +# double +function(x, y) { 1 } +function(x, y, k) { + 1 +} function( x, @@ -60,39 +47,38 @@ function( 1 } - function( - x, y + x, + y ) { 1 } -function(x, - # - y) { +function( + x, + # + y +) { 1 } - # last brace function( - x, y) { - NULL -} + x, + y +) NULL function( - x, y) { - NULL -} + x, + y +) NULL function( x, - y) { - NULL -} + y +) NULL function( x, - y) { - NULL -} + y +) NULL diff --git a/tests/testthat/unindention/mixed-out.R b/tests/testthat/unindention/mixed-out.R index 9c543fdf8..bd9b423f9 100644 --- a/tests/testthat/unindention/mixed-out.R +++ b/tests/testthat/unindention/mixed-out.R @@ -1,7 +1,5 @@ { - ((( - 2 - ))) + (((2))) } { diff --git a/tests/testthat/unindention/unindent_multi_line-out.R b/tests/testthat/unindention/unindent_multi_line-out.R index d549c1202..79a9aae59 100644 --- a/tests/testthat/unindention/unindent_multi_line-out.R +++ b/tests/testthat/unindention/unindent_multi_line-out.R @@ -5,6 +5,8 @@ call( }, luatex = { x - }, { + }, + { xx -}) # FIXME: line break after '}', see also #125 + } +) # FIXME: line break after '}', see also #125 diff --git a/tests/testthat/unindention_regex/random_non_comment_indention-out.R b/tests/testthat/unindention_regex/random_non_comment_indention-out.R index 0dceb2ca5..253037276 100644 --- a/tests/testthat/unindention_regex/random_non_comment_indention-out.R +++ b/tests/testthat/unindention_regex/random_non_comment_indention-out.R @@ -1,4 +1,4 @@ a <- function() { - bbx + bbx x } diff --git a/tests/testthat/unindention_regex/regex_force_with_pattern-out.R b/tests/testthat/unindention_regex/regex_force_with_pattern-out.R index 3386ae756..d7c6cfca5 100644 --- a/tests/testthat/unindention_regex/regex_force_with_pattern-out.R +++ b/tests/testthat/unindention_regex/regex_force_with_pattern-out.R @@ -1,9 +1,9 @@ # ____________________________________________________________________________ # level 1 #### a <- function() { -### . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. -### inside the function should not be indented #### + ### . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. + ### inside the function should not be indented #### q() -## ............................................................................ -## same here #### + ## ............................................................................ + ## same here #### }