-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't run rubocop on schema dumping #30
base: master
Are you sure you want to change the base?
Conversation
Running Rubocop with autofix is a core part of how this Gem resolves the schema.rb conflicts. Not every project uses RuboCop. And not every project that does use RuboCop has a RuboCop configuration that'd be compatible with schema.rb. Removing Rubocop would render the Gem more or less useless since it wouldn't work anymore for projects with no Rubocop or an incompatible |
I don't understand your answer. If a project uses rucobop and for some reason some cops should run on schema.rb this gem creates another kind of conflicts (every time I run migration then I must run my own rubocop again). |
We experienced conflicts that went beyond the ordering. I assume that's why the Gem uses Rubocop with autofix. |
For example our team decide to use single quote for simple strings. This gem uses the default rubocop configuration, so it uses double quote. It is very invasive! |
Why would you have to run Rubocop again? I also use Rubocop enforced single quotes for simple strings in all of my projects but I do not enforce my style guide for |
Because I want it. If you don't like to have code style on schema.rb it doesn't means that other people can't do it. Maybe there are some situations that I discard because I never found it. |
What about a compromise and making rubocop optional instead removing it completely? |
@alexanderadam much much better. But I would like to know why it should run rubocop in order to remove schema conflicts. In 100% of cases conflicts in my team are related to columns order, so after reordering column everything works fine. Looking the code the only reason to run rubocop are for let spec pass (inside a test there is a here document with a schema.rb example and only after rubocop execution the test pass). |
@davidlibrera Just to clarify this: I'm not related to this gem. I just stumbled about this issue here and thought maybe there's another solution besides all or nothing. 😉 |
@Tolsto It would be useful to know which kind of conflicts besides ordering can happen in the schema. Do you have any example? |
Hi there, I can answer this. I am unsure why this ever would happen - it seems like a bad decision for the Rails schema dumper, but back when this gem was originally written (for Rails 4.x) my team was seeing code like this generated by an unmodified schema dump: # My schema.rb
t.string :name, null: false, length: 20
# My teammates schema.rb
t.string :name, null: false, length: 20 Depending on the ordering of the columns, the extra spacing would vary between It may be that later versions of Rails (5/6.x) no longer generate non-deterministic horizontal whitespace, in which case disabling the Rubocop pass is probably OK, but I don't know if this is the case off the top of my head based on my recent work. |
To add on further, at some point I remember this being suggested in another issue and my response then was to find a way to use the I would be happy to accept a PR making that change, but one disabling the Rubocop pass does not make sense to me. |
This was changed in 5.1.0. Rails no longer adds horizontal whitespace. Here's the pull request: rails/rails#25675 |
I think that the gem should not run rubocop on my local schema.rb. In my specific case my .rubocop.yml has different configuration and it conflicts everytime I run rubocop.
I also changed the way tests run so is not necessary to run rubocop in order to let specs passing.