Skip to content
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

Rails/ReversibleMigration incorrectly flags reversible change_column_default based on argument ordering #357

Closed
TimMoser92 opened this issue Sep 15, 2020 · 2 comments · Fixed by #358
Labels
bug Something isn't working

Comments

@TimMoser92
Copy link

The ReversibleMigration Cop complained about a usage of change_column_default, even though all necessary parameters were supplied:

change_column_default :books, :read, to: true, from: false

The detection seemed to be thrown off by the order of the keyword arguments. After swapping from: false and to: true the complaint vanished.


Expected behavior

The ReversibleMigration Cop should not complain about the above mentioned code, since it is reversible. It should not take into account the order of keyword arguments.

Actual behavior

The ReversibleMigration Cop complains about a reversible migration, seemingly because it checks the necessary arguments in a fixed order.

Steps to reproduce the problem

  1. Create a migration.
  2. Add the code above to the change method.
  3. Run rubocop with rubocop-rails extension activated.

RuboCop version

rubocop 0.90.0 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.6.5 x86_64-darwin18)
rubocop-rails (2.8.0)

@koic koic added the bug Something isn't working label Sep 15, 2020
koic added a commit to koic/rubocop-rails that referenced this issue Sep 15, 2020
Fixes rubocop#357.

This PR fixes a false positive for `Rails/ReversibleMigration`
when keyword arguments of `change_column_default` are in the
order of `to`,` from`.
koic added a commit to koic/rubocop-rails that referenced this issue Sep 15, 2020
Fixes rubocop#357.

This PR fixes a false positive for `Rails/ReversibleMigration`
when keyword arguments of `change_column_default` are in the
order of `to`, `from`.
@koic koic closed this as completed in #358 Sep 15, 2020
koic added a commit that referenced this issue Sep 15, 2020
…ible_migration

[Fix #357] Fix a false positive for `Rails/ReversibleMigration`
@TimMoser92
Copy link
Author

@koic Thanke you for the quick fix :) 🎉

@koic
Copy link
Member

koic commented Sep 15, 2020

@TimMoser92 You are welcome. RuboCop Rails 2.8.1 has been released now. This release fixes this issue. Thank you for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants