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

Style/ConditionalAssignment when hitting for ... in loops #4414

Closed
tomdracz opened this issue May 24, 2017 · 0 comments
Closed

Style/ConditionalAssignment when hitting for ... in loops #4414

tomdracz opened this issue May 24, 2017 · 0 comments
Labels

Comments

@tomdracz
Copy link

tomdracz commented May 24, 2017

I've just updated Rubocop to release 0.49.0 and hitting error while hitting for ... in loops. I pinpointed the issue to the use of Style/ConditionalAssignment cop while enforcing assign_inside_condition
Stack trace below:

An error occurred while Style/ConditionalAssignment cop was inspecting An error occurred while Style/ConditionalAssignment cop was inspecting /Users/tom/Hanover/test.rb:1:4.
undefined method `begin_type?' for :i:Symbol
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/style/conditional_assignment.rb:304:in `assignment_node'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/style/conditional_assignment.rb:274:in `check_assignment_to_condition'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/style/conditional_assignment.rb:233:in `block (2 levels) in <class:ConditionalAssignment>'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:44:in `block (2 levels) in on_lvasgn'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:106:in `with_cop_error_handling'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:43:in `block in on_lvasgn'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:42:in `each'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:42:in `on_lvasgn'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/ast/traversal.rb:161:in `block in on_case'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/ast/traversal.rb:160:in `each'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/ast/traversal.rb:160:in `on_case'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:48:in `on_for'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/ast/traversal.rb:12:in `walk'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/commissioner.rb:60:in `investigate'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/team.rb:112:in `investigate'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/team.rb:100:in `offenses'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cop/team.rb:42:in `inspect_file'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:258:in `inspect_file'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:205:in `block in do_inspection_loop'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:237:in `block in iterate_until_no_changes'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:230:in `loop'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:230:in `iterate_until_no_changes'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:201:in `do_inspection_loop'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:111:in `block in file_offenses'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:121:in `file_offense_cache'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:109:in `file_offenses'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:100:in `process_file'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:78:in `block in each_inspected_file'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:75:in `each'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:75:in `reduce'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:75:in `each_inspected_file'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:67:in `inspect_files'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/runner.rb:39:in `run'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cli.rb:82:in `execute_runner'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/lib/rubocop/cli.rb:28:in `run'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/bin/rubocop:13:in `block in <top (required)>'
/Users/tom/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/gems/rubocop-0.49.0/bin/rubocop:12:in `<top (required)>'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/bin/rubocop:23:in `load'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/bin/rubocop:23:in `<main>'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/bin/ruby_executable_hooks:15:in `eval'
/Users/tom/.rvm/gems/ruby-2.4.1@hanover/bin/ruby_executable_hooks:15:in `<main>'


Expected behavior

No errors, apart from style errors appear

Actual behavior

Rubocop error occurs

Steps to reproduce the problem

Run rubocop on simple file like:

for i in [1,2,3]
  puts i
end

With cop

Style/ConditionalAssignment:
  EnforcedStyle: assign_inside_condition

RuboCop version

$ rubocop -V
0.49.0 (using Parser 2.4.0.0, running on ruby 2.4.1 x86_64-darwin16)
@bbatsov bbatsov added the bug label May 24, 2017
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