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/UnneededPercentQ autofix breakage #4781

Closed
mockdeep opened this issue Sep 22, 2017 · 0 comments
Closed

Style/UnneededPercentQ autofix breakage #4781

mockdeep opened this issue Sep 22, 2017 · 0 comments
Assignees
Labels

Comments

@mockdeep
Copy link
Contributor

Ran into an issue with the Style/UnneededPercentQ rule. The autofix throws an error on the following code:

puts %q(foo bar baz) \
  'boogers'

Stack trace:

undefined method `empty?' for nil:NilClass
/home/fletch/.rvm/gems/ruby-2.3.3/gems/parser-2.4.0.0/lib/parser/source/rewriter.rb:249:in `append'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/parser-2.4.0.0/lib/parser/source/rewriter.rb:135:in `replace'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/corrector.rb:94:in `replace'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/style/unneeded_percent_q.rb:65:in `block in autocorrect'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/corrector.rb:56:in `block (2 levels) in rewrite'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/parser-2.4.0.0/lib/parser/source/rewriter.rb:194:in `transaction'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/corrector.rb:55:in `block in rewrite'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/corrector.rb:53:in `each'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/corrector.rb:53:in `rewrite'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:130:in `autocorrect_all_cops'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:68:in `autocorrect'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:96:in `block in offenses'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:113:in `investigate'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:92:in `offenses'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cop/team.rb:42:in `inspect_file'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:258:in `inspect_file'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:205:in `block in do_inspection_loop'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:237:in `block in iterate_until_no_changes'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:230:in `loop'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:230:in `iterate_until_no_changes'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:201:in `do_inspection_loop'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:111:in `block in file_offenses'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:121:in `file_offense_cache'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:109:in `file_offenses'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:100:in `process_file'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:78:in `block in each_inspected_file'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `reduce'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:75:in `each_inspected_file'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:67:in `inspect_files'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/runner.rb:39:in `run'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cli.rb:82:in `execute_runner'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/lib/rubocop/cli.rb:28:in `run'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/bin/rubocop:13:in `block in <top (required)>'
/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
/home/fletch/.rvm/gems/ruby-2.3.3/gems/rubocop-0.49.1/bin/rubocop:12:in `<top (required)>'
/home/fletch/.rvm/gems/ruby-2.3.3/bin/rubocop:23:in `load'
/home/fletch/.rvm/gems/ruby-2.3.3/bin/rubocop:23:in `<main>'
/home/fletch/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
/home/fletch/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'

Expected behavior

Rubocop auto fixes the violation.

Actual behavior

An error is thrown.

Steps to reproduce the problem

run rubocop -a on a file with the above code.

RuboCop version

$ rubocop -V
0.49.1 (using Parser 2.4.0.0, running on ruby 2.3.3 x86_64-linux)
@pocke pocke added the bug label Nov 10, 2017
@pocke pocke self-assigned this Nov 10, 2017
pocke added a commit to pocke/rubocop that referenced this issue Nov 11, 2017
…strings that is concated with backslash

`Style/UnneededPercentQ` raises an error when it is auto-correcting the following code.

```ruby
puts %q(foo bar baz) \
  'boogers'
```

This change will fix this problem.
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