opinions on RuboCop

as a Ruby noobie I’m still trying to figure out best practices and such, so I was wondering what people’s opinions were on RuboCop. I’m generally a fan of linting and static analysis, but I know it’s a divisive topic.

I also noticed that running rubocop on a fresh Hanami project results in a lot of errors, so I’m assuming it isn’t used by the core team?

Hanami does use Rubocop, but it’s pretty well configured: hanami/.rubocop.yml at main · hanami/hanami · GitHub

I personally find the default rules of Rubocop to be over-bearing and so typically turn off a bunch of things like Style/StringLiterals, Style/TrailingCommaInArrayLiteral, etc.

There’s an alternative out there in StandardRB that some people swear by. It provides you a set of rules as-is, and does not allow for the type of configuration that Rubocop does.

1 Like

The RuboCop config linked by Ryan is really only intended for our internal repos, not for Hanami apps themselves. If you take a look at the config, it has a lot of rules configured or disabled that we’ve accrued over the years. I definitely wouldn’t recommend it as a starting point for others.

For Hanami apps, I’d second Ryan’s suggestion of Standard, either used directly, or running its rules via RuboCop. That’s pretty much how I roll when I build apps. See decafsucks/.rubocop.yml at main · decafsucks/decafsucks · GitHub, for example.