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

Inherits:
RuboCop::Cop 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'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



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

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, location: :selector, message: MSG)
  end
end

#on_send(node) ⇒ Object



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

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

  add_offense(node, location: :selector, message: MSG)
end