glowfic-constellation / glowfic

The Glowfic Constellation
https://www.glowfic.com
MIT License
16 stars 10 forks source link

Add Git pre-commit hooks #946

Open Marri opened 5 years ago

Marri commented 5 years ago

CodeClimate is very nice but it runs on builds; it'd be nice if we had earlier feedback about code quality.

Marri commented 5 years ago

Note: sharing git hooks or another

We just create an (executable!) .git/hooks/pre-commit file, but then it needs to be shared somehow.

Example I made quickly (and --cached might be wrong):

#!/bin/sh

if test $(git diff --cached HEAD | grep debugger | wc -l) != 0
then
  cat <<\EOF

Error: You are trying to commit a debugger line!

This can cause our Travis CI tests to hang or fail.

Please finish your testing and remove all calls to the debugger.

EOF
  exit 1
fi

Other things to include: SCSS linting, RuboCop, Flay, Reek, Flog, Rails Best Practices, Traceroute, Brakeman?