Skip to content

Commit

Permalink
[Fixes rubocop#44] Use parser's new emit_forward_arg by default
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Jul 6, 2020
1 parent 7aa7295 commit 6dce0e6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

* [#50](https://github.com/rubocop-hq/rubocop-ast/pull/50): Support find pattern matching for Ruby 2.8 (3.0) parser. ([@koic][])

### Changes

* [#44](https://github.com/rubocop-hq/rubocop-ast/issue/44): **(Breaking)** Use `parser` flag `self.emit_forward_arg = true` by default. ([@marcandre][])

## 0.1.0 (2020-06-26)

### New features
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/ast/builder.rb
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion rubocop-ast.gemspec
Expand Up @@ -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')

Expand Down
5 changes: 4 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -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 }
Expand Down

0 comments on commit 6dce0e6

Please sign in to comment.