Class: BugInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/spotbugs/entity/bug_instance.rb

Overview

Represent a BugInstance.

Constant Summary collapse

RANK_ERROR_THRESHOLD =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, source_dirs, bug_instance) ⇒ BugInstance

Returns a new instance of BugInstance.



9
10
11
12
13
14
15
16
17
18
# File 'lib/spotbugs/entity/bug_instance.rb', line 9

def initialize(prefix, source_dirs, bug_instance)
  @source_dirs = source_dirs
  @bug_instance = bug_instance

  source_path = get_source_path(bug_instance)
  @absolute_path = get_absolute_path(source_path)

  prefix += (prefix.end_with?(file_separator) ? '' : file_separator)
  @relative_path = get_relative_path(prefix, @absolute_path)
end

Instance Attribute Details

#absolute_pathObject (readonly)

Returns the value of attribute absolute_path.



6
7
8
# File 'lib/spotbugs/entity/bug_instance.rb', line 6

def absolute_path
  @absolute_path
end

#bug_instanceObject

Returns the value of attribute bug_instance.



7
8
9
# File 'lib/spotbugs/entity/bug_instance.rb', line 7

def bug_instance
  @bug_instance
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



6
7
8
# File 'lib/spotbugs/entity/bug_instance.rb', line 6

def relative_path
  @relative_path
end

#source_dirsObject

Returns the value of attribute source_dirs.



7
8
9
# File 'lib/spotbugs/entity/bug_instance.rb', line 7

def source_dirs
  @source_dirs
end

Instance Method Details

#descriptionObject



32
33
34
# File 'lib/spotbugs/entity/bug_instance.rb', line 32

def description
  @description ||= bug_instance.xpath('LongMessage').text
end

#lineObject



28
29
30
# File 'lib/spotbugs/entity/bug_instance.rb', line 28

def line
  @line ||= get_value_safely(bug_instance.xpath('SourceLine').attribute('start'), 0).to_i
end

#rankObject



20
21
22
# File 'lib/spotbugs/entity/bug_instance.rb', line 20

def rank
  @rank ||= bug_instance.attribute('rank').value.to_i
end

#typeObject



24
25
26
# File 'lib/spotbugs/entity/bug_instance.rb', line 24

def type
  @type ||= rank > RANK_ERROR_THRESHOLD ? :warn : :fail
end