Sha256: 6eb22768b8dff16c68afab3744452d742e16d936faae901badc32104337b910a
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true # Represent a BugInstance. class BugInstance RANK_ERROR_THRESHOLD = 4 attr_reader :absolute_path, :relative_path attr_accessor :source_dirs, :bug_instance def initialize(prefix, source_dirs, bug_instance) @source_dirs = source_dirs @bug_instance = bug_instance source_path = bug_instance.xpath('SourceLine').attribute('sourcepath').first.value.to_s @absolute_path = get_absolute_path(source_path) prefix += (prefix.end_with?(file_separator) ? '' : file_separator) @relative_path = if @absolute_path.start_with?(prefix) @absolute_path[prefix.length, @absolute_path.length - prefix.length] else @absolute_path end end def rank @rank ||= bug_instance.attribute('rank').value.to_i end def type @type ||= rank > RANK_ERROR_THRESHOLD ? :warn : :fail end def line @line ||= bug_instance.xpath('SourceLine').attribute('start').first.value.to_i end def description @description ||= bug_instance.xpath('LongMessage').text end private def get_absolute_path(source_path) @source_dirs.map do |source_dir| return source_dir if source_dir.end_with?(source_path) end end def file_separator File::ALT_SEPARATOR || File::SEPARATOR end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danger-spotbugs-0.0.2 | lib/spotbugs/entity/bug_instance.rb |
danger-spotbugs-0.0.1 | lib/spotbugs/entity/bug_instance.rb |