Sha256: 28efcf7a2e2a9fb22f90b79fba4c6b720cf8da766ae5d8f500ccecfd0f49e135

Contents?: true

Size: 974 Bytes

Versions: 52

Compression:

Stored size: 974 Bytes

Contents

module CC
  module Analyzer
    module Formatters
      class Formatter
        def initialize(filesystem, output = $stdout)
          @filesystem = filesystem
          @output = output
        end

        def write(data)
          json = JSON.parse(data)
          json["engine_name"] = current_engine.name

          case json["type"].downcase
          when "issue"
            issues << json
          when "warning"
            warnings << json
          else
            raise "Invalid type found: #{json["type"]}"
          end
        end

        def started
        end

        def engine_running(engine)
          @current_engine = engine
          yield
        ensure
          @current_engine = nil
        end

        def finished
        end

        def close
        end

        def failed(_output)
        end

        InvalidFormatterError = Class.new(StandardError)

        private

        attr_reader :current_engine
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
codeclimate-0.69.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.68.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.67.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.66.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.65.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.64.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.7 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.6 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.5 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.4 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.3 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.2 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.1 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.63.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.62.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.61.1 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.61.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.60.1 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.60.0 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.59.1 lib/cc/analyzer/formatters/formatter.rb