Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on TargetRubyVersion 2.7: undefined method `on_numblock' #7647

Closed
JustinFeng opened this issue Jan 13, 2020 · 0 comments · Fixed by #7665
Closed

Error on TargetRubyVersion 2.7: undefined method `on_numblock' #7647

JustinFeng opened this issue Jan 13, 2020 · 0 comments · Fixed by #7665
Labels

Comments

@JustinFeng
Copy link

Expected behavior

Should be able to handle numbered parameter when specifying TargetRubyVersion 2.7

Actual behavior

rubocop command fails with error output

undefined method `on_numblock' for #<RuboCop::Cop::Commissioner:0x00007fcd0eb1d298>
Did you mean?  on_block

Steps to reproduce the problem

.rubocop.yml

AllCops:
  TargetRubyVersion: 2.7

test.rb

#!/usr/bin/env ruby
# frozen_string_literal: true

def hello(meaning)
  spliters = [',', '.', '!']
  spliters.each { meaning = meaning.split(_1).first }
  meaning.delete('"').strip.gsub("\r\n", '; ')
end

Output

$ rubocop test.rb 
Inspecting 1 file
"s(:numblock,\n  s(:send,\n    s(:lvar, :spliters), :each), 1,\n  s(:lvasgn, :meaning,\n    s(:send,\n      s(:send,\n        s(:lvar, :meaning), :split,\n        s(:lvar, :_1)), :first)))"
.

0 files inspected, no offenses detected
undefined method `on_numblock' for #<RuboCop::Cop::Commissioner:0x00007fcd0eb1d298>
Did you mean?  on_block
/Users/justinfeng/.rvm/gems/ruby-2.7.0/gems/rubocop-0.79.0/lib/rubocop/ast/traversal.rb:57:in `block in on_begin'
/Users/justinfeng/.rvm/gems/ruby-2.7.0/gems/rubocop-0.79.0/lib/rubocop/ast/traversal.rb:57:in `each'
/Users/justinfeng/.rvm/gems/ruby-2.7.0/gems/rubocop-0.79.0/lib/rubocop/ast/traversal.rb:57:in `on_begin'

RuboCop version

$ bundle exec rubocop -V
0.79.0 (using Parser 2.7.0.2, running on ruby 2.7.0 x86_64-darwin17)
@koic koic added the bug label Jan 13, 2020
hanachin added a commit to hanachin/rubocop that referenced this issue Jan 28, 2020
when using Ruby 2.7's numbered parameters
koic added a commit that referenced this issue Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants