Created
June 2, 2021 12:15
-
-
Save slapers/69138710e436e51c976ef056bdfd67e1 to your computer and use it in GitHub Desktop.
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
| # | |
| # This prints an overview of all lines of code inside a Elixir project | |
| # + gives a indication on how much code exists in tests vs production code | |
| SLOC_TOTAL=0 | |
| TLOC_TOTAL=0 | |
| echo "Umbrella lines of code overview" | |
| for APP in `ls apps/` | |
| do | |
| SLOC=$(find apps/${APP}/lib -type f -name '*.ex*' -print0 | xargs -0 wc -l | tail -n 1 | awk '{print $1}') | |
| TLOC=$(find apps/${APP}/test -type f -name '*.ex*' -print0 | xargs -0 wc -l | tail -n 1 | awk '{print $1}') | |
| NUM_TESTS=$(find apps/${APP} -type f -name '*.exs' -print0 | xargs -0 grep "test \"" | wc -l | tail -n 1 | awk "{print $1}") | |
| SLOCP=$(echo "scale = 1; 100 / (($SLOC + $TLOC) / $SLOC)" | bc) | |
| TLOCP=$(echo "scale = 1; 100 / (($SLOC + $TLOC) / $TLOC)" | bc) | |
| printf "%16s: sources=%-6u (%5.1f%%) tests=%-6u (%4.1f%%) test-cases=%-4u\n" $APP $SLOC $SLOCP $TLOC $TLOCP $NUM_TESTS | |
| SLOC_TOTAL=$(($SLOC_TOTAL + $SLOC)) | |
| TLOC_TOTAL=$(($TLOC_TOTAL + $TLOC)) | |
| done | |
| SLOC_TOTALP=$(echo "scale = 1; 100 / (($SLOC_TOTAL + $TLOC_TOTAL) / $SLOC_TOTAL)" | bc) | |
| TLOC_TOTALP=$(echo "scale = 1; 100 / (($SLOC_TOTAL + $TLOC_TOTAL) / $TLOC_TOTAL)" | bc) | |
| printf "%16s: sources=%-6u (%5.1f%%) tests=%-6u (%4.1f%%)\n" "Total lines" $SLOC_TOTAL $SLOC_TOTALP $TLOC_TOTAL $TLOC_TOTALP | |
| printf "%16s: src+tst=%-6u \n" "Combined" $(($SLOC_TOTAL + $TLOC_TOTAL)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment