Class: Gitlab::Styles::Rubocop::Cop::PolymorphicAssociations
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Gitlab::Styles::Rubocop::Cop::PolymorphicAssociations
- Includes:
- ModelHelpers
- Defined in:
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
Overview
Cop that prevents the use of polymorphic associations
Constant Summary collapse
- MSG =
'Do not use polymorphic associations, use separate tables instead'.freeze
Instance Method Summary collapse
Methods included from ModelHelpers
Instance Method Details
#on_send(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb', line 13 def on_send(node) return unless in_model?(node) return unless node.children[1] == :belongs_to node.children.last.each_node(:pair) do |pair| key_name = pair.children[0].children[0] add_offense(pair, location: :expression) if key_name == :polymorphic end end |