Class: RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::FactoryBot::ConsistentParenthesesStyle
show all
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle, Util, RSpec::FactoryBot::Language
- Defined in:
- lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb
Overview
Use a consistent style for parentheses in factory bot calls.
Constant Summary
collapse
- MSG_REQUIRE_PARENS =
'Prefer method call with parentheses'
- MSG_OMIT_PARENS =
'Prefer method call without parentheses'
- FACTORY_CALLS =
RuboCop::RSpec::FactoryBot::Language::METHODS
- RESTRICT_ON_SEND =
FACTORY_CALLS
RSpec::FactoryBot::Language::METHODS
Class Method Summary
collapse
Instance Method Summary
collapse
#factory_bot?
Class Method Details
.autocorrect_incompatible_with ⇒ Object
49
50
51
|
# File 'lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb', line 49
def self.autocorrect_incompatible_with
[Style::MethodCallWithArgsParentheses]
end
|
Instance Method Details
#factory_call(node) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb', line 61
def_node_matcher :factory_call, " (send\n {#factory_bot? nil?} %FACTORY_CALLS\n {sym str send lvar} _*\n )\n"
|
#on_send(node) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb', line 68
def on_send(node)
return if ambiguous_without_parentheses?(node)
factory_call(node) do
return if node.method?(:generate) && node.arguments.count > 1
if node.parenthesized?
process_with_parentheses(node)
else
process_without_parentheses(node)
end
end
end
|