Class: PmdTester::PmdConfigError

Inherits:
Object
  • Object
show all
Defined in:
lib/pmdtester/pmd_configerror.rb

Overview

This class represents a ‘configerror’ element of Pmd xml report and which Pmd branch the ‘configerror’ is from

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs, branch) ⇒ PmdConfigError

Returns a new instance of PmdConfigError.



18
19
20
21
22
23
# File 'lib/pmdtester/pmd_configerror.rb', line 18

def initialize(attrs, branch)
  @attrs = attrs

  @changed = false
  @branch = branch
end

Instance Attribute Details

#attrsObject (readonly)

The schema of ‘configerror’ node: <xs:complexType name=“configerror”>

<xs:attribute name="rule" type="xs:string" use="required" />
<xs:attribute name="msg" type="xs:string" use="required" />

</xs:complexType>



15
16
17
# File 'lib/pmdtester/pmd_configerror.rb', line 15

def attrs
  @attrs
end

#branchObject (readonly)

The pmd branch type, ‘base’ or ‘patch’



8
9
10
# File 'lib/pmdtester/pmd_configerror.rb', line 8

def branch
  @branch
end

#old_errorObject

Returns the value of attribute old_error.



16
17
18
# File 'lib/pmdtester/pmd_configerror.rb', line 16

def old_error
  @old_error
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/pmdtester/pmd_configerror.rb', line 37

def changed?
  @changed
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pmdtester/pmd_configerror.rb', line 41

def eql?(other)
  rulename.eql?(other.rulename) && msg.eql?(other.msg)
end

#hashObject



58
59
60
# File 'lib/pmdtester/pmd_configerror.rb', line 58

def hash
  [rulename, msg].hash
end

#msgObject



29
30
31
# File 'lib/pmdtester/pmd_configerror.rb', line 29

def msg
  @attrs['msg']
end

#rulenameObject



25
26
27
# File 'lib/pmdtester/pmd_configerror.rb', line 25

def rulename
  @attrs['rule']
end

#sort_keyObject



33
34
35
# File 'lib/pmdtester/pmd_configerror.rb', line 33

def sort_key
  rulename
end

#try_merge?(other) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pmdtester/pmd_configerror.rb', line 45

def try_merge?(other)
  if branch != BASE &&
     branch != other.branch &&
     rulename == other.rulename &&
     !changed? # not already changed
    @changed = true
    @old_error = other
    true
  end

  false
end