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/StringLiterals: link_to '#foo' not detected as violating double_quotes #3037

Closed
paulkoegel opened this issue Apr 12, 2016 · 2 comments
Closed

Comments

@paulkoegel
Copy link

link_to '#foo' is not detected as violating Style/StringLiterals set to double_quotes.

Sample code with comments:

link_to '#foo' # should raise a Rubocop error but doesn't :(
link_to 'jim', key: 'value' # correctly detected ^_^
link_to "bob", key: "other value" # passes, move along :)

Expected behavior

link_to '#foo' should be detected as not using double quotes

Actual behavior

it is not detected although it uses single quotes. When chaning the string to 'foo' it does get detected.
Output from sample repository:

rubocop
Inspecting 2 files
.C

Offenses:

test.rb:2:9: C: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
link_to 'jim', key: 'value' # correctly detected ^_^
        ^^^^^
test.rb:2:21: C: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
link_to 'jim', key: 'value' # correctly detected ^_^
                    ^^^^^^^

2 files inspected, 2 offenses detected

Steps to reproduce the problem

Please see sample repository: https://github.com/paulkogel/rubocop-bug
bundle install and run rubocop

RuboCop version

0.39.0

$ rubocop -V
0.39.0 (using Parser 2.3.0.7, running on ruby 2.3.0 x86_64-darwin15)
@paulkoegel paulkoegel changed the title link_to '#foo' is not detected as violating Style/StringLiterals set to double_quotes. Style/StringLiterals: link_to '#foo' not detected as violating double_quotes Apr 12, 2016
@deivid-rodriguez
Copy link
Contributor

Dupe of #3017, I think.

@jonas054
Copy link
Collaborator

Not exactly. We'll keep both issues open, because # is a 7-bit ASCII character, so it's a different bug than the failure to report strings with, for example, ñ in them.

@bbatsov bbatsov closed this as completed in 8e01f15 Jun 6, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
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

3 participants