Skip to content

Instantly share code, notes, and snippets.

@bpollman
Created January 31, 2019 00:50
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 bpollman/d0f5f4ef3c375c10860ebcd2bff01a05 to your computer and use it in GitHub Desktop.
Save bpollman/d0f5f4ef3c375c10860ebcd2bff01a05 to your computer and use it in GitHub Desktop.
Generate Some useful Stats from swiftlint output with the help of sqlite3
#!/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 ====================================================================
.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 ====================================================================
.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