lib/rubocop/cop/rspec/empty_hook.rb in rubocop-rspec-1.41.0 vs lib/rubocop/cop/rspec/empty_hook.rb in rubocop-rspec-1.42.0
- old
+ new
@@ -21,28 +21,24 @@
# before(:all) do
# create_feed
# end
# after(:all) { cleanup_feed }
class EmptyHook < Cop
+ extend AutoCorrector
include RuboCop::Cop::RangeHelp
MSG = 'Empty hook detected.'
def_node_matcher :empty_hook?, <<~PATTERN
(block $#{Hooks::ALL.send_pattern} _ nil?)
PATTERN
def on_block(node)
empty_hook?(node) do |hook|
- add_offense(hook)
- end
- end
-
- def autocorrect(node)
- lambda do |corrector|
- block = node.parent
- range = range_with_surrounding_space(range: block.loc.expression)
- corrector.remove(range)
+ add_offense(hook) do |corrector|
+ range = range_with_surrounding_space(range: node.loc.expression)
+ corrector.remove(range)
+ end
end
end
end
end
end