Skip to content

Commit

Permalink
Support Parser::Ruby31
Browse files Browse the repository at this point in the history
Parser gem has been started development for Ruby 3.1 (edge Ruby).
whitequark/parser#792

This PR supports `Parser::Ruby31`, the early adapters will be able to try
edge Ruby with RuboCop.

And this PR update to require Parser 3.0.1.1 or higher, which contains
`Parser::Ruby31`.
https://github.com/whitequark/parser/blob/master/CHANGELOG.md#v3011-2021-05-02
  • Loading branch information
koic committed May 2, 2021
1 parent 7bcf0b4 commit 5dafdd0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/new_support_ruby_3_1_parser.md
@@ -0,0 +1 @@
* [#182](https://github.com/rubocop-hq/rubocop-ast/pull/182): Support `Parser::Ruby31` for Ruby 3.1 parser (experimental). ([@koic][])
3 changes: 3 additions & 0 deletions lib/rubocop/ast/processed_source.rb
Expand Up @@ -236,6 +236,9 @@ def parser_class(ruby_version)
when 2.8, 3.0
require 'parser/ruby30'
Parser::Ruby30
when 3.1
require 'parser/ruby31'
Parser::Ruby31
else
raise ArgumentError,
"RuboCop found unknown Ruby version: #{ruby_version.inspect}"
Expand Down
2 changes: 1 addition & 1 deletion rubocop-ast.gemspec
Expand Up @@ -32,7 +32,7 @@ Gem::Specification.new do |s|
'bug_tracker_uri' => 'https://github.com/rubocop-hq/rubocop-ast/issues'
}

s.add_runtime_dependency('parser', '>= 2.7.1.5')
s.add_runtime_dependency('parser', '>= 3.0.1.1')

s.add_development_dependency('bundler', '>= 1.15.0', '< 3.0')

Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -43,6 +43,10 @@
let(:ruby_version) { 3.0 }
end

RSpec.shared_context 'ruby 3.1', :ruby31 do
let(:ruby_version) { 3.1 }
end

# ...
module DefaultRubyVersion
extend RSpec::SharedContext
Expand Down

0 comments on commit 5dafdd0

Please sign in to comment.