class Pronto::Rustcov

def build_messages(grouped)

def build_messages(grouped)
  messages = []
  grouped.each do |patch, lines|
    linenos = lines.map(&:new_lineno).sort
    line_ranges = linenos.chunk_while { |i, j| j == i + 1 }.to_a
    best_ranges = line_ranges.sort_by { |range| [-range.size, range.first] }.take(pronto_messages_per_file_limit)
    # If we have a message per file limit of N, then create N individual messages
    # We'll take each range and create a separate message for it, up to the limit
    best_ranges.each do |range|
      message_text = format_message_text(range)
      # Find the first line in this range for the message
      first_line_in_range = lines.find { |line| line.new_lineno == range.first }
      messages << Pronto::Message.new(
        patch.new_file_path,
        first_line_in_range,
        :warning,
        message_text,
        nil,
        self.class
      )
    end
  end
  messages
end