Module: Overcommit::Utils::MessagesUtils
- Defined in:
- lib/overcommit/utils/messages_utils.rb
Overview
Utility to process messages
Class Method Summary collapse
-
.extract_messages(output_messages, regex, type_categorizer = nil) ⇒ Array<Message>
Extract file, line number, and type of message from an error/warning messages in output.
Class Method Details
.extract_messages(output_messages, regex, type_categorizer = nil) ⇒ Array<Message>
Extract file, line number, and type of message from an error/warning messages in output.
Assumes each element of ‘output` is a separate error/warning with all information necessary to identify it.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/overcommit/utils/messages_utils.rb', line 23 def (, regex, type_categorizer = nil) .map.with_index do |, index| unless match = .match(regex) raise Overcommit::Exceptions::MessageProcessingError, 'Unexpected output: unable to determine line number or type ' \ "of error/warning for output:\n" \ "#{[index..-1].join("\n")}" end file = extract_file(match, ) line = extract_line(match, ) if match.names.include?('line') && match[:line] type = extract_type(match, , type_categorizer) Overcommit::Hook::Message.new(type, file, line, ) end end |