/dist/check-code.sh

http://txt2tags.googlecode.com/ · Shell · 43 lines · 26 code · 12 blank · 5 comment · 8 complexity · fee9ecaaf5e10d3fbb07ecb298b3096e MD5 · raw file

  1. #!/bin/bash
  2. # check-code.sh - Checks txt2tags code
  3. # by Aurelio Jargas
  4. t2t=../txt2tags
  5. hecho(){ echo -e "\033[36;1mCode: $*\033[m"; }
  6. cd $(dirname "$0")
  7. hecho 'checking shebang'
  8. [ "$(head -1 $t2t)" != "#!/usr/bin/env python" ] && echo FAIL
  9. hecho "checking if executable"
  10. ls -l $t2t | grep -qs '^-rwxr-xr-x' || echo FAIL
  11. hecho "checking year of Copyright"
  12. grep -qs "Copyright.*$(date +%Y)" $t2t || echo FAIL
  13. hecho "searching for !ASCII chars"
  14. grep -v '^[ -~]*$' $t2t # [TAB-~]
  15. hecho "searching for useless blanks"
  16. egrep '[^ ][ ]+$' $t2t | sed -n l # \S\s$
  17. egrep ' ' $t2t | sed -n l # space+TAB
  18. # grep '^ ' $t2t # leading space
  19. hecho "searching for lines >80 columns"
  20. # sed "s/$(echo -ne '\t')/ /g" $t2t | egrep '.{81}'
  21. echo DISABLED
  22. hecho "checking PEP-8 compliance"
  23. if pep8 --version >/dev/null 2>&1
  24. then
  25. pep8 --ignore E203,E221,E241,E501 -r $t2t
  26. else
  27. echo "pep8 command not installed"
  28. echo "See http://pypi.python.org/pypi/pep8"
  29. fi
  30. hecho 'checking version'
  31. $t2t -V | sed 's/<.*//'