rubocop myfile.rb
Inspecting 1 file
.
0 files inspected, no offenses detected
undefined method `on_numblock' for #<RuboCop::Cop::Commissioner:0x00007fe520ae4310>
Did you mean? on_block
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `each'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:100:in `on_def'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `each'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:13:in `walk'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:124:in `investigate'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:112:in `offenses'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/team.rb:44:in `inspect_file'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:296:in `inspect_file'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:244:in `block in do_inspection_loop'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:269:in `loop'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:269:in `iterate_until_no_changes'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:240:in `do_inspection_loop'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:119:in `block in file_offenses'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:143:in `file_offense_cache'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:117:in `file_offenses'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:108:in `process_file'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `each'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `reduce'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:86:in `each_inspected_file'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:73:in `inspect_files'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/runner.rb:39:in `run'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli/command.rb:10:in `run'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli/environment.rb:17:in `run'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:65:in `run_command'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/lib/rubocop/cli.rb:41:in `run'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/exe/rubocop:13:in `block in <top (required)>'
/Users/chris/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/chris/.rvm/gems/ruby-2.7.0/gems/rubocop-0.78.0/exe/rubocop:12:in `<top (required)>'
/Users/chris/.rvm/gems/ruby-2.7.0/bin/rubocop:23:in `load'
/Users/chris/.rvm/gems/ruby-2.7.0/bin/rubocop:23:in `<main>'
My env:
Ruby 2.7.0
Mac OS 10.15.2
Rubocop: 0.78.0
Tried ruby 2.6.5 with same rubocop verison and was working fine.
Parser gem 2.7.0.0 has been released.
https://rubygems.org/gems/parser/versions/2.7.0.0
Can you try updating to the latest parser gem? And is there still the issue?
Please show me the reproduction code if you still have issue.
I have a similar issue with:
def foo(...)
bar(...)
end
rubocop test.rb
Inspecting 1 file
.
0 files inspected, no offenses detected
undefined method `on_forwarded_args' for #<RuboCop::Cop::Commissioner:0x00007fd782356ec8>
ruby/gems/2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:107:in `block in on_send'
ruby/gems/2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:104:in `each'
ruby/gems/2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:104:in `each_with_index'
ruby/gems/2.7.0/gems/rubocop-0.78.0/lib/rubocop/ast/traversal.rb:104:in `on_send'
ruby/gems/2.7.0/gems/rubocop-0.78.0/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
using:
Rubocop: 0.78.0
Parser: 2.7.0.0
Thanks. I am able to reproduce this.
@koic I guess the new node types in parser 2.7 need to be added to RuboCop::AST::Traversal: https://github.com/rubocop-hq/rubocop/compare/master...buehmann:parser-2.7
After that a lot of cops will need to be adjusted to the new possible variations in the AST. For example I get this for @timoschilling's example:
An error occurred while Layout/ClosingParenthesisIndentation cop was inspecting ...
An error occurred while Layout/FirstParameterIndentation cop was inspecting ...
An error occurred while Layout/ParameterAlignment cop was inspecting ...
An error occurred while Naming/MethodParameterName cop was inspecting ...
An error occurred while Style/DefWithParentheses cop was inspecting ...
An error occurred while Style/MethodDefParentheses cop was inspecting ...
An error occurred while Style/OptionalArguments cop was inspecting ...
undefined method `size' for s(:forward_args):RuboCop::AST::Node
undefined method `empty?' for s(:forward_args):RuboCop::AST::Node
undefined method `each_with_index' for s(:forward_args):RuboCop::AST::Node
because those cops don't expect the new :forward_args node.
Here is a other maybe related bug:
def foo(...)
end
# or
def foo(...)
bar
end
โ rubocop test.rb
Inspecting 1 file
An error occurred while Layout/ClosingParenthesisIndentation cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
An error occurred while Layout/FirstParameterIndentation cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
An error occurred while Layout/ParameterAlignment cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
An error occurred while Naming/MethodParameterName cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
An error occurred while Style/MethodDefParentheses cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
An error occurred while Style/OptionalArguments cop was inspecting /../test.rb:3:0.
To see the complete backtrace run rubocop -d.
.
1 file inspected, no offenses detected
6 errors occurred:
An error occurred while Layout/ClosingParenthesisIndentation cop was inspecting /../test.rb:3:0.
An error occurred while Layout/FirstParameterIndentation cop was inspecting /../test.rb:3:0.
An error occurred while Layout/ParameterAlignment cop was inspecting /../test.rb:3:0.
An error occurred while Naming/MethodParameterName cop was inspecting /../test.rb:3:0.
An error occurred while Style/MethodDefParentheses cop was inspecting /../test.rb:3:0.
An error occurred while Style/OptionalArguments cop was inspecting /../test.rb:3:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues
Mention the following information in the issue report:
0.78.0 (using Parser 2.7.0.0, running on ruby 2.7.0 x86_64-darwin19)
@buehmann Yeah, you're right. That's why I'm so "fond" of syntax changes in Ruby. ๐ I guess for now we can have most cops ignore ... and figure out what to do about it down the road. It will eventually require some cops of its own. Same with pattern matching.
@koic @buehmann Are any of you already working on this? If not I will work on it tonight. ๐
Edit: That's Singapore time, so "tonight" means in two hours. ๐ฌ
@Drenmi No, not more than https://github.com/rubocop-hq/rubocop/compare/master...buehmann:parser-2.7 โฆ Go ahead! :slightly_smiling_face:
Will be fixed once we can get #7605 merged.
Hi @koic , sorry for the delay, I updated parser to 2.7.0.1 and the issue still exists. The content of my script file is
#!/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
I think it has something to do with the line spliters.each { meaning = meaning.split(_1).first }.
@ChrisZou Parser 2.7.0.1 is not the only part of the solution; some changes have been made to the master branch to start supporting the Ruby 2.7 syntax. Use the master version or wait for the next release.
โ rubocop (master) โ git describe
v0.78.0-31-g23d5e4b7e
โ rubocop (master) โ cat 7602.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
โ rubocop (master) โ rubocop 7602.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
With master I still get a
undefined method `on_forwarded_args' for #<RuboCop::Cop::Commissioner:0x0000558bff9cc1e8>
You're right. I got confused. on_forwarded_args will be introduced here: https://github.com/rubocop-hq/rubocop/pull/7605
The PR was just merged.
Most helpful comment
@ChrisZou Parser 2.7.0.1 is not the only part of the solution; some changes have been made to the
masterbranch to start supporting the Ruby 2.7 syntax. Use themasterversion or wait for the next release.