I’ve been writing in the Ruby language since sometime in 2002, but if I was looking for a job, I don’t know enough to call myself a ruby programmer. I don’t know rails or anything of the other cool things people do with ruby. I’ve learned to use gems, but haven’t bothered to learn how to write them myself.
But I’m not opposed to learning. I just haven’t gotten around to it yet.
Or so I thought. Then I ran into rubocop, which is a sort of linter and style cop. Those can be helpful, so I thought I’d give it a try. And it’s mostly good. Except it’s opinionated, and some of their opinions are wrong. For example:
- the indentation should be four spaces, not two as they suggest
- parallel assignment is the bomb, despite what they say
- I use double quotes (
") pretty much everywhere I’m not forced to use single quotes (
'). They want to save time for the compiler, I guess.
- You need space inside parentheses (although I will grant the extra whitespace is less important with syntax highlighting than without it).
- And if I’m declaring a RE that’s so complicated I’m using /x flag, then don’t tell me to use
- And speaking of which, go ahead and use
$'when retrieving the results of an RE match. (In moderation.) Honestly, this is a tie. Go ahead and use named groups if you want to.
But you can’t fight city hall. If some younglings want to make Ruby over in the style of Python, well, that’s a crying shame. Ruby is supposed to occupy the perfect spot between Perl and Python. But these kids today! If they’re on your lawn, you might as well go along with their misguided project. And that brings us to rufo, the ruby reformatter. You can use it to do like 10% of the things that rubocop whinges about.
Leave a Reply
You must be logged in to post a comment.