Sha256: ddc0bd1c97cbfea18cfdf0587ef506862f329cb4da5cbcc3df970854fa7bb066

Contents?: true

Size: 787 Bytes

Versions: 75

Compression:

Stored size: 787 Bytes

Contents

module CC
  module Analyzer
    class EngineOutput
      delegate :blank?, to: :raw_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

      def valid?
        validator.valid?
      end

      def error
        validator.error
      end

      private

      attr_accessor :raw_output

      def parsed_output
        @parsed_output ||= JSON.parse(raw_output)
      rescue JSON::ParserError
        nil
      end

      def validator
        IssueValidator.new(parsed_output)
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
codeclimate-0.32.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.32.0.rc1 lib/cc/analyzer/engine_output.rb
codeclimate-0.31.1 lib/cc/analyzer/engine_output.rb
codeclimate-0.31.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.30.1 lib/cc/analyzer/engine_output.rb
codeclimate-0.30.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.29.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.28.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.27.2 lib/cc/analyzer/engine_output.rb
codeclimate-0.27.1 lib/cc/analyzer/engine_output.rb
codeclimate-0.27.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.27.0.rc1 lib/cc/analyzer/engine_output.rb
codeclimate-0.26.0 lib/cc/analyzer/engine_output.rb
codeclimate-0.25.1 lib/cc/analyzer/engine_output.rb
codeclimate-0.25.0 lib/cc/analyzer/engine_output.rb