Class: RuboCop::Cop::Vicenzo::Style::MultilineMethodCallParentheses

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/vicenzo/style/multiline_method_call_parentheses.rb

Overview

Enforces parentheses for method calls with arguments that span multiple lines. Single-line calls are ignored (parentheses are optional).

This cop accepts an AllowedMethods configuration to exempt specific methods from this rule. This is particularly useful for Fluent DSLs (like RSpec's to, change, etc.) where parentheses might hurt readability or conflict with layout rules.

Examples:

# bad
method_name arg1,
            arg2

# good
method_name(arg1,
            arg2)

# good (single line is always allowed)
method_name arg1, arg2

AllowedMethods: ['to']

# good (allowed by configuration)
expect { action }.to change {
  model.attribute
}

Constant Summary collapse

MSG =
'Use parentheses for method calls with arguments that span multiple lines.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object Also known as: on_csend



39
40
41
# File 'lib/rubocop/cop/vicenzo/style/multiline_method_call_parentheses.rb', line 39

def on_send(node)
  check_node(node)
end