diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 77eeb93de..86eb5952b 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -25,9 +25,9 @@ jobs: title: [ null ] include: - { os: windows, rubocop: master, ruby: mingw } - - { rubocop: '0.84.0', ruby: 2.4, os: ubuntu } - - { rubocop: '0.84.0', ruby: head, os: ubuntu } - - { rubocop: '0.84.0', ruby: 2.4, os: ubuntu, coverage: true, title: 'Coverage' } + - { rubocop: '0.87.0', ruby: 2.4, os: ubuntu } + - { rubocop: '0.87.0', ruby: head, os: ubuntu } + - { rubocop: '0.87.0', ruby: 2.4, os: ubuntu, coverage: true, title: 'Coverage' } - { rubocop: master, ruby: 2.7, os: ubuntu, modern: true, title: 'Specs "modern"' } - { rubocop: master, ruby: 2.7, os: ubuntu, internal_investigation: true, modern: true, title: 'Coding Style' } @@ -87,7 +87,7 @@ jobs: matrix: os: [ ubuntu ] ruby: [ 2.4, 2.7 ] - rubocop: [ '0.84.0', master ] + rubocop: [ '0.87.0', master ] steps: - name: checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d1a8b47..880c89753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### Changes +* [#44](https://github.com/rubocop-hq/rubocop-ast/issue/44): **(Breaking)** Use `parser` flag `self.emit_forward_arg = true` by default. ([@marcandre][]) * [#86](https://github.com/rubocop-hq/rubocop-ast/pull/86): `PairNode#delimiter` and `inverse_delimiter` now accept their argument as a named argument. ([@marcandre][]) ## 0.2.0 (2020-07-19) diff --git a/README.md b/README.md index 604ee63de..e5eda6ce2 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,9 @@ See the [docs site](https://docs.rubocop.org/rubocop-ast) for more details. ### Parser compatibility switches -The main `RuboCop` gem uses [legacy AST output from parser](https://github.com/whitequark/parser/#usage). -This gem is meant to be compatible with all settings. For example, to have `-> { ... }` emitted +This gem, by default, uses most [legacy AST output from parser](https://github.com/whitequark/parser/#usage), except for `emit_forward_arg` which is set to `true`. + +The main `RuboCop` gem uses these defaults (and is currently only compatible with these), but this gem can be used separately from `RuboCop` and is meant to be compatible with all settings. For example, to have `-> { ... }` emitted as `LambdaNode` instead of `SendNode`: ```ruby diff --git a/lib/rubocop/ast/builder.rb b/lib/rubocop/ast/builder.rb index 166dc8aea..5a77d677f 100644 --- a/lib/rubocop/ast/builder.rb +++ b/lib/rubocop/ast/builder.rb @@ -14,6 +14,8 @@ module AST # parser = Parser::Ruby25.new(builder) # root_node = parser.parse(buffer) class Builder < Parser::Builders::Default + self.emit_forward_arg = true + NODE_MAP = { and: AndNode, alias: AliasNode, diff --git a/rubocop-ast.gemspec b/rubocop-ast.gemspec index 8f683c5d2..d0d84e852 100644 --- a/rubocop-ast.gemspec +++ b/rubocop-ast.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| 'bug_tracker_uri' => 'https://github.com/rubocop-hq/rubocop-ast/issues' } - s.add_runtime_dependency('parser', '>= 2.7.0.1') + s.add_runtime_dependency('parser', '>= 2.7.1.4') s.add_development_dependency('bundler', '>= 1.15.0', '< 3.0') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b23846f30..8262f4ded 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,7 +8,10 @@ end require 'rubocop-ast' -RuboCop::AST::Builder.modernize if ENV['MODERNIZE'] +if ENV['MODERNIZE'] + RuboCop::AST::Builder.modernize + RuboCop::AST::Builder.emit_forward_arg = false # inverse of default +end RSpec.shared_context 'ruby 2.3', :ruby23 do let(:ruby_version) { 2.3 }