Class: PmdTester::PmdError
- Inherits:
-
Object
- Object
- PmdTester::PmdError
- Includes:
- PmdTester
- Defined in:
- lib/pmdtester/pmd_error.rb
Overview
This class represents a ‘error’ element of Pmd xml report and which Pmd branch the ‘error’ is from
Constant Summary
Constants included from PmdTester
BASE, PATCH, PR_NUM_ENV_VAR, VERSION
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
The pmd branch type, ‘base’ or ‘patch’.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#old_error ⇒ Object
Returns the value of attribute old_error.
-
#short_message ⇒ Object
readonly
Returns the value of attribute short_message.
-
#stack_trace ⇒ Object
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>.
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(branch:, filename:, short_message:) ⇒ PmdError
constructor
A new instance of PmdError.
- #short_filename ⇒ Object
- #sort_key ⇒ Object
- #try_merge?(other) ⇒ Boolean
Methods included from PmdTester
Constructor Details
#initialize(branch:, filename:, short_message:) ⇒ PmdError
Returns a new instance of PmdError.
24 25 26 27 28 29 30 |
# File 'lib/pmdtester/pmd_error.rb', line 24 def initialize(branch:, filename:, short_message:) @branch = branch @stack_trace = '' @changed = false @short_message = @filename = filename end |
Instance Attribute Details
#branch ⇒ Object (readonly)
The pmd branch type, ‘base’ or ‘patch’
9 10 11 |
# File 'lib/pmdtester/pmd_error.rb', line 9 def branch @branch end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
22 23 24 |
# File 'lib/pmdtester/pmd_error.rb', line 22 def filename @filename end |
#old_error ⇒ Object
Returns the value of attribute old_error.
21 22 23 |
# File 'lib/pmdtester/pmd_error.rb', line 21 def old_error @old_error end |
#short_message ⇒ Object (readonly)
Returns the value of attribute short_message.
22 23 24 |
# File 'lib/pmdtester/pmd_error.rb', line 22 def @short_message end |
#stack_trace ⇒ Object
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>
20 21 22 |
# File 'lib/pmdtester/pmd_error.rb', line 20 def stack_trace @stack_trace end |
Instance Method Details
#changed? ⇒ Boolean
36 37 38 |
# File 'lib/pmdtester/pmd_error.rb', line 36 def changed? @changed end |
#eql?(other) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/pmdtester/pmd_error.rb', line 40 def eql?(other) filename.eql?(other.filename) && .eql?(other.) && stack_trace.eql?(other.stack_trace) end |
#hash ⇒ Object
46 47 48 |
# File 'lib/pmdtester/pmd_error.rb', line 46 def hash [filename, stack_trace].hash end |
#short_filename ⇒ Object
32 33 34 |
# File 'lib/pmdtester/pmd_error.rb', line 32 def short_filename filename.gsub(%r{([^/]*+/)+}, '') end |
#sort_key ⇒ Object
50 51 52 |
# File 'lib/pmdtester/pmd_error.rb', line 50 def sort_key filename end |
#try_merge?(other) ⇒ Boolean
54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 |