diff --git a/CHANGELOG.md b/CHANGELOG.md index 94e43feed5..606c87a57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/rubocop/cop/rails/reversible_migration_method_definition.rb b/lib/rubocop/cop/rails/reversible_migration_method_definition.rb index 4a2b90d1ba..29914b49d5 100644 --- a/lib/rubocop/cop/rails/reversible_migration_method_definition.rb +++ b/lib/rubocop/cop/rails/reversible_migration_method_definition.rb @@ -50,7 +50,7 @@ class ReversibleMigrationMethodDefinition < Base (class (const nil? _) (send - (const (const nil? :ActiveRecord) :Migration) + (const (const {nil? cbase} :ActiveRecord) :Migration) :[] (float _)) _) diff --git a/spec/rubocop/cop/rails/reversible_migration_method_definition_spec.rb b/spec/rubocop/cop/rails/reversible_migration_method_definition_spec.rb index 32d5d00a78..e91ca72c90 100644 --- a/spec/rubocop/cop/rails/reversible_migration_method_definition_spec.rb +++ b/spec/rubocop/cop/rails/reversible_migration_method_definition_spec.rb @@ -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