Class: RuboCop::Cop::Webit::MultilineMethodCalls
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Webit::MultilineMethodCalls
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/webit/multiline_method_calls.rb
Overview
Checks for the usage of parentheses on multi-line method calls.
Constant Summary collapse
- MSG_PARENTHESES =
"Multiline method calls must have parentheses."
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/webit/multiline_method_calls.rb', line 38 def on_send(node) return if node.children.empty? || !multiline_method_call?(node) return if node.assignment_method? return if node.operator_method? unless node.parenthesized_call? add_offense(node, message: MSG_PARENTHESES) do |corrector| corrector.replace(node, "#{node.source.sub("#{node.method_name} ", "#{node.method_name}(")})") end end end |