Module: RuboCop::Cop::RSpec::FinalEndLocation
- Included in:
- CommentsHelp, EmptyLineSeparation, ScatteredSetup, RSpec::Corrector::MoveNode
- Defined in:
- lib/rubocop/cop/rspec/mixin/final_end_location.rb
Overview
Helps find the true end location of nodes which might contain heredocs.
Instance Method Summary collapse
Instance Method Details
#final_end_location(start_node) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/rubocop/cop/rspec/mixin/final_end_location.rb', line 8 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 |