Sha256: 2fd8c53d8ce5ab63a56c7b545053ed7e1b22e99325b70f454092167db0bfbef3

Contents?: true

Size: 935 Bytes

Versions: 20

Compression:

Stored size: 935 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 < Base
        extend AutoCorrector
        include EmptyLineSeparation

        MSG = 'Add an empty line after the last `%<let>s`.'

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

          final_let = node.body.child_nodes.reverse.find { |child| let?(child) }

          return if final_let.nil?

          missing_separating_line_offense(final_let) do |method|
            format(MSG, let: method)
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 18 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.12.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.12.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.11.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.11.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.10.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.9.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.8.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.7.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.6.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.5.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.4.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.3.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.2.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.1.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.0.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.0.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb