Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created July 17, 2019 19:27
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 mbklein/018a71745cb39b94f8ebc60d8c3862fe to your computer and use it in GitHub Desktop.
Save mbklein/018a71745cb39b94f8ebc60d8c3862fe to your computer and use it in GitHub Desktop.
Report credo exit status based on severity, not category
#!/bin/bash
######################################################
#
# This script will take the normal credo exit code
# (see https://github.com/rrrene/credo#exit-status)
# and add 64 if any high-severity (non-strict)
# issues are found and 128 if any low-severity
# (strict) issues are found
#
tmp=$(mktemp)
mix credo --strict --format oneline | tee "$tmp"
status=${PIPESTATUS[0]}
if grep -qE '[↑↗→]' "$tmp"; then
status=$(($status + 64))
elif grep -qE '[↘↓]' "$tmp"; then
status=$(($status + 128))
fi
rm "$tmp"
exit $status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment