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

Partial indentation of some nested calls raises an error in Style/FirstParameterIndentation #2006

Closed
awwaiid opened this issue Jul 1, 2015 · 0 comments
Labels

Comments

@awwaiid
Copy link
Contributor

awwaiid commented Jul 1, 2015

Ran into an exception raised by Style/FirstParameterIndentation in some badly indented code. I narrowed it down quite a bit (though this might not be completely minimal. I might look into a fix, but wanted to record the issue in case I don't get to it.

bwilcox@koopa:~/tmp/rubocop$ ./bin/rubocop -v                                 [master]
0.32.1
bwilcox@koopa:~/tmp/rubocop$ cat failing_rubocop.rb                           [master]
foo(
 bar(
  7
))
bwilcox@koopa:~/tmp/rubocop$ ./bin/rubocop -d failing_rubocop.rb              [master]
Inspecting 1 file
Scanning /home/bwilcox/tmp/rubocop/failing_rubocop.rb
For /home/bwilcox/tmp/rubocop: configuration from /home/bwilcox/tmp/rubocop/.rubocop.yml
Inheriting configuration from /home/bwilcox/tmp/rubocop/.rubocop_todo.yml
Default configuration from /home/bwilcox/tmp/rubocop/config/default.yml
Inheriting configuration from /home/bwilcox/tmp/rubocop/config/enabled.yml
Inheriting configuration from /home/bwilcox/tmp/rubocop/config/disabled.yml
An error occurred while Style/FirstParameterIndentation cop was inspecting /home/bwilcox/tmp/rubocop/failing_rubocop.rb.
undefined method `parent' for nil:NilClass
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/style/first_parameter_indentation.rb:42:in `message'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/cop.rb:162:in `add_offense'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/mixin/autocorrect_alignment.rb:27:in `block in check_alignment'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/mixin/autocorrect_alignment.rb:16:in `each'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/mixin/autocorrect_alignment.rb:16:in `check_alignment'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/style/first_parameter_indentation.rb:35:in `on_send'
(eval):5:in `block (2 levels) in on_send'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/commissioner.rb:92:in `with_cop_error_handling'
(eval):4:in `block in on_send'
(eval):2:in `each'
(eval):2:in `on_send'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/ast-2.0.0/lib/ast/processor.rb:239:in `process'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/ast-2.0.0/lib/ast/processor.rb:255:in `block in process_all'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/ast-2.0.0/lib/ast/processor.rb:254:in `map'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/ast-2.0.0/lib/ast/processor.rb:254:in `process_all'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/parser-2.2.2.6/lib/parser/ast/processor.rb:143:in `on_send'
(eval):9:in `on_send'
/home/bwilcox/.rvm/gems/ruby-2.0.0-p451/gems/ast-2.0.0/lib/ast/processor.rb:239:in `process'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/commissioner.rb:52:in `investigate'
/home/bwilcox/tmp/rubocop/lib/rubocop/cop/team.rb:33:in `inspect_file'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:135:in `inspect_file'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:106:in `block in do_inspection_loop'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:100:in `loop'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:100:in `do_inspection_loop'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:78:in `process_file'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:53:in `block in inspect_files'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:51:in `each'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:51:in `inspect_files'
/home/bwilcox/tmp/rubocop/lib/rubocop/runner.rb:30:in `run'
/home/bwilcox/tmp/rubocop/lib/rubocop/cli.rb:26:in `run'
./bin/rubocop:13:in `block in <main>'
/home/bwilcox/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
./bin/rubocop:12:in `<main>'
C

Offenses:

failing_rubocop.rb:1:1: C: Style/Encoding: Missing utf-8 encoding comment.
foo(
^
failing_rubocop.rb:2:2: C: Style/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
 bar(
 ^^^^
failing_rubocop.rb:4:1: C: Style/ClosingParenthesisIndentation: Indent ) the same as the start of the line where ( is.
))
^

1 file inspected, 3 offenses detected

1 error occurred:
An error occurred while Style/FirstParameterIndentation cop was inspecting /home/bwilcox/tmp/rubocop/failing_rubocop.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.32.1 (using Parser 2.2.2.6, running on ruby 2.0.0 x86_64-linux)
Finished in 0.018936341 seconds
@jonas054 jonas054 added the bug label Jul 12, 2015
bbatsov added a commit that referenced this issue Jul 22, 2015
[Fix #2006] Fix crash in case of nested offenses
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