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

Lint/AmbiguousRegexpLiteral - Error occurs when running rubocop. #8878

Closed
mjnohai opened this issue Oct 9, 2020 · 2 comments
Closed

Lint/AmbiguousRegexpLiteral - Error occurs when running rubocop. #8878

mjnohai opened this issue Oct 9, 2020 · 2 comments

Comments

@mjnohai
Copy link

mjnohai commented Oct 9, 2020

Error occurs when running rubocop for the AmbiguousRegexpLiteral linter. The error did not occur on the previous version, 0.92.0.


Expected behavior

Rubocop shouldn't have an error as the regular expression used here is valid.

Actual behavior

An error occurred while Lint/AmbiguousRegexpLiteral cop was inspecting ./projects/MIST/pages/imedidata/course.rb.
undefined method `receiver' for nil:NilClass
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:64:in `method_chain_to_regexp_receiver?'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:56:in `find_offense_node'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:50:in `find_offense_node_by'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:35:in `block in on_new_investigation'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:32:in `each'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb:32:in `on_new_investigation'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:143:in `block (2 levels) in invoke'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:152:in `with_cop_error_handling'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:142:in `block in invoke'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:141:in `each'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:141:in `invoke'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/commissioner.rb:83:in `investigate'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/team.rb:152:in `investigate_partial'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cop/team.rb:83:in `investigate'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:315:in `inspect_file'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:286:in `loop'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:132:in `block in file_offenses'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:157:in `file_offense_cache'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:131:in `file_offenses'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:122:in `process_file'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:100:in `each'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:100:in `reduce'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:86:in `inspect_files'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/runner.rb:47:in `run'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli/command.rb:11:in `run'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli/environment.rb:18:in `run'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli.rb:65:in `run_command'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli.rb:72:in `execute_runners'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/lib/rubocop/cli.rb:41:in `run'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/exe/rubocop:13:in `block in <top (required)>'
.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
.rvm/gems/ruby-2.6.6@mist/gems/rubocop-0.93.0/exe/rubocop:12:in `<top (required)>'
.rvm/gems/ruby-2.6.6@mist/bin/rubocop:23:in `load'
.rvm/gems/ruby-2.6.6@mist/bin/rubocop:23:in `<main>'
.rvm/gems/ruby-2.6.6@mist/bin/ruby_executable_hooks:24:in `eval'
.rvm/gems/ruby-2.6.6@mist/bin/ruby_executable_hooks:24:in `<main>'

Steps to reproduce the problem

  • Running bundle exec rubocop on a file that contained the following regex
/^[(]Correct answer(?:s*) (?:is|are) option(?:s)* ([\d]*)(?:, ([\d]*))*(?: and ([\d]*))*[)]$/

RuboCop version

$ [bundle exec] rubocop -V
0.93.0 (using Parser 2.7.2.0, rubocop-ast 0.7.1, running on ruby 2.6.6 x86_64-darwin18)
@martinjaimem
Copy link

@mnohai-mdsol I think this is already fixed on master branch

@marcandre
Copy link
Contributor

Indeed, sorry about this bug. Fixed by #8863

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