Skip to content

Commit

Permalink
Merge pull request #358 from koic/fix_false_positive_for_rails_revers…
Browse files Browse the repository at this point in the history
…ible_migration

[Fix #357] Fix a false positive for `Rails/ReversibleMigration`
  • Loading branch information
koic committed Sep 15, 2020
2 parents 3ec7cda + 99515d0 commit 92c6828
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
* [#351](https://github.com/rubocop-hq/rubocop-rails/pull/351): Add `<>` operator to `Rails/WhereNot` cop. ([@Tietew][])
* [#352](https://github.com/rubocop-hq/rubocop-rails/pull/352): Do not register offense if given a splatted hash. ([@dvandersluis][])
* [#346](https://github.com/rubocop-hq/rubocop-rails/pull/346): Fix a false positive for `Rails/DynamicFindBy` when any of the arguments are splat argument. ([@koic][])
* [#357](https://github.com/rubocop-hq/rubocop-rails/issues/357): Fix a false positive for `Rails/ReversibleMigration` when keyword arguments of `change_column_default` are in the order of `to`, `from`. ([@koic][])

## 2.8.0 (2020-09-04)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/reversible_migration.rb
Expand Up @@ -360,7 +360,7 @@ def all_hash_key?(args, *keys)
key.children.first.to_sym
end

hash_keys & keys == keys
(hash_keys & keys).sort == keys
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/rubocop/cop/rails/reversible_migration_spec.rb
Expand Up @@ -114,6 +114,11 @@ def change
change_column_default(:posts, :state, from: nil, to: "draft")
RUBY

it_behaves_like 'accepts',
'change_column_default(with :to and :from)', <<-RUBY
change_column_default(:posts, :state, to: "draft", from: nil)
RUBY

it_behaves_like 'accepts',
'change_column_default(*column :from and :to)', <<-RUBY
columns = [:foo, :bar]
Expand Down

0 comments on commit 92c6828

Please sign in to comment.