Sha256: c0e9e63dc1abda39664fbe0668b25dad69c4ede7e4eef9d64d16c05084fd0d4f

Contents?: true

Size: 450 Bytes

Versions: 19

Compression:

Stored size: 450 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Checks the syntax of any modified YAML files.
  class YamlSyntax < Base
    def run
      messages = []

      applicable_files.each do |file|
        begin
          YAML.load_file(file)
        rescue ArgumentError, Psych::SyntaxError => e
          messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
        end
      end

      messages
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

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