Sha256: 6507dab479eda58e9ce141b5e2468e42e9d967a5b78bad7fbe700efc5572977f

Contents?: true

Size: 1 KB

Versions: 46

Compression:

Stored size: 1 KB

Contents

module CC
  module Analyzer
    class Issue
      SPEC_ISSUE_ATTRIBUTES = %w[
        categories
        check_name
        content
        description
        location
        other_locations
        remediation_points
        severity
        type
      ]

      def initialize(output)
        @output = output
      end

      def as_json(*)
        parsed_output.reverse_merge!(
          "fingerprint" => fingerprint,
        )
      end

      def fingerprint
        parsed_output.fetch("fingerprint") { default_fingerprint }
      end

      # Allow access to hash keys as methods
      SPEC_ISSUE_ATTRIBUTES.each do |key|
        define_method(key) do
          parsed_output[key]
        end
      end

      def path
        parsed_output.fetch("location", {}).fetch("path", "")
      end

      private

      attr_reader :output

      def default_fingerprint
        SourceFingerprint.new(self).compute
      end

      def parsed_output
        @parsed_output ||= JSON.parse(output)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
codeclimate-0.55.0 lib/cc/analyzer/issue.rb
codeclimate-0.54.0 lib/cc/analyzer/issue.rb
codeclimate-0.53.0 lib/cc/analyzer/issue.rb
codeclimate-0.52.0 lib/cc/analyzer/issue.rb
codeclimate-0.51.3 lib/cc/analyzer/issue.rb
codeclimate-0.51.2 lib/cc/analyzer/issue.rb
codeclimate-0.51.1 lib/cc/analyzer/issue.rb
codeclimate-0.51.0 lib/cc/analyzer/issue.rb
codeclimate-0.50.0 lib/cc/analyzer/issue.rb
codeclimate-0.49.0 lib/cc/analyzer/issue.rb
codeclimate-0.48.0 lib/cc/analyzer/issue.rb
codeclimate-0.47.0 lib/cc/analyzer/issue.rb
codeclimate-0.46.0 lib/cc/analyzer/issue.rb
codeclimate-0.45.0 lib/cc/analyzer/issue.rb
codeclimate-0.44.0 lib/cc/analyzer/issue.rb
codeclimate-0.43.1 lib/cc/analyzer/issue.rb
codeclimate-0.43.0 lib/cc/analyzer/issue.rb
codeclimate-0.42.1 lib/cc/analyzer/issue.rb
codeclimate-0.42.0 lib/cc/analyzer/issue.rb
codeclimate-0.41.0 lib/cc/analyzer/issue.rb