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

Regression for UnneededPercentQ? #2434

Closed
backus opened this issue Nov 16, 2015 · 2 comments
Closed

Regression for UnneededPercentQ? #2434

backus opened this issue Nov 16, 2015 · 2 comments

Comments

@backus
Copy link
Contributor

backus commented Nov 16, 2015

Example:

$ rubocop -v
0.35.1
$ cat ex.rb .rubocop.yml
# encoding: utf-8

interpolation = 'hello'

%Q(example "with quotes" and #{interpolation})

---
Style/BarePercentLiterals:
  EnforcedStyle: percent_q
  SupportedStyles:
  - percent_q
  - bare_percent
$ rubocop ex.rb
Inspecting 1 file
C

Offenses:

ex.rb:5:1: C: Use %Q only for strings that contain both single quotes and double quotes, or for dynamic strings that contain double quotes.
%Q(example "with quotes" and #{interpolation})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

Gist for files in question: https://gist.github.com/backus/f341a4b92e54fa376211

Bisecting this points to 0ad7df5 I think

@backus
Copy link
Contributor Author

backus commented Nov 16, 2015

Making the following change (which was present before #2274) seems to fix the issue and also does not break any specs

diff --git i/lib/rubocop/cop/style/unneeded_percent_q.rb w/lib/rubocop/cop/style/unneeded_percent_q.rb
index 055f002..5bad397 100644
--- i/lib/rubocop/cop/style/unneeded_percent_q.rb
+++ w/lib/rubocop/cop/style/unneeded_percent_q.rb
@@ -16,7 +16,7 @@ module RuboCop
         STRING_INTERPOLATION_REGEXP = /#\{.+}/

         def on_dstr(node)
-          check(node)
+          check(node) unless node.loc.expression.source =~ /"/
         end

         def on_str(node)

@backus
Copy link
Contributor Author

backus commented Nov 16, 2015

I thought I was checking against master but looks like I had an old revision :(. Ignore me this was fixed #2419.

@backus backus closed this as completed Nov 16, 2015
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

No branches or pull requests

1 participant