Skip to content

Commit

Permalink
Merge pull request #1998 from rubocop/use-node-extensions-instead-of-…
Browse files Browse the repository at this point in the history
…splat

Use Node extensions instead of *splat
  • Loading branch information
bquorning authored Dec 6, 2024
2 parents 5e7b947 + a115a93 commit 274c7d9
Show file tree
Hide file tree
Showing 2 changed files with 5 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
7 changes: 3 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,10 @@ def single_element_array?(node)
end

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

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

def autocorrect_array_arg(corrector, arg)
Expand Down

0 comments on commit 274c7d9

Please sign in to comment.