Skip to content

Commit

Permalink
Permit to specify TargetRubyVersion 2.7
Browse files Browse the repository at this point in the history
Parser gem has been started development for Ruby 2.7 (edge Ruby).
whitequark/parser#546

This PR permits Ruby 2.7, the early adapters will be able to try edge
Ruby with RuboCop.
  • Loading branch information
koic authored and bbatsov committed May 27, 2019
1 parent d427cab commit c06cc51
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### New features

* [#7084](https://github.com/rubocop-hq/rubocop/pull/7084): Permit to specify TargetRubyVersion 2.7. ([@koic][])

### Bug fixes

* [#7066](https://github.com/rubocop-hq/rubocop/issues/7066): Fix `Layout/AlignHash` when mixed Hash styles are used. ([@rmm5t][])
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Config

# 2.3 is the oldest officially supported Ruby version.
DEFAULT_RUBY_VERSION = 2.3
KNOWN_RUBIES = [2.3, 2.4, 2.5, 2.6].freeze
KNOWN_RUBIES = [2.3, 2.4, 2.5, 2.6, 2.7].freeze
OBSOLETE_RUBIES = {
1.9 => '0.50', 2.0 => '0.50', 2.1 => '0.58', 2.2 => '0.69'
}.freeze
Expand Down
3 changes: 3 additions & 0 deletions lib/rubocop/processed_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def parser_class(ruby_version)
when 2.6
require 'parser/ruby26'
Parser::Ruby26
when 2.7
require 'parser/ruby27'
Parser::Ruby27
else
raise ArgumentError, "Unknown Ruby version: #{ruby_version.inspect}"
end
Expand Down
6 changes: 3 additions & 3 deletions spec/rubocop/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1773,14 +1773,14 @@ def method(foo, bar, qux, fred, arg5, f) end #{'#' * 45}
it 'fails with an error message' do
create_file('.rubocop.yml', <<~YAML)
AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 2.8
YAML
expect(cli.run([])).to eq(2)
expect($stderr.string.strip).to match(
/\AError: Unknown Ruby version 2.7 found in `TargetRubyVersion`/
/\AError: Unknown Ruby version 2.8 found in `TargetRubyVersion`/
)
expect($stderr.string.strip).to match(
/Supported versions: 2.3, 2.4, 2.5, 2.6/
/Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7/
)
end
end
Expand Down

0 comments on commit c06cc51

Please sign in to comment.