Last active
August 29, 2015 14:04
-
-
Save eaigner/82909602899f8588f0fc to your computer and use it in GitHub Desktop.
vet.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vet.bash | |
function check_dir() { | |
egrep -rn -e "$2" "$1" | |
if [[ $? != 1 ]] ; then | |
echo "$3" | |
exit $rc | |
fi | |
} | |
function check() { | |
for dir in include src test | |
do | |
check_dir "$dir" "$1" "$2" | |
done | |
} | |
check "^ " "no leading spaces allowed, use tabs" | |
check "[^g(](m|c|re)alloc\(" "use guarded allocator" | |
check "str[nl]?cpy" "use memcpy" | |
check "sprintf" "sprintf functions are insecure, use the snprintf version instead" | |
check "for\(" "expected space after 'for' keyword" | |
check "if\(" "expected space after 'if' keyword" | |
check "while\(" "expected space after 'while' keyword" | |
check "switch\(" "expected space after 'swich' keyword" | |
check "[\[\(] " "remove space after bracket" | |
check " [\]\)]" "remove space before bracket" | |
check "[[:space:]]$" "trailing whitespace" | |
check "} ?(else|while)" "expected newline before (else|while)" | |
check "(do|for|if|else|while|switch) (.*)?{" "move opening curly brace to next line" | |
check ".{81,}$" "line exceeds 80 characters" | |
check "^\t{4,}(if|else|for|while|case|switch|do)" "excessive indent level" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment