Class: RuboCop::Cop::Sequel::JSONColumn

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sequel/json_column.rb

Overview

JSONColumn looks for non-JSONB columns.

Constant Summary collapse

MSG =
'Use JSONB rather than JSON or hstore'
RESTRICT_ON_SEND =
%i[add_column].freeze

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/rubocop/cop/sequel/json_column.rb', line 29

def on_block(node)
  return unless node.send_node.method_name == :create_table

  node.each_node(:send) do |method|
    next unless column_method?(method) || column_type?(method)

    add_offense(method.loc.selector, message: MSG)
  end
end

#on_send(node) ⇒ Object



23
24
25
26
27
# File 'lib/rubocop/cop/sequel/json_column.rb', line 23

def on_send(node)
  return unless json_or_hstore?(node)

  add_offense(node.loc.selector, message: MSG)
end