Class: PmdViolation

Inherits:
Object
  • Object
show all
Defined in:
lib/pmd/entity/pmd_violation.rb

Overview

Represent a PMD violation.

Constant Summary collapse

PRIORITY_ERROR_THRESHOLD =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(violation) ⇒ PmdViolation

Returns a new instance of PmdViolation.



8
9
10
# File 'lib/pmd/entity/pmd_violation.rb', line 8

def initialize(violation)
  @violation = violation
end

Instance Attribute Details

#violationObject

Returns the value of attribute violation.



6
7
8
# File 'lib/pmd/entity/pmd_violation.rb', line 6

def violation
  @violation
end

Instance Method Details

#descriptionObject



24
25
26
# File 'lib/pmd/entity/pmd_violation.rb', line 24

def description
  @description ||= violation.text.gsub("\n", '')
end

#lineObject



20
21
22
# File 'lib/pmd/entity/pmd_violation.rb', line 20

def line
  @line ||= violation.attribute('beginline').value.to_i
end

#priorityObject



12
13
14
# File 'lib/pmd/entity/pmd_violation.rb', line 12

def priority
  @priority ||= violation.attribute('priority').value.to_i
end

#typeObject



16
17
18
# File 'lib/pmd/entity/pmd_violation.rb', line 16

def type
  @type ||= priority < PRIORITY_ERROR_THRESHOLD ? :warn : :fail
end