2017-06-02 08:29:30 -04:00
|
|
|
require_relative '../model_helpers'
|
|
|
|
|
2017-05-31 07:47:36 -04:00
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
# Cop that prevents the use of `serialize` in ActiveRecord models.
|
|
|
|
class ActiverecordSerialize < RuboCop::Cop::Cop
|
2017-06-02 08:29:30 -04:00
|
|
|
include ModelHelpers
|
|
|
|
|
2017-05-31 07:47:36 -04:00
|
|
|
MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'.freeze
|
|
|
|
|
|
|
|
def on_send(node)
|
2017-06-02 08:29:30 -04:00
|
|
|
return unless in_model?(node)
|
2017-05-31 07:47:36 -04:00
|
|
|
|
|
|
|
add_offense(node, :selector) if node.children[1] == :serialize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|