Parse a JSON code coverage file and report that information as a
 message in Danger.
 @return  [void]
340733
def report(coverage_path, sticky: true)
      if File.exist? coverage_path
        coverage_json = JSON.parse(File.read(coverage_path), symbolize_names: true)
        metrics = coverage_json[:metrics]
        percentage = metrics[:covered_percent]
        lines = metrics[:covered_lines]
        total_lines = metrics[:total_lines]

        formatted_percentage = format('%.02f', percentage)
        message("Code coverage is now at #{formatted_percentage}% (#{lines}/#{total_lines} lines)", sticky: sticky)
      else
        fail('Code coverage data not found')
      end
    end
388304
def parse_file(path, target_ext=nil)
      return nil if path.nil?
      return nil if File.directory? path
      _load_from_file path, target_ext
      # if File.directory? path
      #   _load_from_directory path
      # else
      #   _load_from_file path, target_ext
      # end
    end
1272127
def parse_json(response)
			json_response = JSON.parse(response)
			error = json_response['error']
			if !error.nil? then raise APIException.new(error) end
			return json_response
		end
432442
def parse_warnings
      @warning_count = @xcodebuild_json["warnings"].count
      @warning_count = @warning_count + @xcodebuild_json["ld_warnings"].count
      @warning_count = @warning_count + @xcodebuild_json["compile_warnings"].count
      if @warning_count > 0 && post_messages
        warning_string = @warning_count == 1 ? "warning" : "warnings"
        message = Array.new
        message.push (@build_title) unless @build_title.nil?
        message.push("Please fix **#{@warning_count}** #{warning_string} 😒")
        warn(message.reject(&:empty?).join(" "))
      end
      return @warning_count
    end
1309096
def parse_visibility(code, default, container)
      result = []
      visibility_default = default || :public

      used_modules = []
      container.includes.each{|i| used_modules << i.name} if container

      remaining_code = code.gsub(/^\s*?type[\s\,]+.*?\s+end\s+type.*?$/im, "")
      remaining_code.split("\n").each{ |line|
        if /^\s*?private\s*?$/ =~ line
          visibility_default = :private
          break
        end
      } if remaining_code

      remaining_code.split("\n").each{ |line|
        if /^\s*?private\s*?(::)?\s+(.*)\s*?(!.*?)?/i =~ line
          methods = $2.sub(/!.*$/, '')
          methods.split(",").each{ |meth|
            meth.sub!(/!.*$/, '')
            meth.gsub!(/:/, '')
            result << {
              "name" => meth.chomp.strip,
              "visibility" => :private,
              "used_modules" => used_modules.clone,
              "file_or_module" => container,
              "entity_is_discovered" => nil,
              "local_name" => nil
            }
          }
        elsif /^\s*?public\s*?(::)?\s+(.*)\s*?(!.*?)?/i =~ line
          methods = $2.sub(/!.*$/, '')
          methods.split(",").each{ |meth|
            meth.sub!(/!.*$/, '')
            meth.gsub!(/:/, '')
            result << {
              "name" => meth.chomp.strip,
              "visibility" => :public,
              "used_modules" => used_modules.clone,
              "file_or_module" => container,
              "entity_is_discovered" => nil,
              "local_name" => nil
            }
          }
        end
      } if remaining_code

      if container
        result.each{ |vis_info|
          vis_info["parent"] = container.name
        }
      end

      return visibility_default, result
    end
238432
def help_now!(message=nil)
      exception = OptionParser::ParseError.new(message)
      class << exception
        def exit_code; 64; end
      end
      raise exception
    end
454713
def parse_response(response)
      case response.content_type
      when JSON_CONTENT_TYPE
        JSON.parse(response.body, quirks_mode: true, symbolize_names: true)
      else
        response.body
      end
    end
36778
def json
      return @json if defined?(@json)
      # no content, no JSON
      if @response.code.to_s == '204'
        data = {}
      elsif @response.body.blank?
        # no body, no json
        data = {message: @response.message.blank? ? 'empty body' : @response.message.strip}
      end
      begin
        data ||= JSON.parse(@response.body)
      rescue ::Exception => e
        data = { message: "Invalid JSON - #{e.message} for:\n#{@response.body}" }
      end
      # indifferent access to hashes
      data = data.is_a?(Array) ? data.map(&:with_indifferent_access) : data.with_indifferent_access
      # empty OK response is not seen as an error
      data = {} if data.is_a?(Hash) && data.size == 1 && data[:message] == 'OK'
      # prepend HTTP response code to message
      data[:message] = "#{response.code}: #{data[:message]}" unless @response.is_a?(Net::HTTPSuccess)
      @json = data
    end
1215201
def parse
      if pre_parse
        messages = @file_reader.other_lines.map do |line|
          basic_message_match =  @line_regex.match(line)
          meta_message_match = @line_regex_status.match(line)
          if basic_message_match
            create_message(basic_message_match)
          elsif meta_message_match
            create_status_or_event_message(meta_message_match)
          end
        end

        Chat.new(messages, @metadata)
      end
    end
1261267
def report(file_path)
      raise 'ShellCheck summary file not found' unless File.file?(file_path)
      shellcheck_summary = JSON.parse(File.read(file_path), symbolize_names: true)
      run_summary(shellcheck_summary)
    end
537626
def parse_response(response)
      check_version_and_warn(response.headers[X_KONTENA_VERSION])

      if response.headers[CONTENT_TYPE] =~ JSON_REGEX
        parse_json(response)
      else
        response.body
      end
    end
290080
def code( *args, &blk )
  # check for optional hash for options
  opts = args.last.kind_of?(Hash) ? args.pop : {}
  
  name_plus_part = args.first   # check for optional filename
    
  if name_plus_part 
    name, part = name_plus_part.split( '#' ) # split off optional part/anchor 
    
    content = find_content_from( name, part ) 
    
    # add name and part to opts so engine can use paras too  
    opts[ :name ] = name  
    opts[ :part ] = part if part
    
    return format_code( content, opts )
  elsif blk # inline code via block?
    content = capture_erb(&blk)
    return if content.empty?

    concat_erb( format_code( content, opts ), blk.binding )
    return
  else
    msg = '*** warning: empty code directive; inline code or file para expected'
    puts msg 
    return wrap_markup( "<!-- #{msg} -->" )
  end
end
954612
def raw_response(json, status)
      json.empty? ? {} : JSON.parse(json, symbolize_names: true)
    rescue StandardError
      { message: json, code: status }
    end
923734
def parse_coverage(coverage_report, parser):
    
    if parser in PARSERS:
        if coverage_report:
            return PARSERS[parser].parse_coverage_report(coverage_report)
        return None
    return NotImplemented
1201838
def parse_json(body)
      buf = {}

      begin
        buf = JSON.parse(body)
      rescue JSON::ParserError
      end

      buf
    end
116196
def error(response)
      if (response.content_type || "").include?("json")
        # Attempt to parse the error as JSON
        begin
          json = JSON.parse(response.body)

          if json["errors"] && json["errors"].first
            raise Error::HTTPError.new(json["errors"].first)
          end
        rescue JSON::ParserError; end
      end

      raise Error::HTTPError.new(
        "status"  => response.code,
        "message" => response.body
      )
    end
503670
def parse_response(response:, params: nil, body: {})
      if response.code < 299
        body[:data] = parse_json(response.body)
        body[:success] = true
      else
        error = write_error_message(response)
        body[:error] = error
        body[:success] = false
      end
      body[:code] = response.code
      body.merge!(raw: { body: response.body, params: params })
    end