Skip to content

Commit 1e9c257

Browse files
authored
Merge pull request #601 from tachyons/bugfix/handle_ignored_columns_from_mixins
Handle ignored_columns from mixins
2 parents 647e46a + 3bc131f commit 1e9c257

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#601](https://github.com/rubocop/rubocop-rails/pull/601): Handle ignored_columns from mixins for `Rails/UnusedIgnoredColumns` cop. ([@tachyons][])

lib/rubocop/cop/rails/unused_ignored_columns.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def class_node(node)
6161

6262
def table(node)
6363
klass = class_node(node)
64+
return unless klass
65+
6466
schema.table_by(name: table_name(klass))
6567
end
6668
end

spec/rubocop/cop/rails/unused_ignored_columns_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ class User < ApplicationRecord
3333
end
3434
end
3535

36+
context 'with an used/unused ignored column in a mixin' do
37+
it 'does nothing' do
38+
expect_no_offenses(<<~RUBY)
39+
module Abc
40+
self.ignored_columns = [:real_name]
41+
end
42+
RUBY
43+
end
44+
end
45+
3646
context 'with an unused ignored column as a String' do
3747
it 'registers an offense' do
3848
expect_offense(<<~RUBY)

0 commit comments

Comments
 (0)