Sha256: ea7939d695e6f4ada21d94e6d0587bfa2ecd2085fc6c7c9b884de99a4a7d4553

Contents?: true

Size: 650 Bytes

Versions: 19

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs 'sqlint' against any modified SQL files.
  #
  # @see https://github.com/purcell/sqlint
  class Sqlint < Base
    MESSAGE_REGEX = /(?<file>(?:\w:)?.+):(?<line>\d+):\d+:(?<type>\w+)/

    MESSAGE_TYPE_CATEGORIZER = lambda do |type|
      type == 'ERROR' ? :error : :warning
    end

    def run
      result = execute(command, args: applicable_files)
      output = result.stdout.chomp
      return :pass if result.success? && output.empty?

      extract_messages(
        output.split("\n"),
        MESSAGE_REGEX,
        MESSAGE_TYPE_CATEGORIZER
      )
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
overcommit-0.58.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.57.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.56.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.55.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.54.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.54.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.53.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.52.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.52.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.51.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.50.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.49.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.49.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.48.1 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.48.0 lib/overcommit/hook/pre_commit/sqlint.rb
overcommit-0.47.0 lib/overcommit/hook/pre_commit/sqlint.rb