standard icon indicating copy to clipboard operation
standard copied to clipboard

Add a rubocop-rails ruleset

Open searls opened this issue 3 years ago • 8 comments

[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:

  1. 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.
  2. 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.
  3. I suspect whatever we do in (2) will not be perfect, so we probably need a config flag for rails: true/false

Thoughts?

searls avatar Mar 04 '21 13:03 searls

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.

taylorthurlow avatar Mar 05 '21 01:03 taylorthurlow

Thanks for the advice

searls avatar Mar 05 '21 13:03 searls

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.

mrcasals avatar Mar 08 '21 08:03 mrcasals

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?

diesl avatar Sep 12 '22 20:09 diesl

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

searls avatar Sep 12 '22 21:09 searls

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 👍

diesl avatar Sep 13 '22 20:09 diesl

I can't wait to start using standard-rails and others given the recent update :raised_hands:

xdmx avatar Feb 10 '23 19:02 xdmx

@xdmx stay tuned! Should have something to share in the next couple months

searls avatar Feb 10 '23 20:02 searls