Created
April 9, 2020 11:43
-
-
Save ouchadam/36f094e543d3383c3e3df45a601ae4ac to your computer and use it in GitHub Desktop.
kotlin and java code percentages using cloc
This file contains 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
#!/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