Github vs bbatsov Ruby Style Guides

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.

1 Like

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.

1 Like

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.

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.

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.

1 Like