Sha256: f47ba7e0d5c4a2ef4fe285bd02771e468875a6febde89d2614f7e652e1d15d35

Contents?: true

Size: 457 Bytes

Versions: 19

Compression:

Stored size: 457 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module RSpec
    # Helps find the true end location of nodes which might contain heredocs.
    module FinalEndLocation
      def final_end_location(start_node)
        heredoc_endings =
          start_node.each_node(:str, :dstr, :xstr)
            .select(&:heredoc?)
            .map { |node| node.loc.heredoc_end }

        [start_node.loc.end, *heredoc_endings].max_by(&:line)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rubocop-rspec-2.0.0.pre lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.44.1 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.44.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.43.2 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.43.1 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.43.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.42.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.41.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.40.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.39.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.38.1 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.38.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.37.1 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.37.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.36.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.35.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.34.1 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.34.0 lib/rubocop/rspec/final_end_location.rb
rubocop-rspec-1.33.0 lib/rubocop/rspec/final_end_location.rb