Skip to content

Commit 219868e

Browse files
committed
Refactor with integration into match_redundant_around_hook_block
Follow up: #1620 (review)
1 parent 35e07d5 commit 219868e

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

lib/rubocop/cop/rspec/redundant_around.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,7 @@ def on_block(node)
2727
autocorrect(corrector, node)
2828
end
2929
end
30-
31-
def on_numblock(node)
32-
return unless match_redundant_around_hook_numblock?(node)
33-
34-
add_offense(node) do |corrector|
35-
autocorrect(corrector, node)
36-
end
37-
end
30+
alias on_numblock on_block
3831

3932
def on_send(node)
4033
return unless match_redundant_around_hook_send?(node)
@@ -48,16 +41,7 @@ def on_send(node)
4841

4942
# @!method match_redundant_around_hook_block?(node)
5043
def_node_matcher :match_redundant_around_hook_block?, <<~PATTERN
51-
(block
52-
(send _ :around ...)
53-
(args _?)
54-
(send _ :run)
55-
)
56-
PATTERN
57-
58-
# @!method match_redundant_around_hook_numblock?(node)
59-
def_node_matcher :match_redundant_around_hook_numblock?, <<~PATTERN
60-
(numblock (send _ :around) ... (send _ :run))
44+
({block numblock} (send _ :around ...) ... (send _ :run))
6145
PATTERN
6246

6347
# @!method match_redundant_around_hook_send?(node)

0 commit comments

Comments
 (0)