{"action":"opened","issue":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/3597","repository_url":"https://api.github.com/repos/bbatsov/rubocop","labels_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3597/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3597/comments","events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3597/events","html_url":"https://github.com/bbatsov/rubocop/issues/3597","id":182263412,"number":3597,"title":"Rubocop crashes on splat operator in case/when block when in auto-correct mode","user":{"login":"rpherbig","id":1181607,"avatar_url":"https://avatars.githubusercontent.com/u/1181607?v=3","gravatar_id":"","url":"https://api.github.com/users/rpherbig","html_url":"https://github.com/rpherbig","followers_url":"https://api.github.com/users/rpherbig/followers","following_url":"https://api.github.com/users/rpherbig/following{/other_user}","gists_url":"https://api.github.com/users/rpherbig/gists{/gist_id}","starred_url":"https://api.github.com/users/rpherbig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpherbig/subscriptions","organizations_url":"https://api.github.com/users/rpherbig/orgs","repos_url":"https://api.github.com/users/rpherbig/repos","events_url":"https://api.github.com/users/rpherbig/events{/privacy}","received_events_url":"https://api.github.com/users/rpherbig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-11T13:27:01Z","updated_at":"2016-10-11T13:27:01Z","closed_at":null,"body":"--------\r\n\r\n## Expected behavior\r\n\r\nRunning rubocop in auto-correct mode should behave the same as normal mode, but also fix as many issues as possible. This is the output in normal mode:\r\n\r\n```\r\n$ rubocop crash.rb\r\nInspecting 1 file\r\nW\r\n\r\nOffenses:\r\n\r\ncrash.rb:1:11: C: Use %w or %W for an array of words.\r\nresults = ['a', 'b']\r\n          ^^^^^^^^^^\r\ncrash.rb:2:6: W: Literal 'a' appeared in a condition.\r\ncase 'a'\r\n     ^^^\r\ncrash.rb:3:1: C: Place when conditions with a splat at the end of the when branches.\r\nwhen *results, 'c'\r\n^^^^^^^^^^^^^\r\ncrash.rb:7:4: C: Final newline missing.\r\nend\r\n```\r\n\r\n## Actual behavior\r\n\r\nHowever, rubocop crashes on the same code in auto-correct mode:\r\n\r\n```\r\n$ rubocop --auto-correct crash.rb\r\nInspecting 1 file\r\n\r\n\r\n0 files inspected, no offenses detected\r\nundefined method `source_range' for nil:NilClass\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/performance/case_when_splat.rb:126:in `when_branch_range'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/performance/case_when_splat.rb:110:in `reorder_condition'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/performance/case_when_splat.rb:86:in `block in autocorrect'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/corrector.rb:57:in `call'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/corrector.rb:57:in `block (2 levels) in rewrite'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/parser-2.3.1.4/lib/parser/source/rewriter.rb:194:in `transaction'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/corrector.rb:56:in `block in rewrite'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/corrector.rb:54:in `each'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/corrector.rb:54:in `rewrite'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:145:in `autocorrect_all_cops'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:77:in `autocorrect'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:105:in `block in offenses'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:122:in `investigate'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:101:in `offenses'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cop/team.rb:52:in `inspect_file'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:244:in `inspect_file'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:191:in `block in do_inspection_loop'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:223:in `block in iterate_until_no_changes'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:216:in `loop'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:216:in `iterate_until_no_changes'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:187:in `do_inspection_loop'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:102:in `block in file_offenses'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:112:in `file_offense_cache'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:100:in `file_offenses'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:91:in `process_file'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:69:in `block in each_inspected_file'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:66:in `each'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:66:in `reduce'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:66:in `each_inspected_file'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:58:in `inspect_files'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/runner.rb:37:in `run'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cli.rb:72:in `execute_runner'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/lib/rubocop/cli.rb:28:in `run'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/bin/rubocop:14:in `block in <top (required)>'\r\nc:/Ruby200/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'\r\nc:/Ruby200/lib/ruby/gems/2.0.0/gems/rubocop-0.43.0/bin/rubocop:13:in `<top (required)>'\r\nc:/Ruby200/bin/rubocop:23:in `load'\r\nc:/Ruby200/bin/rubocop:23:in `<main>'\r\n```\r\n\r\n## Steps to reproduce the problem\r\n\r\nI made a simple ruby file that demonstrates the problem. Run Rubocop on it twice to see the problem (once with auto-correct, once without):\r\n```\r\nresults = ['a', 'b']\r\ncase 'a'\r\nwhen *results, 'c'\r\n  puts 'true'\r\nelse\r\n  puts 'false'\r\nend\r\n```\r\n\r\n## RuboCop version\r\n\r\n```\r\n$ rubocop -V\r\n0.43.0 (using Parser 2.3.1.4, running on ruby 2.0.0 i386-mingw32)\r\n```\r\n"}}
{"actor":{"display_login":"rpherbig"}}