10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/runger_style/cops/default/multiline_method_arguments_line_breaks.rb', line 10
def on_send(node)
if node.arguments? && multiline_method_call?(node)
arguments =
if (
node.arguments.one? &&
node.arguments.first.hash_type? &&
!node.arguments.first.braces?
)
node.arguments.first.pairs
else
node.arguments
end
arguments.each_cons(2) do |arg1, arg2|
if same_line?(arg1, arg2)
separator = separator_range(arg1, arg2)
add_offense(separator, message: MSG) do |corrector|
base_indent = base_indentation(arg1)
replacement = ",\n#{base_indent}"
corrector.replace(separator, replacement)
end
end
end
end
end
|