Method: Overcommit::Hook::PreCommit::JsonSyntax#run

Defined in:
lib/overcommit/hook/pre_commit/json_syntax.rb

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/overcommit/hook/pre_commit/json_syntax.rb', line 6

def run
  messages = []

  applicable_files.each do |file|
    begin
      JSON.parse(IO.read(file))
    rescue JSON::ParserError => e
      error = "#{e.message} parsing #{file}"
      messages << Overcommit::Hook::Message.new(:error, file, nil, error)
    end
  end

  messages
end