Skip to content

Instantly share code, notes, and snippets.

@juliengdt
Created July 20, 2015 16:06
Show Gist options
  • Save juliengdt/eb2b237331ca461ef98b to your computer and use it in GitHub Desktop.
Save juliengdt/eb2b237331ca461ef98b to your computer and use it in GitHub Desktop.
Jacky Script for Xcode Build Phases
#CODE COMPLEXITY
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 wc -l | awk '$1 > 400 && $2 != "total" {for(i=2;i<NF;i++){printf "%s%s", $i, " "} print $NF ":1: warning: File more than 400 lines (" $1 "), consider refactoring." }'
#TODO & FIXME CHECKER
KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
#TOTAL LINES - USELESS BUT FUN
echo "Total lines of code:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 cat | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment