Class: Overcommit::GitHook::YamlSyntax

Inherits:
HookSpecificCheck show all
Includes:
HookRegistry
Defined in:
lib/overcommit/plugins/pre_commit/yaml_syntax.rb

Instance Method Summary collapse

Methods included from HookRegistry

included

Methods inherited from HookSpecificCheck

file_type, friendly_name, #initialize, #name, required!, #skip?, skippable?, #staged, stealth!, #stealth?

Constructor Details

This class inherits a constructor from Overcommit::GitHook::HookSpecificCheck

Instance Method Details

#run_checkObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/overcommit/plugins/pre_commit/yaml_syntax.rb', line 8

def run_check
  clean = true
  output = []
  staged.each do |staged_file|
    begin
      YAML.load_file(staged_file.path)
    rescue ArgumentError => e
      output << "#{e.message} parsing #{staged_file.path}"
      clean = false
    end
  end
  return (clean ? :good : :bad), output
end