Class: Rubocop::Cop::PolymorphicAssociations
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Rubocop::Cop::PolymorphicAssociations
- 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'
- RESTRICT_ON_SEND =
%i[belongs_to].to_set.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
16 17 18 19 20 |
# File 'lib/rubocop/cop/polymorphic_associations.rb', line 16 def on_send(node) polymorphic_pair(node) do |pair| add_offense(pair) end end |
#polymorphic_pair(node) ⇒ Object
12 13 14 |
# File 'lib/rubocop/cop/polymorphic_associations.rb', line 12 def_node_matcher :polymorphic_pair, <<~PATTERN (send _ %RESTRICT_ON_SEND ... (hash <$(pair (sym :polymorphic) _) ...>)) PATTERN |