Skip to content

Commit a115a93

Browse files
committed
Use Node extensions instead of *splat
1 parent 5e7b947 commit a115a93

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/rubocop/cop/rspec/around_block.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ def add_no_arg_offense(node)
6969
end
7070

7171
def check_for_unused_proxy(block, proxy)
72-
name, = *proxy
73-
7472
find_arg_usage(block) do |usage|
75-
return if usage.include?(s(:lvar, name))
73+
return if usage.include?(s(:lvar, proxy.name))
7674
end
7775

7876
add_offense(
7977
proxy,
80-
message: format(MSG_UNUSED_ARG, arg: name)
78+
message: format(MSG_UNUSED_ARG, arg: proxy.name)
8179
)
8280
end
8381

lib/rubocop/cop/rspec/single_argument_message_chain.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ def single_element_array?(node)
6767
end
6868

6969
def autocorrect_hash_arg(corrector, arg)
70-
key, value = *arg.children.first
71-
72-
corrector.replace(arg, key_to_arg(key))
70+
pair = arg.pairs.first
71+
corrector.replace(arg, key_to_arg(pair.key))
7372
corrector.insert_after(arg.parent.loc.end,
74-
".and_return(#{value.source})")
73+
".and_return(#{pair.value.source})")
7574
end
7675

7776
def autocorrect_array_arg(corrector, arg)

0 commit comments

Comments
 (0)