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

An error occurred while Performance/RegexpMatch cop was inspecting #4407

Closed
pgolm opened this issue May 23, 2017 · 2 comments
Closed

An error occurred while Performance/RegexpMatch cop was inspecting #4407

pgolm opened this issue May 23, 2017 · 2 comments

Comments

@pgolm
Copy link

pgolm commented May 23, 2017

After upgrading rubocop the following issue is triggered:

An error occurred while Performance/RegexpMatch cop was inspecting

It raises in the following line:

register_purge_url(Card) { card_path('\d+', match.id) if match }

Rubocop version:

$ rubocop -V
0.48.1 (using Parser 2.4.0.0, running on ruby 2.4.1 x86_64-linux)

Stacktrace with rubocop -d:

An error occurred while Performance/RegexpMatch cop was inspecting /app/models/concerns/varnish_cleaner.rb:268:29.
undefined method `type' for nil:NilClass
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/performance/regexp_match.rb:69:in `match_method?'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/performance/regexp_match.rb:97:in `match_node?'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/performance/regexp_match.rb:140:in `check_condition'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/performance/regexp_match.rb:110:in `on_if'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:43:in `block (2 levels) in on_if'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:106:in `with_cop_error_handling'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:42:in `block in on_if'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:41:in `each'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:41:in `on_if'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/ast/traversal.rb:154:in `on_block'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:47:in `on_block'
(eval):2:in `block in on_begin'
(eval):2:in `each'
(eval):2:in `on_begin'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:47:in `on_begin'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/ast/traversal.rb:141:in `on_while'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:47:in `on_module'                                                                                     [25/1892]
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/ast/traversal.rb:12:in `walk'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/commissioner.rb:60:in `investigate'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/team.rb:124:in `investigate'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/team.rb:112:in `offenses'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cop/team.rb:54:in `inspect_file'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:248:in `inspect_file'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:195:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:227:in `block in iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:220:in `loop'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:220:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:191:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:101:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:111:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:99:in `file_offenses'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:90:in `process_file'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:68:in `block in each_inspected_file'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:65:in `each'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:65:in `reduce'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:65:in `each_inspected_file'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:57:in `inspect_files'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/runner.rb:36:in `run'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cli.rb:72:in `execute_runner'
/usr/local/bundle/gems/rubocop-0.48.1/lib/rubocop/cli.rb:27:in `run'
/usr/local/bundle/gems/rubocop-0.48.1/bin/rubocop:13:in `block in <top (required)>'
/usr/local/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/usr/local/bundle/gems/rubocop-0.48.1/bin/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:17:in `load'
/usr/local/bundle/bin/rubocop:17:in `<main>'
@bbatsov
Copy link
Collaborator

bbatsov commented May 24, 2017

I can't reproduce this with RuboCop 0.49.

@pocke
Copy link
Collaborator

pocke commented May 24, 2017

We need to specify TargetRubyVersion to reproduce this error.

AllCops:
  TargetRubyVersion: 2.4

minimum code to reproduce: a if match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants