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 issue with rails ActiveStorage #656

Closed
uxxman opened this issue Mar 15, 2022 · 4 comments · Fixed by #655
Closed

Rails/MigrationClassName issue with rails ActiveStorage #656

uxxman opened this issue Mar 15, 2022 · 4 comments · Fixed by #655
Labels
bug Something isn't working

Comments

@uxxman
Copy link

uxxman commented Mar 15, 2022

#644 introduced MigrationClassName which doesn't play along with rails generated migrations for ActiveStorage

Issue with rails generated active storage migrations.

db/migrate/20210214101402_create_active_storage_tables.active_storage.rb:2:7: C: [Correctable] Rails/MigrationClassName: Replace with CreateActiveStorageTables.activeStorage that matches the file name.

where CreateActiveStorageTables.activeStorage is an invalid syntax. The cop should exclude activestorage migration files


RuboCop version

$ [bundle exec] rubocop -V
1.26.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.1.1 arm64-darwin21)
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.0
  - rubocop-rspec 2.9.0
@koic koic added the bug Something isn't working label Mar 15, 2022
@koic
Copy link
Member

koic commented Mar 15, 2022

Probably #655 will solve it. I will wait for other issue feedback for a while before the bugfix releasing. Thank you.

@ShockwaveNN
Copy link

Same here

Just for clarification, calling autocorrect of Rails/MigrationClassName cause my code:

# frozen_string_literal: true

# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
  def change
    change_column_null(:active_storage_blobs, :checksum, true)
  end
end

to become

# frozen_string_literal: true

# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum.activeStorage < ActiveRecord::Migration[6.0]
  def change
    change_column_null(:active_storage_blobs, :checksum, true)
  end
end

with raising errors on rubocop -A result:

rubocop -A db/migrate/20220210092016_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb
Inspecting 1 file
E

Offenses:

db/migrate/20220210092016_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb:4:7: C: [Corrected] Rails/MigrationClassName: Replace with RemoveNotNullOnActiveStorageBlobsChecksum.activeStorage that matches the file name.
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
db/migrate/20220210092016_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb:4:63: E: Lint/Syntax: unexpected token tLT
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)
class RemoveNotNullOnActiveStorageBlobsChecksum.activeStorage < ActiveRecord::Migration[6.0]
                                                              ^
db/migrate/20220210092016_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb:8:1: E: Lint/Syntax: unexpected token kEND
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)
end
^^^

1 file inspected, 3 offenses detected, 1 offense corrected

@koic
Copy link
Member

koic commented Mar 16, 2022

RuboCop Rails 2.14.1 has been released.
https://github.com/rubocop/rubocop-rails/releases/tag/v2.14.1

@ShockwaveNN
Copy link

I can confirm my problem is fixed in 2.14.1

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.

3 participants