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

False positive in Rails/ReversibleMigration #476

Closed
erikaxel opened this issue May 4, 2021 · 1 comment · Fixed by #477
Closed

False positive in Rails/ReversibleMigration #476

erikaxel opened this issue May 4, 2021 · 1 comment · Fixed by #477
Labels
bug Something isn't working

Comments

@erikaxel
Copy link

erikaxel commented May 4, 2021


Expected behavior

Given the following migration

class RemoveSomeTable < ActiveRecord::Migration[6.1] 
   def change
      drop_table :some_table, &:timestamps 
   end
end

I expect Rubocop to not give any warnings, since this is a valid reversible migration.

If we try to do this as a block instead (which Rails/ReversibleMigration wants)

class RemoveSomeTable < ActiveRecord::Migration[6.1] 
   def change
      drop_table :some_table do |t| 
         t.timestamps 
      end
   end
end

we will run into the Style/SymbolProc cop instead.

Actual behavior

Rubocop gives a Rails/ReversibleMigration warning.

Steps to reproduce the problem

See simple example above.

RuboCop version

1.13.0 (using Parser 3.0.1.0, rubocop-ast 1.4.1, running on ruby 3.0.1 x86_64-darwin20)
  - rubocop-performance 1.11.0
  - rubocop-rails 2.9.1
  - rubocop-rspec 2.2.0
@koic koic added the bug Something isn't working label May 4, 2021
koic added a commit to koic/rubocop-rails that referenced this issue May 4, 2021
Fixes rubocop#476.

This PR fixes a false positive for `Rails/ReversibleMigratin`
when using `drop_table` with symbol proc.
koic added a commit to koic/rubocop-rails that referenced this issue May 4, 2021
Fixes rubocop#476.

This PR fixes a false positive for `Rails/ReversibleMigration`
when using `drop_table` with symbol proc.
koic added a commit to koic/rubocop-rails that referenced this issue May 4, 2021
Fixes rubocop#476.

This PR fixes a false positive for `Rails/ReversibleMigration`
when using `drop_table` with symbol proc.
@koic koic closed this as completed in #477 May 5, 2021
koic added a commit that referenced this issue May 5, 2021
…rsible_migration

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

erikaxel commented May 6, 2021

Thank you for a quick resolution!

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