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

Failure in Layout/SpaceAroundMethodCallOperator - undefined method `begin_pos' for nil:NilClass #8459

Closed
ms-ati opened this issue Aug 5, 2020 · 1 comment

Comments

@ms-ati
Copy link

ms-ati commented Aug 5, 2020

Expected behavior

Given a Guardfile with the following lines:

  watch(rails.controllers) do |m|
    [
      rspec.spec.("routing/#{m[1]}_routing"),
      rspec.spec.("controllers/#{m[1]}_controller"),
      rspec.spec.("acceptance/#{m[1]}")
    ]
  end

We expect Rubocop to run all specs without raising internal errors.

Actual behavior

Rubocop 0.88.0 is raising errors in the cop Layout/SpaceAroundMethodCallOperator when inspecting such a Guardfile.

Specifically, the code in the form rspec.( appears to trigger the following error in Rubocop:

An error occurred while Layout/SpaceAroundMethodCallOperator cop was inspecting /app/Guardfile:50:6.
undefined method `begin_pos' for nil:NilClass
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/layout/space_around_method_call_operator.rb:69:in `check_space_after_dot'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/layout/space_around_method_call_operator.rb:49:in `on_send'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:91:in `block (2 levels) in trigger_responding_cops'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:113:in `with_cop_error_handling'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:90:in `block in trigger_responding_cops'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:89:in `each'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:89:in `trigger_responding_cops'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:61:in `block (2 levels) in <class:Commissioner>'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `block in on_array'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `each'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `on_array'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:173:in `on_block'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `each'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:173:in `on_block'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/bundle/gems/rubocop-ast-0.3.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:74:in `investigate'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/team.rb:151:in `investigate_partial'
/bundle/gems/rubocop-0.88.0/lib/rubocop/cop/team.rb:83:in `investigate'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:295:in `inspect_file'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:245:in `block in do_inspection_loop'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:277:in `block in iterate_until_no_changes'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:270:in `loop'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:270:in `iterate_until_no_changes'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:241:in `do_inspection_loop'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:121:in `block in file_offenses'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:146:in `file_offense_cache'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:120:in `file_offenses'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:111:in `process_file'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `each'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `reduce'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `each_inspected_file'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:78:in `inspect_files'
/bundle/gems/rubocop-0.88.0/lib/rubocop/runner.rb:39:in `run'

Steps to reproduce the problem

Run rubocop against a Guardfile like this one:
http://alfredoroca.github.io/spring/guard/test/2015/07/13/spring-guard

RuboCop version

$ bundle exec rubocop -V
0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.5.3 x86_64-linux)
@ms-ati ms-ati changed the title Layout/SpaceAroundMethodCallOperator - undefined method `begin_pos' for nil:NilClass Failure in Layout/SpaceAroundMethodCallOperator - undefined method `begin_pos' for nil:NilClass Aug 5, 2020
@koic koic added the duplicate label Aug 5, 2020
@koic
Copy link
Member

koic commented Aug 5, 2020

This issue is a dup with #8324 and solved by #8328. Thank you for your feedback!

@koic koic closed this as completed Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants