Class: Bugwatch::FlogScore
- Inherits:
-
Object
- Object
- Bugwatch::FlogScore
show all
- Includes:
- RubyFileAdapter
- Defined in:
- lib/bugwatch/flog_score.rb
Instance Method Summary
collapse
#analyzable_file?, #ruby_file?, #test_file?
Constructor Details
#initialize(diff_contents) ⇒ FlogScore
Returns a new instance of FlogScore.
39
40
41
|
# File 'lib/bugwatch/flog_score.rb', line 39
def initialize(diff_contents)
@diff_contents = diff_contents
end
|
Instance Method Details
#average ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/bugwatch/flog_score.rb', line 49
def average
average_score = scores.reduce(0.0) do |memo, score|
_, before_score, after_score = score
(after_score - before_score) + memo
end / scores.size.to_f
average_score.nan? ? 0.0 : average_score
end
|
#scores ⇒ Object
43
44
45
46
47
|
# File 'lib/bugwatch/flog_score.rb', line 43
def scores
filtered_diff_contents.map do |diff_content|
[diff_content.path, score_blob(diff_content.a_blob), score_blob(diff_content.b_blob)]
end
end
|
#total_score ⇒ Object
57
58
59
60
61
|
# File 'lib/bugwatch/flog_score.rb', line 57
def total_score
scores.reduce(0) do |calculated_score, (_, before_score, after_score)|
calculated_score + (after_score - before_score)
end
end
|