Skip to content

Instantly share code, notes, and snippets.

@claytron
Created January 8, 2016 16:48
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 claytron/f19103de047eb0f1f56c to your computer and use it in GitHub Desktop.
Save claytron/f19103de047eb0f1f56c to your computer and use it in GitHub Desktop.
Get rubocop metrics details
#!/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