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
- DEFAULT_NON_IMPLICIT_ASSOCIATION_METHOD_NAMES =
%w[ association factory sequence skip_create traits_for_enum ].freeze
- 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
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rubocop/cop/factory_bot/association_style.rb', line 83 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 |