Class: PreCommit::Message::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/pre_commit/message/formatter.rb

Overview

Responsible for format a given output

Instance Method Summary collapse

Instance Method Details

#format(errors) ⇒ String

Format output for a given errors details

Parameters:

  • JSON (Hash)

    errors details

Returns:

  • (String)

    formatted output (may return nil)

Raises:

  • ArgumentError when input is empty



13
14
15
16
17
18
19
20
21
22
# File 'lib/plugins/pre_commit/message/formatter.rb', line 13

def format(errors)
  throw ArgumentError.new if errors.nil? || errors.empty?

  files = errors['checkstyle']['file']

  return nil if files.empty?
  return format_single(files) unless files.is_a? Array

  format_multiple(files)
end