Skip to content

Commit

Permalink
Support TargetRubyVersion 3.1 (experimental)
Browse files Browse the repository at this point in the history
RuboCop AST 1.5 supports Ruby 3.1.
rubocop/rubocop-ast#182.

This PR supports `TargetRubyVersion 3.1`.
  • Loading branch information
koic authored and bbatsov committed May 2, 2021
1 parent baba552 commit 93a325f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/new_support_ruby_3_1_experimental.md
@@ -0,0 +1 @@
* [#9758](https://github.com/rubocop/rubocop/pull/9758): Support `TargetRubyVersion 3.1` (experimental). ([@koic][])
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/compatibility.adoc
Expand Up @@ -31,6 +31,7 @@ The following table is the support matrix.
| 2.6 | -
| 2.7 | -
| 3.0 | -
| 3.1 (experimental) | -
|===

NOTE: The compatibility xref:configuration.adoc#setting-the-target-ruby-version[target Ruby version mentioned here] is about code analysis (what RuboCop can analyze), not runtime (is RuboCop capable of running on some Ruby or not).
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/rspec/shared_contexts.rb
Expand Up @@ -131,3 +131,7 @@ def source_range(range, buffer: source_buffer)
RSpec.shared_context 'ruby 3.0', :ruby30 do
let(:ruby_version) { 3.0 }
end

RSpec.shared_context 'ruby 3.1', :ruby31 do
let(:ruby_version) { 3.1 }
end
2 changes: 1 addition & 1 deletion lib/rubocop/target_ruby.rb
Expand Up @@ -4,7 +4,7 @@ module RuboCop
# The kind of Ruby that code inspected by RuboCop is written in.
# @api private
class TargetRuby
KNOWN_RUBIES = [2.5, 2.6, 2.7, 3.0].freeze
KNOWN_RUBIES = [2.5, 2.6, 2.7, 3.0, 3.1].freeze
DEFAULT_VERSION = KNOWN_RUBIES.first

OBSOLETE_RUBIES = {
Expand Down
2 changes: 1 addition & 1 deletion rubocop.gemspec
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('rainbow', '>= 2.2.2', '< 4.0')
s.add_runtime_dependency('regexp_parser', '>= 1.8', '< 3.0')
s.add_runtime_dependency('rexml')
s.add_runtime_dependency('rubocop-ast', '>= 1.2.0', '< 2.0')
s.add_runtime_dependency('rubocop-ast', '>= 1.5.0', '< 2.0')
s.add_runtime_dependency('ruby-progressbar', '~> 1.7')
s.add_runtime_dependency('unicode-display_width', '>= 1.4.0', '< 3.0')

Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cli_spec.rb
Expand Up @@ -1612,7 +1612,7 @@ def method(foo, bar, qux, fred, arg5, f) end #{'#' * 85}
expect($stderr.string.strip).to start_with(
'Error: RuboCop found unknown Ruby version 4.0 in `TargetRubyVersion`'
)
expect($stderr.string.strip).to match(/Supported versions: 2.5, 2.6, 2.7, 3.0/)
expect($stderr.string.strip).to match(/Supported versions: 2.5, 2.6, 2.7, 3.0, 3.1/)
end
end

Expand Down

0 comments on commit 93a325f

Please sign in to comment.