class PmdTester::PmdError

This class represents a 'error' element of Pmd xml report and which Pmd branch the 'error' is from

Attributes

branch[R]

The pmd branch type, 'base' or 'patch'

filename[R]
old_error[RW]
short_message[R]
stack_trace[RW]

The schema of 'error' node:

 <xs:complexType name="error">
   <xs:simpleContent>
     <xs:extension base="xs:string">
       <xs:attribute name="filename" type="xs:string" use="required"/>
       <xs:attribute name="msg" type="xs:string" use="required"/>
     </xs:extension>
   </xs:simpleContent>
</xs:complexType>

Public Class Methods

new(branch:, filename:, short_message:) click to toggle source
# File lib/pmdtester/pmd_error.rb, line 24
def initialize(branch:, filename:, short_message:)
  @branch = branch
  @stack_trace = ''
  @changed = false
  @short_message = short_message
  @filename = filename
end

Public Instance Methods

changed?() click to toggle source
# File lib/pmdtester/pmd_error.rb, line 36
def changed?
  @changed
end
eql?(other) click to toggle source
# File lib/pmdtester/pmd_error.rb, line 40
def eql?(other)
  filename.eql?(other.filename) &&
    short_message.eql?(other.short_message) &&
    stack_trace.eql?(other.stack_trace)
end
hash() click to toggle source
# File lib/pmdtester/pmd_error.rb, line 46
def hash
  [filename, stack_trace].hash
end
short_filename() click to toggle source
# File lib/pmdtester/pmd_error.rb, line 32
def short_filename
  filename.gsub(%r{([^/]*+/)+}, '')
end
sort_key() click to toggle source
# File lib/pmdtester/pmd_error.rb, line 50
def sort_key
  filename
end
try_merge?(other) click to toggle source
# File lib/pmdtester/pmd_error.rb, line 54
def try_merge?(other)
  if branch != BASE &&
     branch != other.branch &&
     filename == other.filename &&
     !changed? # not already changed
    @changed = true
    @old_error = other
    true
  else
    false
  end
end