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

[RUBY] Single quotes preferred style #565

Closed
wants to merge 1 commit into from

Conversation

ssunday
Copy link

@ssunday ssunday commented Aug 19, 2019

Why:

Update:

This: #174 (comment)

@iwz
Copy link
Contributor

iwz commented Aug 19, 2019

The change to double quotes was a controversial discussion when introduced. You may find the discussion, reasoning, and eventual decision interesting, @ssunday #174

Personally, since adopting this change to always use double quotes, I've always appreciated not having to think about which quotes to use.

@mike-burns
Copy link
Contributor

mike-burns commented Aug 19, 2019

Some context on how this PR came to be: @ssunday is collaborating with us on a project in NYC and has had to debug our code.

Some history of the thoughtbot styleguide with a focus on quote marks:

  • We started the styleguide so we could stop having discussions about arbitrary style and just pick one thing without ever changing it.
  • We originally specified single quotes, as was the Ruby style at the time.
  • Someone proposed changing an arbitrary thing we picked. That was rejected, because that defeats the point of no longer discussing these things.
  • Someone proposed changing it again, and it was changed.
  • We figured that if we can change arbitrary things we might as well re-discuss quotes.
  • We changed to double quotes, as was the Ruby style at the time.

As usual I'd like to promote the idea of deleting the style/ directory entirely.

@ssunday
Copy link
Author

ssunday commented Aug 20, 2019

@iwz It's a really interesting thread! Lots definitely changed since then...and not at all! Some of the points brought up are still true (both sides).

With rubocop autofixing where it is, enforcing single/double quotes removes the Human adoption element to a degree. You could 'forget' to use single and it corrects it if it could/should. (This is assuming rubocop is also being used to correct things). So to me, this then comes to what is easier to read and manage. Are single quotes easier for our minds to process? It takes up less visual space...does it add up? To me, it looks cleaner and seems more elegant.

Also, which has been said: #174 (comment)

/s: Has there been studies if double quote usage increases chances of developing Carpal Tunnel Syndrome?? end/s

@odlp
Copy link

odlp commented Sep 6, 2019

Personally, since adopting this change to always use double quotes, I've always appreciated not having to think about which quotes to use.

I particularly appreciate this when writing test descriptions. Please excuse the overly specific example - but I hope it provides a useful illustration.

Say I'm trying to describe the edge-cases where something shouldn't take place:

RSpec.describe Foo do
  it 'doesn' # Brain: Uh oh...
end

One then has to break their flow and pick an option...

  1. Convert to double quotes and continue:
it "doesn't notify via Slack"
  1. Reword to avoid contractions:
it 'does not notify via Slack' # Hmm I didn't want to replace "doesn't" with "does not"
  1. Be lawful evil (aside: Is this how this Alignments thing works?):
it 'does\'t notify via Slack' # Nope

@JoelQ
Copy link
Contributor

JoelQ commented Sep 6, 2019

Inspired by @odlp's comment, I threw this together 😂😂😂

Good Neutral Evil
Lawful 'does not' 'doesn’t' 'doesn\'t'
Neutral %q{doesn't} "doesn't" 'doesnt'
Chaotic <<TXT.chomp don't TXT "doesn#{"'"}t" 'doesn'"'"'t'

@mike-burns
Copy link
Contributor

@jferris I don't know how to move this PR forward, in any direction. Do you?

@ssunday
Copy link
Author

ssunday commented Sep 6, 2019

@odlp if you're assuming people are automatically doing this....to me, you could use double quotes and have the linter enforce the proper option. Converting to double quotes for apostrophes is also, I think, acceptable, as sometimes you'll need to use double quotes anyway for other reasons. The goal isn't to eliminate double quotes, but have single quotes be preferred as it's easier to type and parse.

@jferris
Copy link
Contributor

jferris commented Sep 6, 2019

I'm going to close this pull request, because I'm not convinced that going back to single quotes will be worth the required changes we'd need to make.

People are welcome to continue discussing quoting styles, but I don't plan on merging this.

@jferris jferris closed this Sep 6, 2019
@ssunday ssunday deleted the rubocop-suggestions branch September 6, 2019 17:24
@ssunday
Copy link
Author

ssunday commented Sep 6, 2019

@jferris 👍 It's your style guide/linters to run, can't argue with that perspective.

@composerinteralia
Copy link
Contributor

More information for the next time this comes up: Rails itself prefers double quotes and they plan to clean up any lingering single quotes.

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.

7 participants