[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/sds/overcommit/main/lib/overcommit/hook/pre_commit/shell_check.rb [Back]  [Original]

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs `shellcheck` against any modified shell script files.
  #
  # @see http://www.shellcheck.net/
  class ShellCheck < Base
    MESSAGE_TYPE_CATEGORIZER = lambda do |type|
      type.include?('note') ? :warning : :error
    end

    def run
      result = execute(command, args: applicable_files)
      return :pass if result.success?

      extract_messages(
        result.stdout.split("\n"),
        /^(?(?:\w:)?[^:]+):(?\d+):[^ ]+ (?[^ ]+)/,
        MESSAGE_TYPE_CATEGORIZER,
      )
    end
  end
end

Web Proxy Viewer  |  New URL  |  Original Page