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.
25 26 27 28 29 30 31 |
# File 'lib/pmdtester/pmd_error.rb', line 25 def initialize(branch:, filename:, short_message:) @branch = branch @stack_trace = '' @changed = false = @filename = filename end |
Instance Attribute Details
#branch ⇒ Object (readonly)
The pmd branch type, ‘base’ or ‘patch’
10 11 12 |
# File 'lib/pmdtester/pmd_error.rb', line 10 def branch @branch end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
23 24 25 |
# File 'lib/pmdtester/pmd_error.rb', line 23 def filename @filename end |
#old_error ⇒ Object
Returns the value of attribute old_error.
22 23 24 |
# File 'lib/pmdtester/pmd_error.rb', line 22 def old_error @old_error end |
#short_message ⇒ Object (readonly)
Returns the value of attribute short_message.
23 24 25 |
# File 'lib/pmdtester/pmd_error.rb', line 23 def 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>
21 22 23 |
# File 'lib/pmdtester/pmd_error.rb', line 21 def stack_trace @stack_trace end |
Instance Method Details
#changed? ⇒ Boolean
37 38 39 |
# File 'lib/pmdtester/pmd_error.rb', line 37 def changed? @changed end |
#eql?(other) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/pmdtester/pmd_error.rb', line 41 def eql?(other) filename.eql?(other.filename) && .eql?(other.) && stack_trace.eql?(other.stack_trace) end |
#hash ⇒ Object
47 48 49 |
# File 'lib/pmdtester/pmd_error.rb', line 47 def hash [filename, stack_trace].hash end |
#short_filename ⇒ Object
33 34 35 |
# File 'lib/pmdtester/pmd_error.rb', line 33 def short_filename filename.gsub(%r{([^/]*+/)+}, '') end |
#sort_key ⇒ Object
51 52 53 |
# File 'lib/pmdtester/pmd_error.rb', line 51 def sort_key filename end |
#try_merge?(other) ⇒ Boolean
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pmdtester/pmd_error.rb', line 55 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 |