Sha256: 15bc04b74cd0c73986d8b1aff5cc711066e99f02952f14445f3b8a463d121d94

Contents?: true

Size: 743 Bytes

Versions: 9

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  #
  # Run's the Puppet metadata linter. It has support for adding options
  # in the .overcommit.yaml
  #
  # @see https://voxpupuli.org/blog/2014/11/06/linting-metadata-json/
  #
  class PuppetMetadataJsonLint < Base
    MESSAGE_REGEX = /\((?<type>.*)\).*/.freeze

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

    def run
      result = execute(command, args: applicable_files)
      output = result.stdout.chomp.gsub(/^"|"$/, '')
      return :pass if result.success? && output.empty?

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

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
overcommit-0.64.1 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.64.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.63.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.62.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.61.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.60.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.59.1 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-0.59.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb