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

Rails/MigrationClassName triggers on classes that are not migrations #660

Closed
tomhughes opened this issue Mar 16, 2022 · 0 comments · Fixed by #663
Closed

Rails/MigrationClassName triggers on classes that are not migrations #660

tomhughes opened this issue Mar 16, 2022 · 0 comments · Fixed by #663
Labels
bug Something isn't working

Comments

@tomhughes
Copy link

Expected behavior

The Rails/MigrationClassName cop should only trigger on the migration class that inherits from ActiveRecord::Migration.

Actual behavior

The Rails/MigrationClassName cop will trigger on top level classes which are supporting classes that are not the migration.

Steps to reproduce the problem

Consider this example:

class NotAMigration
end

class ThisMigration < ActiveRecord::Migration[4.2]
end

Only the second class should be affected by the cop but in fact the first one is and the second one is left alone.

RuboCop version

1.26.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.0.2 x86_64-linux)
  - rubocop-minitest 0.18.0
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.1
  - rubocop-rake 0.6.0
@koic koic added the bug Something isn't working label Mar 16, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Mar 16, 2022
Fixes rubocop#660.

This PR fixes a false positive for `Rails/MigrationClassName`
when defining another outer class.
koic added a commit to koic/rubocop-rails that referenced this issue Mar 16, 2022
Fixes rubocop#660.

This PR fixes a false positive for `Rails/MigrationClassName`
when defining another class.
koic added a commit to koic/rubocop-rails that referenced this issue Mar 16, 2022
Fixes rubocop#660.

This PR fixes a false positive for `Rails/MigrationClassName`
when defining another class.
@koic koic closed this as completed in #663 Mar 16, 2022
koic added a commit that referenced this issue Mar 16, 2022
…ation_class_name

[Fix #660] Fix a false positive for `Rails/MigrationClassName`
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