Skip to content

Commit bf47e35

Browse files
marcandrebbatsov
authored andcommitted
Don't mutate arguments.
Too lazy to factorize this pattern
1 parent bcfff57 commit bf47e35

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def on_send(node)
3737
# ...then each key/value pair is treated as a method 'argument'
3838
# when determining where line breaks should appear.
3939
if (last_arg = args.last)
40-
args = args.concat(args.pop.children) if last_arg.hash_type? && !last_arg.braces?
40+
args = args[0...-1] + last_arg.children if last_arg.hash_type? && !last_arg.braces?
4141
end
4242

4343
check_line_breaks(node, args)

lib/rubocop/cop/mixin/check_line_breakable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def process_args(args)
171171
# ...then each key/value pair is treated as a method 'argument'
172172
# when determining where line breaks should appear.
173173
if (last_arg = args.last)
174-
args = args.concat(args.pop.children) if last_arg.hash_type? && !last_arg.braces?
174+
args = args[0...-1] + last_arg.children if last_arg.hash_type? && !last_arg.braces?
175175
end
176176
args
177177
end

0 commit comments

Comments
 (0)