Class: RuboCop::Cop::Betterment::VagueSerialize

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/betterment/vague_serialize.rb

Constant Summary collapse

MSG =
'Active Record models with serialized columns should specify which ' \
'deserializer to use instead of falling back to the default.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



15
16
17
18
19
# File 'lib/rubocop/cop/betterment/vague_serialize.rb', line 15

def on_send(node)
  return unless serialize? node

  add_offense(node) if node.arguments.length < 2 || !node.arguments[1].const_type?
end

#serialize?(node) ⇒ Object



11
12
13
# File 'lib/rubocop/cop/betterment/vague_serialize.rb', line 11

def_node_matcher :serialize?, <<-PATTERN
  (send nil? :serialize ...)
PATTERN