Sha256: f36f28a28f9b608a44b4b2fb727d0595ed8cb0bcfe84dd7b29c060d4081d79cd

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 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 < Cop
        include RuboCop::RSpec::BlankLineSeparation

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

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

          missing_separating_line(node) do |location|
            add_offense(
              node,
              location: location,
              message: format(MSG, hook: node.method_name)
            )
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-rspec-1.41.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.40.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.39.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.38.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.38.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.37.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.37.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.36.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.35.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.34.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.34.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.33.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb