Skip to content

Instantly share code, notes, and snippets.

@alex-min
Created January 14, 2016 15:08
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 alex-min/82d124e204a512ac3802 to your computer and use it in GitHub Desktop.
Save alex-min/82d124e204a512ac3802 to your computer and use it in GitHub Desktop.
catches some style problems cane and tailor might miss
#!/bin/bash
# done quickly, don't look here
# this catches some style problems cane and tailor might miss
echo "---- Doing checks -----"
echo "[+] additional space"
find "$PWD" | grep -F .rb | grep -v schema.rb | xargs pcregrep -n -M "\n\nend"
find "$PWD" | grep -E '\.e?rb$' | xargs grep -nE ' $'
echo "[+] missing space"
find "$PWD" | grep -E '\.e?rb$' | grep -v schema.rb | xargs grep -nE "[A-Za-Z]:['\"]"
echo "[+] additional space"
find "$PWD" | grep -F '.erb' | xargs grep -nE '<[a-Za-Z]+ '
find "$PWD" | grep -F '.erb' | xargs grep -nE '= +'
find "$PWD" | grep -F '.erb' | xargs grep -nE '<% +'
find "$PWD" | grep -F '.erb' | xargs grep -nE '<%.* +%>'
find "$PWD" | grep -F '.rb' | xargs grep -nE '( + = )|( = +)'
echo "[+] additional space after tag, should maybe be nbsp;"
find "$PWD" | grep -F '.erb' | xargs grep -nE '[a-z]> [a-zA-Z]'
find "$PWD" | grep -F '.erb' | xargs grep -nE '[a-zA-Z] +</[a-z]'
echo "[+] missing space"
find "$PWD" | grep -F '.erb' | xargs grep -nE '<%[a-zA-Z]'
find "$PWD" | grep -F '.erb' | xargs grep -nE '<%=[a-zA-Z]'
find "$PWD" | grep -F '.erb' | xargs grep -nE '[a-zA-Z]%>'
echo "[+] useless semicolon"
find "$PWD" | grep -F '.rb' | xargs grep -nE ';$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment