Skip to content

Commit

Permalink
Refactor with integration into match_redundant_around_hook_block
Browse files Browse the repository at this point in the history
Follow up: #1620 (review)
  • Loading branch information
ydah committed Apr 18, 2023
1 parent 35e07d5 commit 219868e
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions lib/rubocop/cop/rspec/redundant_around.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ def on_block(node)
autocorrect(corrector, node)
end
end

def on_numblock(node)
return unless match_redundant_around_hook_numblock?(node)

add_offense(node) do |corrector|
autocorrect(corrector, node)
end
end
alias on_numblock on_block

def on_send(node)
return unless match_redundant_around_hook_send?(node)
Expand All @@ -48,16 +41,7 @@ def on_send(node)

# @!method match_redundant_around_hook_block?(node)
def_node_matcher :match_redundant_around_hook_block?, <<~PATTERN
(block
(send _ :around ...)
(args _?)
(send _ :run)
)
PATTERN

# @!method match_redundant_around_hook_numblock?(node)
def_node_matcher :match_redundant_around_hook_numblock?, <<~PATTERN
(numblock (send _ :around) ... (send _ :run))
({block numblock} (send _ :around ...) ... (send _ :run))
PATTERN

# @!method match_redundant_around_hook_send?(node)
Expand Down

0 comments on commit 219868e

Please sign in to comment.