-
Measure interest rates. Ruby code that changed most frequently in the last year.
git log --format=format: --name-only --after="2017-05-18" -- "*.rb" | egrep -v '^$' | sort | uniq -c | sort -r | head -10
-
Measure size of each file. Lines of code is a simple proxy for complexity. Just Ruby files
cloc . --by-file --csv --include-lang=Ruby --quiet
-
Combine the two into a single output of filename, change_frequency, size.
require 'csv'
require 'pathname'
require 'json'
ROOT_PATH = Pathname.new("./")
def strip_path(path)
Pathname.new(path).relative_path_from(ROOT_PATH).to_s
end
change_frequencies = File.readlines("all_frequencies.txt").map{|line| line.strip.split(" ").reverse}.to_h; nil
sizes = CSV.readlines("all_lines.csv", headers: true, skip_blanks: true).map{|row| [strip_path(row["filename"]), row["code"]]}.to_h; nil
hotspots = change_frequencies.map {|name, changes| [name, changes.to_i, sizes[name].to_i]}; nil
hotspots.sort_by{|data| [data[1], data[2]]}.reverse.take(100).each{|l| p l}; nil