class PreCommit::Message::Formatter
Responsible for format a given output
Public Instance Methods
format(checkstyle)
click to toggle source
Format output for a given errors
details
@param checkstyle [Domain::Checkstyle] Checkstyle
details @return [String] formatted output or nil when has no errors @raise ArgumentError when input is empty
# File lib/plugins/pre_commit/message/formatter.rb, line 13 def format(checkstyle) throw ArgumentError.new if checkstyle.nil? return nil if checkstyle.good? format_multiple(checkstyle.bad_files) end
Private Instance Methods
format_errors(errors)
click to toggle source
# File lib/plugins/pre_commit/message/formatter.rb, line 30 def format_errors(errors) errors.reduce('') { |a, e| a + line(e) } end
format_multiple(files)
click to toggle source
# File lib/plugins/pre_commit/message/formatter.rb, line 22 def format_multiple(files) files.reduce('') { |a, e| a + format_single(e) } end
format_single(bad_file)
click to toggle source
# File lib/plugins/pre_commit/message/formatter.rb, line 26 def format_single(bad_file) "File errors: #{bad_file.name} \n" + format_errors(bad_file.errors) end
line(error)
click to toggle source
# File lib/plugins/pre_commit/message/formatter.rb, line 34 def line(error) " line: #{error['line']}:#{error['column']}"\ " error: #{error['message']}\n" end