Skip to content
I Love Standardrb
February 28 2019

How do you format your ruby code across developers and projects?

I confess, I’m in love with standardrb. I’ve used other formatting tools like the hound and rubocop, but standardrb is great because it takes all the choice away from me. I’ll be honest, I didn’t even look at the ruleset; the fact that some great ruby consultancies use it is enough for me. I just install the tool using bundle, add it to a pre commit hook, and all the ruby code I check in is formatted beautifully. And if there are any other flaws in my code that standardrb can catch (like an unused variable), they are noted before my code even commits.

Here’s my precommit hook.

if git rev-parse --verify HEAD >/dev/null 2>&1
        # Initial commit: diff against an empty tree object

# Redirect output to stderr.
exec 1>&2

standardrb --fix app test config

The one issue I have is that when changes are made by standardrb, the commit fails, but I have to remember to re-add the modified files. Nothing a little –amend can’t fix, but slightly annoying.

Sometimes taking choice away gives you more freedom. Try standardrb today.

Culture Foundry is a digital experience agency that helps our clients elevate their impact with beautiful technology. We provide the expertise and insight at every layer that makes a great digital experience for websites and applications possible. If you're committed to elevating your digital experience, contact us and we'd be happy to schedule a chat to see if we're a fit.

(Psst! We also happen to be a great place to work.)

Back To Top