Sha256: b1c668d36dbbbac1b89b7652e234fd4efc50df3ac07ec141fefde492b1ed20b7

Contents?: true

Size: 1.21 KB

Versions: 7

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`.'.freeze

        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

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-rspec-1.32.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.31.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.30.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.30.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.29.1 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.29.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb
rubocop-rspec-1.28.0 lib/rubocop/cop/rspec/empty_line_after_hook.rb