Created
October 26, 2011 13:23
-
-
Save michaelfeathers/1316333 to your computer and use it in GitHub Desktop.
Ruby in Haskell style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :: [event] -> [month,int] | |
def avg_lines_per_commit_by_month events | |
cls_by_month = lines_added_per_commit(events).group_by {|date,_| month_from_date(date) } | |
cls_by_month.map {|_,cls| cls.map {|cl| cl[1]}.mean }.flatten | |
end | |
# :: [event] -> Float | |
def percent_reduction method_events | |
non_deleted = method_events.select {|e| e.status != :deleted } | |
return 0.0 if non_deleted.count == 0 | |
num_reductions = non_deleted.each_cons(2) \ | |
.map {|before, after| after.method_length < before.method_length } \ | |
.count(true) | |
num_reductions / non_deleted.count.to_f | |
end | |
# :: [event] -> [FixNum] | |
def refactoring_reduction_profile events | |
events.group_by(&:method_name) \ | |
.map {|_,e| percent_reduction(e) } \ | |
.freq_by {|e| (e * 100 / 10).to_i } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment