Skip to content

Commit 9748bdb

Browse files
committed
Suppress RuboCop offenses
This commit suppresses the following RuboCop offenses: ```console $ bundle exec rubocop (snip) Offenses: lib/rubocop/cop/rails/not_null_column.rb:95:23: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. return if type.value == :virtual || type.value == 'virtual' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/rails/not_null_column.rb:96:24: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. return if (type.value == :text || type.value == 'text') && database == MYSQL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 296 files inspected, 2 offenses detected, 2 offenses autocorrectable ```
1 parent 048d2c7 commit 9748bdb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/rubocop/cop/rails/not_null_column.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class NotNullColumn < Base
4646
MSG = 'Do not add a NOT NULL column without a default value.'
4747
RESTRICT_ON_SEND = %i[add_column add_reference].freeze
4848

49+
VIRTUAL_TYPE_VALUES = [:virtual, 'virtual'].freeze
50+
TEXT_TYPE_VALUES = [:text, 'text'].freeze
51+
4952
def_node_matcher :add_not_null_column?, <<~PATTERN
5053
(send nil? :add_column _ _ $_ (hash $...))
5154
PATTERN
@@ -92,8 +95,8 @@ def on_block(node)
9295

9396
def check_column(type, pairs)
9497
if type.respond_to?(:value)
95-
return if type.value == :virtual || type.value == 'virtual'
96-
return if (type.value == :text || type.value == 'text') && database == MYSQL
98+
return if VIRTUAL_TYPE_VALUES.include?(type.value)
99+
return if TEXT_TYPE_VALUES.include?(type.value) && database == MYSQL
97100
end
98101

99102
check_pairs(pairs)

0 commit comments

Comments
 (0)