Sha256: 9fc7f356f509774d5016cd25f8bdd0f54b5592d3f990b7651194cf0525587639

Contents?: true

Size: 993 Bytes

Versions: 53

Compression:

Stored size: 993 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) # rubocop:disable InternalAffairs/NumblockHandler
          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

53 entries across 51 versions & 7 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-3.0.3/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.3.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.2.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.1.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.5 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.4 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-3.0.1/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.3 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.2 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-rspec-3.0.1/lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-3.0.0.pre lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.31.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.30.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.29.2 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.29.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.29.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.28.0 lib/rubocop/cop/rspec/empty_line_after_final_let.rb
rubocop-rspec-2.27.1 lib/rubocop/cop/rspec/empty_line_after_final_let.rb