Class: Rubocop::Cop::PolymorphicAssociations
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Rubocop::Cop::PolymorphicAssociations
- Includes:
- Gitlab::Styles::Rubocop::ModelHelpers
- Defined in:
- lib/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'
Instance Method Summary collapse
Methods included from Gitlab::Styles::Rubocop::ModelHelpers
Instance Method Details
#on_send(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/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) if key_name == :polymorphic end end |