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/ReversibleMigrationMethodDefinition false positive? #488

Closed
coding-bunny opened this issue May 17, 2021 · 0 comments · Fixed by #489
Closed

Rails/ReversibleMigrationMethodDefinition false positive? #488

coding-bunny opened this issue May 17, 2021 · 0 comments · Fixed by #489
Labels
bug Something isn't working

Comments

@coding-bunny
Copy link

Expected behavior

I expect the Cop to not flag a correct migration as "wrong"

Actual behavior

The cop is currently flagging all migrations

Steps to reproduce the problem

# frozen_string_literal: true

# This migration removes the ActiveStorage Blob tables.
class RemoveActiveStorageBlobs < ::ActiveRecord::Migration[6.1]
  # Runs the migration in the correct direction
  def change
    drop_table :active_storage_blobs do |t|
      t.string :key, null: false
      t.string :filename, null: false
      t.string :content_type
      t.text :metadata
      t.bigint :byte_size, null: false
      t.string :checksum, null: false
      t.datetime :created_at, null: false
      t.index :key, unique: true
    end
  end
end

This is currently flagged:

db/migrate/20210513071056_remove_active_storage_blobs.rb:4:1: E: Rails/ReversibleMigrationMethodDefinition: Migrations must contain either a change method, or both an up and a down method.
class RemoveActiveStorageBlobs < ::ActiveRecord::Migration[6.1] ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-rails, rubocop-performance, and others) output by rubocop -V,
include them as well. Here's an example:

➜  customink_international git:(coding-bunny/bump_inkycop) ✗ bundle exec rubocop -V
1.14.0 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 3.0.0 x86_64-linux)
  - rubocop-performance 1.11.3
  - rubocop-rails 2.10.1
  - rubocop-rake 0.5.1
  - rubocop-rspec 2.3.0
@koic koic added the bug Something isn't working label May 17, 2021
koic added a commit to koic/rubocop-rails that referenced this issue May 17, 2021
…MethodDefinition`

Fixes rubocop#488.

This PR fixes a false positive for `Rails/ReversibleMigrationMethodDefinition`
when using cbase migration class.
@koic koic closed this as completed in #489 May 19, 2021
koic added a commit that referenced this issue May 19, 2021
…igration_method_definition

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