Class: RuboCop::Cop::FactoryBot::FactoryNameStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::FactoryBot::FactoryNameStyle
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle, ConfigurableExplicitOnly, FactoryBot::Language
- Defined in:
- lib/rubocop/cop/factory_bot/factory_name_style.rb
Overview
Checks for name style for argument of FactoryBot::Syntax::Methods.
Constant Summary collapse
- MSG =
'Use %<prefer>s to refer to a factory.'
- FACTORY_CALLS =
RuboCop::FactoryBot::Language::METHODS
- RESTRICT_ON_SEND =
FACTORY_CALLS
Constants included from FactoryBot::Language
Instance Method Summary collapse
Methods included from ConfigurableExplicitOnly
#explicit_only?, #factory_call?
Methods included from FactoryBot::Language
Instance Method Details
#factory_call(node) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/rubocop/cop/factory_bot/factory_name_style.rb', line 62 def_node_matcher :factory_call, <<~PATTERN (send #factory_call? %FACTORY_CALLS ${str sym} ... ) PATTERN |
#on_send(node) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/rubocop/cop/factory_bot/factory_name_style.rb', line 69 def on_send(node) factory_call(node) do |name| if offense_for_symbol_style?(name) register_offense(name, name.value.to_sym.inspect) elsif offense_for_string_style?(name) register_offense(name, name.value.to_s.inspect) end end end |