Skip to content

Commit

Permalink
Merge pull request #1621 from ydah/refactor-RedundantAround
Browse files Browse the repository at this point in the history
Refactor with integration into `match_redundant_around_hook_block`
  • Loading branch information
pirj committed Apr 18, 2023
2 parents 35e07d5 + 219868e commit 7e2a570
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 7e2a570

Please sign in to comment.