Sha256: ec6bcf3597bd6a463a2354509d636ed145831e141ab39d4e31f9c09ae709838c

Contents?: true

Size: 989 Bytes

Versions: 7

Compression:

Stored size: 989 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks if there is an empty line after the last let block.
      #
      # @example
      #   # bad
      #   let(:foo) { bar }
      #   let(:something) { other }
      #   it { does_something }
      #
      #   # good
      #   let(:foo) { bar }
      #   let(:something) { other }
      #
      #   it { does_something }
      class EmptyLineAfterFinalLet < Cop
        include RuboCop::RSpec::BlankLineSeparation

        MSG = 'Add an empty line after the last `let` block.'.freeze

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

          latest_let = node.body.child_nodes.select { |child| let?(child) }.last

          return if latest_let.nil?
          return if last_child?(latest_let)

          missing_separating_line(latest_let) do |location|
            add_offense(latest_let, location: location)
          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_final_let.rb
rubocop-rspec-1.31.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.30.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.30.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.29.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.29.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-1.28.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb