Class: MetricAdapter::Metric

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

Overview

A normalized representation of a code metric.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, signature, message) ⇒ Metric

Create an instance of Metric. ‘location` is expected to be a `Location` instance



21
22
23
24
25
26
# File 'lib/metric.rb', line 21

def initialize(location, signature,  message)
  @location  = location
  @signature = signature
  @message   = message
  @score     = 0
end

Instance Attribute Details

#locationObject

Location where this metric applies (see the Location class)



7
8
9
# File 'lib/metric.rb', line 7

def location
  @location
end

#messageObject

Message indicating the issue being reported



13
14
15
# File 'lib/metric.rb', line 13

def message
  @message
end

#scoreObject

Optional score for for the metric indicating severity A score is not normalized across analyzers



17
18
19
# File 'lib/metric.rb', line 17

def score
  @score
end

#signatureObject

Associated class and method signature



10
11
12
# File 'lib/metric.rb', line 10

def signature
  @signature
end

Instance Method Details

#lineObject

Returns the line number this metric applies to.



35
36
37
# File 'lib/metric.rb', line 35

def line
  location.line
end

#pathObject

Returns the path that this metric applies to, for example:

./lib/metric.rb


30
31
32
# File 'lib/metric.rb', line 30

def path
  location.path
end