Skip to content

Prefer single-quoted strings #437

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

Merged

Conversation

mariusbutuc
Copy link
Contributor

RuboCop's Style/StringLiterals recommends to:

Prefer single-quoted strings when you don't need string interpolation or special symbols

I understand that the camps are divided around nitpicks like this one, but this minimal and inexpensive change—in both the docs and the generated code—can reduce number of notices a new user would get.

  * when you don't need string interpolation or special symbols
@mariusbutuc
Copy link
Contributor Author

Or, I could quote @fxn 😄

prefer single quotes, by the beard of the prophet!

@grosser
Copy link
Collaborator

grosser commented Sep 19, 2015

I don't really care either way ... but want to throw in this: https://viget.com/extend/just-use-double-quoted-ruby-strings

afaik there is no significant performance benefit ... avoiding a few rubocop warnings for whoever pastes code is nice ... but I've also seen projects use double-quoted style ... so meh :D

@jonleighton
Copy link
Member

Personally, I prefer double quotes, because there's no performance benefit to single quotes, and I hate having to convert the quoting style just to be able to use interpolation.

That said, this PR is really about what style we use in the generated code. If the rest of the code generated by Rails uses single quotes (does it?), we should also probably use single quotes for consistency I suppose.

@fxn
Copy link
Member

fxn commented Sep 30, 2015

Yes, Rails has that convention (and the reasoning is not performance, I don't know who started that myth).

@rafaelfranca
Copy link
Member

👍 for the change in the generated code, but not for spring code. @mariusbutuc could you update your pull request to change only the generated code?

@rafaelfranca
Copy link
Member

Looks like everything in this PR is in the generated code. Thanks!

rafaelfranca added a commit that referenced this pull request Oct 3, 2015
@rafaelfranca rafaelfranca merged commit 354637f into rails:master Oct 3, 2015
@mariusbutuc mariusbutuc deleted the prefer-single-quoted-strings branch October 3, 2015 02:11
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

Successfully merging this pull request may close these issues.

5 participants