Sha256: ffa3474d425475e111a9bc991ff2a04a8c229f3e12bf869bba8b7e5958b8a324

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks if there is an empty line after hook blocks.
      #
      # @example
      #   # bad
      #   before { do_something }
      #   it { does_something }
      #
      #   # bad
      #   after { do_something }
      #   it { does_something }
      #
      #   # bad
      #   around { |test| test.run }
      #   it { does_something }
      #
      #   # good
      #   before { do_something }
      #
      #   it { does_something }
      #
      #   # good
      #   after { do_something }
      #
      #   it { does_something }
      #
      #   # good
      #   around { |test| test.run }
      #
      #   it { does_something }
      #
      class EmptyLineAfterHook < Base
        extend AutoCorrector
        include RuboCop::RSpec::EmptyLineSeparation

        MSG = 'Add an empty line after `%<hook>s`.'

        def on_block(node)
          return unless hook?(node)

          missing_separating_line_offense(node) do |method|
            format(MSG, hook: method)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-2.0.0.pre lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.44.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.44.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.43.2 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.43.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.43.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb