Skip to content

Commit

Permalink
Merge pull request #489 from koic/fix_false_positive_for_reversible_m…
Browse files Browse the repository at this point in the history
…igration_method_definition

[Fix #488] Fix a false positive for `Rails/ReversibleMigrationMethodDefinition`
  • Loading branch information
koic authored May 19, 2021
2 parents ad4fb01 + 970054b commit 3a8d952
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [#482](https://github.com/rubocop/rubocop-rails/pull/482): Fix a false positive for `Rails/RelativeDateConstant` when assigning (hashes/arrays/etc)-containing procs to a constant. ([@jdelStrother][])
* [#419](https://github.com/rubocop/rubocop-rails/issues/419): Fix an error for `Rails/UniqueValidationWithoutIndex` when using a unique index and `check_constraint` that has `nil` first argument. ([@koic][])
* [#70](https://github.com/rubocop/rubocop-rails/issues/70): Fix a false positive for `Rails/TimeZone` when setting `EnforcedStyle: strict` and using `Time.current`. ([@koic][])
* [#488](https://github.com/rubocop/rubocop-rails/issues/488): Fix a false positive for `Rails/ReversibleMigrationMethodDefinition` when using cbase migration class. ([@koic][])

### Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ReversibleMigrationMethodDefinition < Base
(class
(const nil? _)
(send
(const (const nil? :ActiveRecord) :Migration)
(const (const {nil? cbase} :ActiveRecord) :Migration)
:[]
(float _))
_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,14 @@ def change
end
RUBY
end

it 'does not register offenses correctly with any cbase migration class' do
expect_no_offenses(<<~RUBY)
class SomeMigration < ::ActiveRecord::Migration[5.2]
def change
add_column :users, :email, :text, null: false
end
end
RUBY
end
end

0 comments on commit 3a8d952

Please sign in to comment.