Sha256: 325eaabfe6f490499bc07e0cf268ceff325874d69f06953f9c5ae0fd2740eaf5

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

module CC
  module Analyzer
    class EngineOutput
      delegate :blank?, to: :chomped_output
      delegate :to_json, to: :as_issue

      def initialize(raw_output)
        @raw_output = raw_output
      end

      def issue?
        parsed_output &&
          parsed_output["type"].present? &&
          parsed_output["type"].downcase == "issue"
      end

      def as_issue
        Issue.new(raw_output)
      end

      private

      attr_accessor :raw_output

      def parsed_output
        JSON.parse(chomped_output)
      rescue JSON::ParserError
        nil
      end

      # Docker can put start-of-text characters when logging,
      # which show up as issues. Remove them here if they are at either end
      # of the output and then check blankness.
      # https://github.com/docker/docker/issues/7375
      def chomped_output
        @chomped_output ||= raw_output.chomp("\u0002")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codeclimate-0.18.4 lib/cc/analyzer/engine_output.rb
codeclimate-0.18.3 lib/cc/analyzer/engine_output.rb