Skip to content

Instantly share code, notes, and snippets.

@ouchadam
Created April 9, 2020 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouchadam/36f094e543d3383c3e3df45a601ae4ac to your computer and use it in GitHub Desktop.
Save ouchadam/36f094e543d3383c3e3df45a601ae4ac to your computer and use it in GitHub Desktop.
kotlin and java code percentages using cloc
#!/bin/bash
for d in ./*/;
do
result=$(cloc $d --match-d='/java/' --json | jq '. | {total: .SUM.code, kotlin: .Kotlin.code, java: .Java.code}' )
if [ -n "$result" ]
then
total=$(jq '.total' <<< $result)
kotlin=$(jq '.kotlin' <<< $result)
java=$(jq '.java' <<< $result)
kotlinP=$(echo "scale=2;($kotlin/$total)*100" | bc)
javaP=$(echo "scale=2;($java/$total)*100" | bc)
echo $d kotlin: "$kotlinP"% java: "$javaP"%
fi;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment