Class: RuboCop::Cop::Glib::MultilineMethodCallStyle

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/glib/rubocop/cops/multiline_method_call_style.rb

Overview

Enforces parentheses style for multi-line method calls with arguments.

Examples:

# bad
page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
  footer.h1 text: 'Footer'
end

# bad
page.footer \
  padding: glib_json_padding_body,
  backgroundColor: '#b3bac2',
  childViews: ->(footer) do
    footer.h1 text: 'Footer'
  end

# good
page.footer(
  padding: glib_json_padding_body,
  backgroundColor: '#b3bac2',
  childViews: ->(footer) do
    footer.h1 text: 'Footer'
  end
)

Constant Summary collapse

MSG =
'Use parentheses style for multi-line method calls: ' \
'wrap arguments in parentheses and place each argument on its own line.'

Instance Method Summary collapse

Instance Method Details

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



36
37
38
39
40
41
42
43
44
45
# File 'lib/glib/rubocop/cops/multiline_method_call_style.rb', line 36

def on_send(node)
  return unless multi_line_call_with_args?(node)
  return if proper_parentheses_style?(node)
  return if proper_backslash_style?(node) && allow_backslash?
  return if inside_correctable_parent?(node)

  add_offense(node) do |corrector|
    autocorrect(corrector, node)
  end
end