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

DotPosition cop breaks on lambda call with '.()' #394

Closed
dirkbolte opened this issue Jul 25, 2013 · 2 comments
Closed

DotPosition cop breaks on lambda call with '.()' #394

dirkbolte opened this issue Jul 25, 2013 · 2 comments
Labels

Comments

@dirkbolte
Copy link
Contributor

The following code results in an exception in the DotPosition cop:

# encoding: UTF-8
l = ->(p) { puts p }
l.(1)

Resulting callstack is:

An error occurred while DotPosition cop was inspecting /tmp/test.rb.
undefined method `line' for nil:NilClass
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cop/style/dot_position.rb:22:in `proper_dot_position?'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cop/style/dot_position.rb:13:in `on_send'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cop/commissioner.rb:80:in `delegate_to'
(eval):4:in `block in on_send'
(eval):2:in `each'
(eval):2:in `on_send'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/ast-1.1.0/lib/ast/processor.rb:239:in `process'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/ast-1.1.0/lib/ast/processor.rb:255:in `block in process_all'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/ast-1.1.0/lib/ast/processor.rb:254:in `map'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/ast-1.1.0/lib/ast/processor.rb:254:in `process_all'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/parser-2.0.0.pre2/lib/parser/ast/processor.rb:6:in `process_regular_node'
(eval):8:in `on_begin'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/ast-1.1.0/lib/ast/processor.rb:239:in `process'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cop/commissioner.rb:54:in `investigate'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cli.rb:109:in `inspect_file'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cli.rb:58:in `block in run'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cli.rb:52:in `each'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/lib/rubocop/cli.rb:52:in `run'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/bin/rubocop:14:in `block in <top (required)>'
/home/dirkbolte/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/gems/rubocop-0.10.0/bin/rubocop:13:in `<top (required)>'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/bin/rubocop:19:in `load'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/bin/rubocop:19:in `<main>'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
/home/dirkbolte/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'

Version information:
Mention the following information in the issue report:
0.10.0 (using Parser 2.0.0.pre2, running on ruby 1.9.3 x86_64-linux)

@dirkbolte
Copy link
Contributor Author

Anyhow I wonder whether this syntax would be something to add as BAD for the ruby coding style.

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 27, 2013

Yep, it's not something I'd consider good style. l[1] is also pretty confusing since it looks a lot like element access. Please, create a ticket on the style guide so we won't forget to add a rule about this.

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

No branches or pull requests

2 participants