Skip to content

Instantly share code, notes, and snippets.

@jailbirt
Forked from bspaulding/metrics.sh
Created March 6, 2017 03:05
Show Gist options
  • Save jailbirt/c615caed2e8714b2602b6f4dc93cb61c to your computer and use it in GitHub Desktop.
Save jailbirt/c615caed2e8714b2602b6f4dc93cb61c to your computer and use it in GitHub Desktop.
codebase metrics
# use noglob on zsh
# change file extensions where appropriate
# collect source file paths for analysis
find . -name "*.js" | grep -v "bower_components" | grep -v "node_modules" > source_files.txt
# number of files in project
wc -l source_files.txt
# number of lines by file
cat source_files.txt | xargs wc -l | sort -r | less
# number of commits by file
# since beginning of history
cat source_files.txt | parallel --progress "git log --follow --oneline {} | wc -l | xargs -I {count} echo {count} {} >> commits-by-file.txt"
cat commits-by-file.txt | sort -r -n
# last month
cat source_files.txt | parallel --progress "git log --follow --oneline --after={1.month.ago} {} | wc -l | xargs -I {count} echo {count} {} >> commits-by-file-last-month.txt"
cat commits-by-file-last-month.txt | sort -r -n
# last quarter
cat source_files.txt | parallel --progress "git log --follow --oneline --after={3.months.ago} {} | wc -l | xargs -I {count} echo {count} {} >> commits-by-file-last-quarter.txt"
cat commits-by-file-last-quarter.txt | sort -r -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment