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

Layout/LineLength error #7759

Closed
hanachin opened this issue Feb 26, 2020 · 0 comments · Fixed by #7760
Closed

Layout/LineLength error #7759

hanachin opened this issue Feb 26, 2020 · 0 comments · Fixed by #7760
Labels

Comments

@hanachin
Copy link
Contributor

Expected behavior

Same as

% echo '-> x { { a: 1 } }' | rubocop _0.79.0_ --stdin foo.rb --only Layout/LineLength
Inspecting 1 file
.

1 file inspected, no offenses detected

Actual behavior

% echo '-> x { { a: 1 } }' | rubocop _0.80.0_ --debug --stdin foo.rb --only Layout/LineLength
For /tmp/bug: configuration from /home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/config/default.yml
Inspecting 1 file
Scanning /tmp/bug/foo.rb
An error occurred while Layout/LineLength cop was inspecting /tmp/bug/foo.rb:1:0.
undefined method `begin_pos' for nil:NilClass
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/layout/line_length.rb:127:in `check_for_breakable_block'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/layout/line_length.rb:71:in `on_block'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:136:in `with_cop_error_handling'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:55:in `each'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:124:in `investigate'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:112:in `offenses'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:44:in `inspect_file'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:296:in `inspect_file'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:244:in `block in do_inspection_loop'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:269:in `loop'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:269:in `iterate_until_no_changes'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:240:in `do_inspection_loop'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:119:in `block in file_offenses'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:143:in `file_offense_cache'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:117:in `file_offenses'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:108:in `process_file'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `each'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `reduce'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `each_inspected_file'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:73:in `inspect_files'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:39:in `run'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli/command.rb:10:in `run'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli/environment.rb:17:in `run'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:65:in `run_command'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:41:in `run'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/exe/rubocop:13:in `block in <top (required)>'
/home/sei/.rbenv/versions/master/lib/ruby/2.8.0/benchmark.rb:308:in `realtime'
/home/sei/.rbenv/versions/master/lib/ruby/gems/2.8.0/gems/rubocop-0.80.0/exe/rubocop:12:in `<top (required)>'
/home/sei/.rbenv/versions/master/bin/rubocop:23:in `load'
/home/sei/.rbenv/versions/master/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Layout/LineLength cop was inspecting /tmp/bug/foo.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.80.0 (using Parser 2.7.0.2, running on ruby 2.8.0 x86_64-linux)
Finished in 0.18920945399804623 seconds

Steps to reproduce the problem

echo '-> x { { a: 1 } }' | rubocop _0.80.0_ --debug --stdin foo.rb --only Layout/LineLength

RuboCop version

$ rubocop -V
0.80.0 (using Parser 2.7.0.2, running on ruby 2.8.0 x86_64-linux)
@koic koic added the bug label Feb 26, 2020
koic added a commit to koic/rubocop that referenced this issue Feb 26, 2020
Fixes rubocop#7759.

This PR fixes the following error for `Layout/LineLength` cop when
using lambda syntax that argument is not enclosed in parentheses.

```ruby
% cat example.rb
-> x {}
```

```console
% bundle exec rubocop --only Layout/LineLength -d
(snip)

An error occurred while Layout/LineLength cop was inspecting
/Users/koic/src/github.com/koic/rubocop-issues/7759/example.rb:1:0.
undefined method `begin_pos' for nil:NilClass
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/layout/line_length.rb:127:in
`check_for_breakable_block'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/layout/line_length.rb:71:in
`on_block'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:57:in
`block (2 levels) in trigger_responding_cops'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:136:in
`with_cop_error_handling'
```
bbatsov pushed a commit that referenced this issue Feb 29, 2020
Fixes #7759.

This PR fixes the following error for `Layout/LineLength` cop when
using lambda syntax that argument is not enclosed in parentheses.

```ruby
% cat example.rb
-> x {}
```

```console
% bundle exec rubocop --only Layout/LineLength -d
(snip)

An error occurred while Layout/LineLength cop was inspecting
/Users/koic/src/github.com/koic/rubocop-issues/7759/example.rb:1:0.
undefined method `begin_pos' for nil:NilClass
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/layout/line_length.rb:127:in
`check_for_breakable_block'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/layout/line_length.rb:71:in
`on_block'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:57:in
`block (2 levels) in trigger_responding_cops'
/Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:136:in
`with_cop_error_handling'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants