Module: ScoringStrategies

Extended by:
ScoringStrategies
Included in:
ChurnAnalyzer, FlayAnalyzer, FlogAnalyzer, RcovAnalyzer, ReekAnalyzer, RoodiAnalyzer, SaikuroAnalyzer, ScoringStrategies
Defined in:
lib/base/scoring_strategies.rb

Instance Method Summary collapse

Instance Method Details

#average(scores) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/base/scoring_strategies.rb', line 19

def average(scores)
  # remove dependency on statarray
  # scores.to_statarray.mean
  score_length = scores.length
  sum = 0
  sum = scores.inject( nil ) { |sum,x| sum ? sum+x : x }
  (sum.to_f / score_length.to_f)
end

#identity(ranking, item) ⇒ Object



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

def identity(ranking, item)
  ranking[item] # Use the score you got (ex flog score of 20 is not bad even if it is the top one in project)
end

#percentile(ranking, item) ⇒ Object



3
4
5
# File 'lib/base/scoring_strategies.rb', line 3

def percentile(ranking, item)
  ranking.percentile(item) # per project score percentile
end

#present(row) ⇒ Object



11
12
13
# File 'lib/base/scoring_strategies.rb', line 11

def present(row)
  1 # If present it's a one, not present it's a zero - For things like Reek that don't have a number
end

#sum(scores) ⇒ Object



15
16
17
# File 'lib/base/scoring_strategies.rb', line 15

def sum(scores)
  scores.inject(0) {|s,x| s+x}
end