Class: RuboCop::Cop::FactoryBot::AssociationStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::FactoryBot::AssociationStyle
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/factory_bot/association_style.rb
Overview
Use a consistent style to define associations.
Constant Summary collapse
- RESTRICT_ON_SEND =
i[factory trait].freeze
- KEYWORDS =
i[alias and begin break case class def defined? do else elsif end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield __FILE__ __LINE__ __ENCODING__].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rubocop/cop/factory_bot/association_style.rb', line 75 def on_send(node) bad_associations_in(node).each do |association| add_offense( association, message: "Use #{style} style to define associations." ) do |corrector| autocorrect(corrector, association) end end end |