Created
January 31, 2019 00:50
-
-
Save bpollman/d0f5f4ef3c375c10860ebcd2bff01a05 to your computer and use it in GitHub Desktop.
Generate Some useful Stats from swiftlint output with the help of sqlite3
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
#!/bin/bash -- | |
csvfile=$(mktemp) | |
# get pwd to trim it from output | |
pwd=$(pwd) | |
pwdlen=${#pwd} | |
#get swifty | |
swiftlint lint --reporter csv > $csvfile | |
echo -e "\nGenerating Swiftlint Stats\n" | |
# use sqlite to parse the csv and dump some stats | |
sqlite3 -batch $1 <<EOF | |
.mode csv | |
.headers on | |
.mode column | |
.import ${csvfile} lint | |
.print ==================================================================== | |
.print Most Offensive Files\n | |
.print ==================================================================== | |
.width 110 10 | |
SELECT SUBSTR(file,'${pwdlen}'+2) as File, count(type) AS Count FROM lint GROUP BY File, severity ORDER BY Count DESC; | |
.print ==================================================================== | |
.print Most Offensive Violations | |
.print ==================================================================== | |
.width 40 10 10 | |
SELECT type AS Violation, severity AS Severity, count(type) AS Count FROM lint GROUP BY type ORDER BY severity, Count DESC; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment