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 in Layout/SpaceAroundMethodCallOperator cop when using Proc#call shorthand syntax #8324

Closed
nertzy opened this issue Jul 13, 2020 · 1 comment · Fixed by #8328
Closed
Labels

Comments

@nertzy
Copy link

nertzy commented Jul 13, 2020

Expected behavior

I want to use the Proc#call shorthand syntax that looks like proc.(*args) instead of proc.call(*args).

I'm using the example from the top of the Proc documentation.

Actual behavior

The 0.88 implementation of Layout/SpaceAroundMethodCallOperator raises an error when it encounters this syntax.

Steps to reproduce the problem

script.rb

# frozen_string_literal: true

square = proc { |x| x**2 }
puts square.(3)

rubocop.yml

Style/LambdaCall:
  EnforcedStyle: braces

Layout/SpaceAroundMethodCallOperator:
  Enabled: true

$ rubocop -d script.rb > output

output

For /Users/dev/projects/fake: configuration from /Users/dev/projects/fake/.rubocop.yml
Default configuration from /Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/config/default.yml
Inspecting 1 file
Scanning /Users/dev/projects/fake/script.rb
undefined method `begin_pos' for nil:NilClass
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/layout/space_around_method_call_operator.rb:69:in `check_space_after_dot'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/layout/space_around_method_call_operator.rb:49:in `on_send'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:91:in `block (2 levels) in trigger_responding_cops'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:113:in `with_cop_error_handling'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:90:in `block in trigger_responding_cops'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:89:in `each'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:89:in `trigger_responding_cops'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:61:in `block (2 levels) in <class:Commissioner>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:116:in `block in on_send'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:113:in `each'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:113:in `each_with_index'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:113:in `on_send'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:59:in `each'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.1.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/commissioner.rb:74:in `investigate'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/team.rb:151:in `investigate_partial'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cop/team.rb:83:in `investigate'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:295:in `inspect_file'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:245:in `block in do_inspection_loop'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:277:in `block in iterate_until_no_changes'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:270:in `loop'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:270:in `iterate_until_no_changes'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:241:in `do_inspection_loop'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:121:in `block in file_offenses'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:146:in `file_offense_cache'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:120:in `file_offenses'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:111:in `process_file'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `each'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `reduce'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:89:in `each_inspected_file'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:78:in `inspect_files'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/runner.rb:39:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli/command.rb:10:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli/environment.rb:17:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli.rb:65:in `run_command'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/lib/rubocop/cli.rb:41:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/exe/rubocop:13:in `block in <top (required)>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.88.0/exe/rubocop:12:in `<top (required)>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/bin/rubocop:23:in `load'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/bin/rubocop:23:in `<top (required)>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/dev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/dev/.rbenv/versions/2.7.1/bin/bundle:23:in `load'
/Users/dev/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
.

1 file inspected, no offenses detected
Finished in 0.11158400005660951 seconds

RuboCop version

$ [bundle exec] rubocop -V
0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.7.1 x86_64-darwin19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants