-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Style/ConditionalAssignment causes undefined method `column' for nil:NilClass #7165
Labels
Comments
8 tasks
Thanks for the feedback. I opened a PR #7166. |
koic
added a commit
to koic/rubocop
that referenced
this issue
Jun 24, 2019
Fixes rubocop#7165. This PR fixes an auto-correct error for `Style/ConditionalAssignment` when without `else` branch'. This error occurs when `EnforcedStyle: assign_inside_condition`. ```yaml # .rubocop.yml Style/ConditionalAssignment: EnforcedStyle: assign_inside_condition ``` ```ruby # example.rb var = if foo bar elsif baz qux end ``` ```console % rubocop -a --only Style/ConditionalAssignment Inspecting 1 file 0 files inspected, no offenses detected undefined method `column' for nil:NilClass /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:600:in `move_branch_' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:576:in `block (2 lev' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:575:in `each' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:575:in `block in mov' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/corrector.rb:64:in `block (2 levels) in rewrite' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/parser-2.6.3.0/lib/parser/source/tree_rewriter.rb:220:in `transaction' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/corrector.rb:63:in `block in rewrite' ```
bbatsov
pushed a commit
that referenced
this issue
Jun 25, 2019
Fixes #7165. This PR fixes an auto-correct error for `Style/ConditionalAssignment` when without `else` branch'. This error occurs when `EnforcedStyle: assign_inside_condition`. ```yaml # .rubocop.yml Style/ConditionalAssignment: EnforcedStyle: assign_inside_condition ``` ```ruby # example.rb var = if foo bar elsif baz qux end ``` ```console % rubocop -a --only Style/ConditionalAssignment Inspecting 1 file 0 files inspected, no offenses detected undefined method `column' for nil:NilClass /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:600:in `move_branch_' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:576:in `block (2 lev' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:575:in `each' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/style/conditional_assignment.rb:575:in `block in mov' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/corrector.rb:64:in `block (2 levels) in rewrite' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/parser-2.6.3.0/lib/parser/source/tree_rewriter.rb:220:in `transaction' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.71.0/lib/rubocop/cop/corrector.rb:63:in `block in rewrite' ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Do not raise exception.
Actual behavior
When
EnforcedStyle: assign_inside_condition
causes error:
Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: