class PmdTester::PmdViolation
This class represents a 'violation' element of Pmd xml report and which pmd branch the 'violation' is from
Attributes
The pmd branch type, 'base' or 'patch'
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
The schema of 'violation' element: <xs:complexType name=“violation”>
<xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="beginline" type="xs:integer" use="required" /> <xs:attribute name="endline" type="xs:integer" use="required" /> <xs:attribute name="begincolumn" type="xs:integer" use="required" /> <xs:attribute name="endcolumn" type="xs:integer" use="required" /> <xs:attribute name="rule" type="xs:string" use="required" /> <xs:attribute name="ruleset" type="xs:string" use="required" /> <xs:attribute name="package" type="xs:string" use="optional" /> <xs:attribute name="class" type="xs:string" use="optional" /> <xs:attribute name="method" type="xs:string" use="optional" /> <xs:attribute name="variable" type="xs:string" use="optional" /> <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" /> <xs:attribute name="priority" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent>
</xs:complexType>
Public Class Methods
rubocop:disable Metrics/ParameterLists Disable it: how is replacing a long parameter list with a single hash helping?
# File lib/pmdtester/pmd_violation.rb, line 35 def initialize(branch:, fname:, info_url:, bline:, rule_name:, ruleset_name:) @branch = branch @fname = fname @message = '' @info_url = info_url @line = bline @rule_name = rule_name @ruleset_name = ruleset_name @changed = false @old_message = nil @old_line = nil end
Public Instance Methods
only makes sense if this is a diff
# File lib/pmdtester/pmd_violation.rb, line 70 def added? branch != BASE && !changed? end
only makes sense if this is a diff
# File lib/pmdtester/pmd_violation.rb, line 75 def changed? @changed end
# File lib/pmdtester/pmd_violation.rb, line 88 def eql?(other) rule_name.eql?(other.rule_name) && line.eql?(other.line) && fname.eql?(other.fname) && message.eql?(other.message) end
# File lib/pmdtester/pmd_violation.rb, line 95 def hash [line, rule_name, message].hash end
rubocop:enable Metrics/ParameterLists
# File lib/pmdtester/pmd_violation.rb, line 52 def line_move?(other) message.eql?(other.message) && (line - other.line).abs <= 5 end
only makes sense if this is a diff
# File lib/pmdtester/pmd_violation.rb, line 80 def removed? branch == BASE end
# File lib/pmdtester/pmd_violation.rb, line 84 def sort_key line end
# File lib/pmdtester/pmd_violation.rb, line 99 def to_liquid { 'branch' => branch, 'changed' => changed? } end
# File lib/pmdtester/pmd_violation.rb, line 56 def try_merge?(other) if branch != BASE && branch != other.branch && rule_name == other.rule_name && !changed? && # not already changed (line == other.line || line_move?(other)) @changed = true @old_message = other.message @old_line = other.line true else false end end