Sha256: 441d0a10b37f763bf4e1285191ac600739bf445a19c40fbe81a74bd43abee768

Contents?: true

Size: 484 Bytes

Versions: 25

Compression:

Stored size: 484 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Checks the syntax of any modified JSON files.
  class JsonSyntax < Base
    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
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
overcommit-0.62.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.61.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.60.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.59.1 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.59.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.58.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.57.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.56.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.55.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.54.1 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.54.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.53.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.52.1 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.52.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.51.0 lib/overcommit/hook/pre_commit/json_syntax.rb
overcommit-0.50.0 lib/overcommit/hook/pre_commit/json_syntax.rb