Sha256: 68c9dd193daa640b309f470b4252b26874b47ae3642e3ca216ce7e6a8150b3b0

Contents?: true

Size: 775 Bytes

Versions: 17

Compression:

Stored size: 775 Bytes

Contents

module CC
  module Analyzer
    class EngineOutputFilter
      ISSUE_TYPE = "issue".freeze

      def initialize(config = {})
        @config = config
      end

      def filter?(output)
        if (json = parse_as_json(output))
          issue?(json) && ignore_issue?(json)
        else
          false
        end
      end

      private

      def parse_as_json(output)
        JSON.parse(output)
      rescue JSON::ParserError
        nil
      end

      def issue?(json)
        json["type"] == ISSUE_TYPE
      end

      def ignore_issue?(json)
        !check_config(json["check"]).fetch("enabled", true)
      end

      def check_config(check_name)
        @checks ||= @config.fetch("checks", {})
        @checks.fetch(check_name, {})
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
codeclimate-0.4.1 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.4.0 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.3.2 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.3.1 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.3.0 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.12 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.11 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.9 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.7 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.6 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.4 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.2 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2.1 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.2 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.1.5 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.1.4 lib/cc/analyzer/engine_output_filter.rb
codeclimate-0.1.3 lib/cc/analyzer/engine_output_filter.rb