Skip to content

Commit

Permalink
Suppress RuboCop offenses
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
koic committed Dec 27, 2024
1 parent 048d2c7 commit 9748bdb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rubocop/cop/rails/not_null_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class NotNullColumn < Base
MSG = 'Do not add a NOT NULL column without a default value.'
RESTRICT_ON_SEND = %i[add_column add_reference].freeze

VIRTUAL_TYPE_VALUES = [:virtual, 'virtual'].freeze
TEXT_TYPE_VALUES = [:text, 'text'].freeze

def_node_matcher :add_not_null_column?, <<~PATTERN
(send nil? :add_column _ _ $_ (hash $...))
PATTERN
Expand Down Expand Up @@ -92,8 +95,8 @@ def on_block(node)

def check_column(type, pairs)
if type.respond_to?(:value)
return if type.value == :virtual || type.value == 'virtual'
return if (type.value == :text || type.value == 'text') && database == MYSQL
return if VIRTUAL_TYPE_VALUES.include?(type.value)
return if TEXT_TYPE_VALUES.include?(type.value) && database == MYSQL
end

check_pairs(pairs)
Expand Down

0 comments on commit 9748bdb

Please sign in to comment.