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

[Fix #7759] Fix an error for Layout/LineLength #7760

Merged
merged 1 commit into from Feb 29, 2020

Conversation

koic
Copy link
Member

@koic koic commented Feb 26, 2020

Fixes #7759.

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

% cat example.rb
-> x {}
% 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'

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the fix_an_error_for_layout_line_length branch from ad40f28 to 1423e27 Compare February 26, 2020 10:37
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'
```
@koic koic force-pushed the fix_an_error_for_layout_line_length branch from 1423e27 to d90867d Compare February 26, 2020 11:51
@bbatsov bbatsov merged commit 63c7666 into rubocop:master Feb 29, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 29, 2020

Thanks!

@koic koic deleted the fix_an_error_for_layout_line_length branch February 29, 2020 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layout/LineLength error
3 participants