Class: Watchr::FlayMetric::Report

Inherits:
Flay
  • Object
show all
Defined in:
lib/watchr/metrics/flay/report.rb

Overview

Adapted Flay report metric.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Report

Returns a new instance of Report.



14
15
16
17
18
19
20
21
# File 'lib/watchr/metrics/flay/report.rb', line 14

def initialize(path)
  super(:mass => 12, :diff => true)

  files = Flay.expand_dirs_to_files(path)

  process(*files)
  process_result
end

Instance Attribute Details

#duplicationsObject (readonly)

Returns the value of attribute duplications.



12
13
14
# File 'lib/watchr/metrics/flay/report.rb', line 12

def duplications
  @duplications
end

Instance Method Details

#duplications_by_file(path) ⇒ Object



27
28
29
30
31
32
# File 'lib/watchr/metrics/flay/report.rb', line 27

def duplications_by_file(path)
  duplications.find_all do |duplication|
    false
#          duplication.locations.any? {|location| location.file == path}
  end
end

#process_resultObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/watchr/metrics/flay/report.rb', line 34

def process_result
  @duplications = []

  masses.sort_by { |h,m| [-m, hashes[h].first.file] }.each do |hash, mass|
    nodes = hashes[hash]

    same = identical[hash]
    node = nodes.first
    bonus = same ? nodes.size : 0

    @duplications << DiffFactory.build(same, nodes, bonus, mass)
  end
end

#total_scoreObject



23
24
25
# File 'lib/watchr/metrics/flay/report.rb', line 23

def total_score
  total
end