← Back to Upcase

Github vs bbatsov Ruby Style Guides


(Justin Gordon) #1

Has anybody outlined the differences and their opinions between the Gitub Ruby Style Guide vs. the BBatsov Ruby Style Guide?

The main difference I’ve noticed is the consistent use of “” for all strings vs. only using “” for strings that are doing interpolation. I got started on the latter, so my fingers seem to prefer using ‘’ for strings unless interpolation is needed.


(Geoff Harcourt) #2

I think it’s important to just find style guidelines you and your teammates can agree on, and then to stick to it. There’s parts of the Github, BBatsov/Rubocop and Thoughtbot style guides that I like, and parts I don’t. Just find things that work for you, and pay attention to when people that you respect do things differently, because there might be a good reason why.


(Nicholas Shook) #3

fwiw, I prefer rubocop. I use guard-rubocop which I think is a great way to ensure the aesthetics of the code throughout the system. I did disable the 80 character line-limit and the top level comment (I hate writing comments).

Like you I like the ‘’ for strings that don’t have interpolation. I just think it looks nicer.


(rubylove.io) #4

I still prefer to say what I mean and mean what I say (PoLS)…

immutable_str = 'something cool here'
interop = "#{immutable_str}, how awesome is that?"

I will freely admit this comes from back when i did ASP.Net work and strings were killing app performance due to garbage collection. Since then i have been careful about what kind of string i use.

I am also into ruby-functional coding, so I prefer values and idempotency. To me, this style of stringing goes along with that, as well as PoLS.


(Pedro Nascimento) #5

If you are thinking about using rubocop: vim plugin syntastic supports it.

Just make sure you have the gem and the syntastic installed and add:

let g:syntastic_ruby_checkers = ['mri', 'rubocop']

To your vimrc file.