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/BulkChangeTable error on empty migration #5958

Closed
andyw8 opened this issue Jun 6, 2018 · 1 comment
Closed

Rails/BulkChangeTable error on empty migration #5958

andyw8 opened this issue Jun 6, 2018 · 1 comment
Labels

Comments

@andyw8
Copy link
Contributor

andyw8 commented Jun 6, 2018

Rails/BulkChangeTable fails on a migration file with no entries.

Expected behavior

No warnings should be reported.

Actual behavior

Fails with:

An error occurred while Rails/BulkChangeTable cop was inspecting ....../db/migrate/20180526194248_drop_delayed_jobs.rb:2:2.
undefined method `each_child_node' for nil:NilClass
.../lib/rubocop/cop/rails/bulk_change_table.rb:141:in `on_def'
.../lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops'
.../lib/rubocop/cop/commissioner.rb:105:in `with_cop_error_handling'
.../lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops'
.../lib/rubocop/cop/commissioner.rb:55:in `each'
.../lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops'
.../lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
.../lib/rubocop/ast/traversal.rb:88:in `on_class'
.../lib/rubocop/cop/commissioner.rb:34:in `block (2 levels) in <class:Commissioner>'
.../lib/rubocop/ast/traversal.rb:12:in `walk'
.../lib/rubocop/cop/commissioner.rb:45:in `investigate'
.../lib/rubocop/cop/team.rb:114:in `investigate'
.../lib/rubocop/cop/team.rb:102:in `offenses'
.../lib/rubocop/cop/team.rb:44:in `inspect_file'

Steps to reproduce the problem

Run RuboCop on the following:

class DropDelayedJobs < ActiveRecord::Migration[5.1]
  def change; end
end

RuboCop version

0.57.0 (using Parser 2.5.0.5, running on ruby 2.5.0 x86_64-darwin16)

@wata727
Copy link
Contributor

wata727 commented Jun 6, 2018

Thanks @andyw8, I'll take a look later.

wata727 added a commit to wata727/rubocop that referenced this issue Jun 6, 2018
Fixes rubocop#5958

`Rails/BulkChangeTable` cop raises an error when there is the
migration method with no entries like the following:

```ruby
class EmptyMigration < ActiveRecord::Migration[5.1]
  def change; end
end
```

This change makes this Cop to handle empty method body
without errors.
bbatsov pushed a commit that referenced this issue Jun 6, 2018
Fixes #5958

`Rails/BulkChangeTable` cop raises an error when there is the
migration method with no entries like the following:

```ruby
class EmptyMigration < ActiveRecord::Migration[5.1]
  def change; end
end
```

This change makes this Cop to handle empty method body
without errors.
koic pushed a commit to rubocop/rubocop-rails that referenced this issue Oct 26, 2018
Fixes rubocop/rubocop#5958

`Rails/BulkChangeTable` cop raises an error when there is the
migration method with no entries like the following:

```ruby
class EmptyMigration < ActiveRecord::Migration[5.1]
  def change; end
end
```

This change makes this Cop to handle empty method body
without errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants