Sha256: 71d8384923a67217298358dc492a1f0c44bfa01ed8b1646912c4aefff2f758a8

Contents?: true

Size: 639 Bytes

Versions: 2

Compression:

Stored size: 639 Bytes

Contents

require "digest/md5"

module CC
  module Analyzer
    class SourceFingerprint
      def initialize(issue)
        @issue = issue
      end

      def compute
        md5 = Digest::MD5.new
        md5 << issue.path
        md5 << issue.check_name.to_s
        md5 << relevant_source.gsub(/\s+/, "") if relevant_source
        md5.hexdigest
      end

      private

      attr_reader :issue

      def relevant_source
        source = SourceExtractor.new(raw_source).extract(issue.location)
        source if source && !source.empty?
      end

      def raw_source
        @raw_source ||= File.read(issue.path)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codeclimate-0.27.0 lib/cc/analyzer/source_fingerprint.rb
codeclimate-0.27.0.rc1 lib/cc/analyzer/source_fingerprint.rb