gitlab-org--gitlab-foss/rubocop/cop/activerecord_serialize.rb
Yorick Peterse 5819ca1a24
Added Cop to blacklist polymorphic associations
One should really use a separate table instead of using polymorphic
associations.

See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11168 for
more information.
2017-06-07 17:36:55 +02:00

18 lines
489 B
Ruby

require_relative '../model_helpers'
module RuboCop
module Cop
# Cop that prevents the use of `serialize` in ActiveRecord models.
class ActiverecordSerialize < RuboCop::Cop::Cop
include ModelHelpers
MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'.freeze
def on_send(node)
return unless in_model?(node)
add_offense(node, :selector) if node.children[1] == :serialize
end
end
end
end