Created
January 8, 2016 16:48
-
-
Save claytron/f19103de047eb0f1f56c to your computer and use it in GitHub Desktop.
Get rubocop metrics details
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
#!/usr/bin/env bash | |
# Example output: | |
# | |
# Metrics/PerceivedComplexity | |
# Min: 8 Max: 96 Average: 14.628342 | |
cops=( | |
Metrics/AbcSize | |
Metrics/ClassLength | |
Metrics/CyclomaticComplexity | |
Metrics/LineLength | |
Metrics/MethodLength | |
Metrics/PerceivedComplexity | |
) | |
for cop in ${cops[@]}; do | |
print "$cop" | |
rubocop -f s --only "$cop" S '/^== /d' -e 's/.*\[([^\/]+).*/\1/' -e \$d -e '/^$/d' | awk 'NR == 1 { max=$1; min=$1; sum=0 } { if ($1>max) max=$1; if ($1<min) min=$1; sum+=$1;} END {printf "Min: %d\tMax: %d\tAverage: %f\n", min, max, sum/NR}' || echo 'fail' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment