Class: Watchr::FlayMetric::Report
- Inherits:
-
Flay
- Object
- Flay
- Watchr::FlayMetric::Report
- Defined in:
- lib/watchr/metrics/flay/report.rb
Overview
Adapted Flay report metric.
Instance Attribute Summary collapse
-
#duplications ⇒ Object
readonly
Returns the value of attribute duplications.
Instance Method Summary collapse
- #duplications_by_file(path) ⇒ Object
-
#initialize(path) ⇒ Report
constructor
A new instance of Report.
- #process_result ⇒ Object
- #total_score ⇒ Object
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.(path) process(*files) process_result end |
Instance Attribute Details
#duplications ⇒ Object (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_result ⇒ Object
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_score ⇒ Object
23 24 25 |
# File 'lib/watchr/metrics/flay/report.rb', line 23 def total_score total end |