module Overcommit::Hook::Shared::Pronto

@see github.com/prontolabs/pronto

Constants

MESSAGE_REGEX
MESSAGE_TYPE_CATEGORIZER

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/shared/pronto.rb, line 14
def run
  result = execute(command)
  return :pass if result.success?

  # e.g. runtime errors
  generic_errors = extract_messages(
    result.stderr.split("\n"),
    /^(?<type>[a-z]+)/i
  )

  pronto_infractions = extract_messages(
    result.stdout.split("\n").select { |line| line.match?(MESSAGE_REGEX) },
    MESSAGE_REGEX,
    MESSAGE_TYPE_CATEGORIZER,
  )

  generic_errors + pronto_infractions
end