Skip to content

Commit

Permalink
Merge pull request #477 from koic/fix_a_false_positive_for_rails_reve…
Browse files Browse the repository at this point in the history
…rsible_migration

[Fix #476] Fix a false positive for `Rails/ReversibleMigration`
  • Loading branch information
koic authored May 5, 2021
2 parents 5c44c5d + 6259a52 commit a2334ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [#137](https://github.com/rubocop/rubocop-rails/issues/137): Make `Rails/HasManyOrHasOneDependent` aware of `readonly?` is `true`. ([@koic][])
* [#474](https://github.com/rubocop/rubocop-rails/pull/474): Fix a false negative for `Rails/SafeNavigation` when using `try!` without receiver. ([@koic][])
* [#126](https://github.com/rubocop/rubocop-rails/issues/126): Fix an incorrect auto-correct for `Rails/SafeNavigation` with `Style/RedndantSelf`. ([@koic][])
* [#476](https://github.com/rubocop/rubocop-rails/issues/476): Fix a false positive for `Rails/ReversibleMigration` when using `drop_table` with symbol proc. ([@koic][])

### Changes

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/reversible_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def check_irreversible_schema_statement_node(node)

def check_drop_table_node(node)
drop_table_call(node) do
unless node.parent.block_type?
unless node.parent.block_type? || node.last_argument.block_pass_type?
add_offense(
node,
message: format(MSG, action: 'drop_table(without block)')
Expand Down
4 changes: 4 additions & 0 deletions spec/rubocop/cop/rails/reversible_migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def change
end
RUBY

it_behaves_like 'accepts', 'drop_table(with symbol proc)', <<~RUBY
drop_table :users, &:timestamps
RUBY

it_behaves_like 'offense', 'drop_table(without block)', <<~RUBY
drop_table :users
RUBY
Expand Down

0 comments on commit a2334ff

Please sign in to comment.