Skip to content

Commit

Permalink
Use Node extensions instead of *splat
Browse files Browse the repository at this point in the history
  • Loading branch information
bquorning committed Nov 20, 2024
1 parent 5d96600 commit 3093265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions lib/rubocop/cop/rspec/around_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ def add_no_arg_offense(node)
end

def check_for_unused_proxy(block, proxy)
name, = *proxy

find_arg_usage(block) do |usage|
return if usage.include?(s(:lvar, name))
return if usage.include?(s(:lvar, proxy.name))
end

add_offense(
proxy,
message: format(MSG_UNUSED_ARG, arg: name)
message: format(MSG_UNUSED_ARG, arg: proxy.name)
)
end

Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/cop/rspec/single_argument_message_chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ def single_element_array?(node)
end

def autocorrect_hash_arg(corrector, arg)
key, value = *arg.children.first

corrector.replace(arg, key_to_arg(key))
corrector.replace(arg, key_to_arg(arg.keys.first))
corrector.insert_after(arg.parent.loc.end,
".and_return(#{value.source})")
".and_return(#{arg.values.first.source})")
end

def autocorrect_array_arg(corrector, arg)
Expand Down

0 comments on commit 3093265

Please sign in to comment.