standard
standard copied to clipboard
Add a rubocop-rails ruleset
[rubocop-rails(https://github.com/rubocop/rubocop-rails) has come a long way since we started the Standard project, and there's a lot in it that I think Standard could benefit from.
My approach to integrating it would look a lot like how we incorporate rubocop-performance, currently. However, there are a couple wrinkles:
- rubocop-rails has a hard dep on activesupport, which means if we add it as a hard dep on standard, people avoiding Rails-related gems in their project would get it whether they want it or not and —though it's
>=
—could create transitive pain for some users. We should investigate ways of enabling it without adding it as a hard runtime dep for all users all the time. - We should inspect what rubocop-rails already does to detect Rails apps vs. non-Rails projects, and (since Standard is all about defaults), we should do our best to intelligently only lint when we're sure we're in a Rails app.
- I suspect whatever we do in (2) will not be perfect, so we probably need a config flag for rails: true/false
Thoughts?
If there's one thing I learned using rubocop-rails it's that it's not all that great at determining what is or isn't a Rails app.
It's not awful at it, and I'm sure it will be helpful, but don't look to it as a goal.
Thanks for the advice
Maybe for standard
maintainers it's easier to have a standard-rails
gem? It could use standard
as a dependency, and add rubocop-rails
.
This way from a standard
perspective you wouldn't need to care about Rails apps, and from standard-rails
you can assume it's being used in a Rails app.
Hi @searls,
unfortunately, this issue has not seen any activity since almost one year. I wonder if you have plans for adding this in the near future?
I am really looking forward to have a rails ruleset integrated. They way @mrcasals proposed seems like a good idea. What do you think?
I think that this is the right architectural perspective, but after discussing with a lot of users of rubocop-rails, I've not found very many endorsements that it would be worthwhile (put differently, I haven't seen much evidence that an opinionated, fixed ruleset could be chosen and meet our expectations for universality, consistency, and reasonability).
I'll take a second look
Thank you for your quick anwer and explanation.
I think it would still be worthwile to have an opinionated ruleset, even if it does not meet the high standards in the beginning, compared to having no ruleset at all.
One of the big advantages still is not having to argue about rules if there is one standard 👍
I can't wait to start using standard-rails and others given the recent update :raised_hands:
@xdmx stay tuned! Should have something to share in the next couple months