Sha256: c2490f1596148db7d4d8ef3acc2953478980ef3e078ffa96bd8e810b2348c4a3
Contents?: true
Size: 1.13 KB
Versions: 10
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module RSpec # Checks for empty before and after hooks. # # @example # # bad # before {} # after do; end # before(:all) do # end # after(:all) { } # # # good # before { create_users } # after do # cleanup_users # end # before(:all) do # create_feed # end # after(:all) { cleanup_feed } class EmptyHook < Base extend AutoCorrector include RuboCop::Cop::RangeHelp MSG = 'Empty hook detected.' # @!method empty_hook?(node) def_node_matcher :empty_hook?, <<~PATTERN (block $#{send_pattern('#Hooks.all')} _ nil?) PATTERN def on_block(node) empty_hook?(node) do |hook| add_offense(hook) do |corrector| range = range_with_surrounding_space( range: node.loc.expression, side: :left ) corrector.remove(range) end end end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems