diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7107aea7..e3f0f1cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby_version: ['3.2', '3.1', '3.0', '2.7'] + ruby_version: ['3.3', '3.2', '3.1', '3.0', '2.7'] steps: - uses: actions/checkout@v3 diff --git a/bin/verify-sample-code b/bin/verify-sample-code index cc40696b..8ec9a5ad 100755 --- a/bin/verify-sample-code +++ b/bin/verify-sample-code @@ -1,17 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true repos = { - "rspec/rspec-core" => { - "--exclude-pattern" => [ - "spec/rspec/core/world_spec.rb", - "spec/rspec/core/formatters/exception_presenter_spec.rb", - "spec/rspec/core/formatters/snippet_extractor_spec.rb", - "spec/rspec/core/metadata_spec.rb", - "spec/rspec/core/formatters/html_formatter_spec.rb", - "spec/rspec/core/formatters_spec.rb", - "spec/rspec/core/formatters/documentation_formatter_spec.rb", - "spec/rspec/core/formatters/progress_formatter_spec.rb" - ].join(","), + "lostisland/faraday" => { + "--format" => "progress", }, } diff --git a/lib/rufo/formatter.rb b/lib/rufo/formatter.rb index d564a61c..e3d8879e 100644 --- a/lib/rufo/formatter.rb +++ b/lib/rufo/formatter.rb @@ -2315,6 +2315,12 @@ def visit_q_or_i_array(node) write_indent next_indent end next_token + + # fix for 3.3 ripper change. two :on_words_sep are generated for "#\n " + while current_token_kind == :on_words_sep + next_token + end + has_space = true if current_token_value.start_with?(" ") end @@ -2337,6 +2343,10 @@ def visit_q_or_i_array(node) next_token write_line write_indent(column) + # two :on_words_sep are generated for "#\n " on ruby 3.3 + while current_token_kind == :on_words_sep + next_token + end else next_token write_space diff --git a/spec/lib/rufo/formatter_source_specs/break.rb.spec b/spec/lib/rufo/formatter_source_specs/break.rb.spec index f5f463e0..95174f3b 100644 --- a/spec/lib/rufo/formatter_source_specs/break.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/break.rb.spec @@ -1,29 +1,44 @@ #~# ORIGINAL break +loop do break +end #~# EXPECTED -break +loop do + break +end #~# ORIGINAL +loop do break 1 +end #~# EXPECTED -break 1 +loop do + break 1 +end #~# ORIGINAL - +loop do break 1 , 2 +end #~# EXPECTED -break 1, 2 +loop do + break 1, 2 +end #~# ORIGINAL +loop do break 1 , 2 +end #~# EXPECTED -break 1, - 2 +loop do + break 1, + 2 +end diff --git a/spec/lib/rufo/formatter_source_specs/next.rb.spec b/spec/lib/rufo/formatter_source_specs/next.rb.spec index f1fa5c0c..390d0565 100644 --- a/spec/lib/rufo/formatter_source_specs/next.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/next.rb.spec @@ -1,29 +1,46 @@ #~# ORIGINAL next +loop do next +end #~# EXPECTED -next +loop do + next +end #~# ORIGINAL +loop do next 1 +end #~# EXPECTED -next 1 +loop do + next 1 +end #~# ORIGINAL +loop do next 1 , 2 +end #~# EXPECTED -next 1, 2 +loop do + next 1, 2 +end #~# ORIGINAL +loop do next 1 , 2 +end #~# EXPECTED -next 1, - 2 +loop do + next 1, + 2 +end + diff --git a/spec/lib/rufo/formatter_source_specs/redo.rb.spec b/spec/lib/rufo/formatter_source_specs/redo.rb.spec index 1109b983..118ffd87 100644 --- a/spec/lib/rufo/formatter_source_specs/redo.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/redo.rb.spec @@ -1,6 +1,10 @@ #~# ORIGINAL redo +loop do redo +end #~# EXPECTED -redo +loop do + redo +end diff --git a/spec/lib/rufo/formatter_source_specs/retry.rb.spec b/spec/lib/rufo/formatter_source_specs/retry.rb.spec index b57d483f..40e6a830 100644 --- a/spec/lib/rufo/formatter_source_specs/retry.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/retry.rb.spec @@ -1,6 +1,12 @@ #~# ORIGINAL retry +begin +rescue retry +end #~# EXPECTED -retry +begin +rescue + retry +end diff --git a/spec/lib/rufo/formatter_source_specs/yield.rb.spec b/spec/lib/rufo/formatter_source_specs/yield.rb.spec index e51b615e..84cc7664 100644 --- a/spec/lib/rufo/formatter_source_specs/yield.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/yield.rb.spec @@ -1,36 +1,56 @@ #~# ORIGINAL yield +def foo yield +end #~# EXPECTED -yield +def foo + yield +end #~# ORIGINAL +def foo yield 1 +end #~# EXPECTED -yield 1 +def foo + yield 1 +end #~# ORIGINAL +def foo yield 1 , 2 +end #~# EXPECTED -yield 1, 2 +def foo + yield 1, 2 +end #~# ORIGINAL +def foo yield 1 , 2 +end #~# EXPECTED -yield 1, - 2 +def foo + yield 1, + 2 +end #~# ORIGINAL +def foo yield( 1 , 2 ) +end #~# EXPECTED -yield(1, 2) +def foo + yield(1, 2) +end