Update panic lint script with more functions

This commit is contained in:
Sean DuBois
2018-08-11 00:55:12 -07:00
parent 1a37e3d840
commit 3e67d71290
3 changed files with 17 additions and 18 deletions

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
# Disallow usages of functions that cause the program to exit in the library code
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
EXCLUDE_DIRECTORIES="--exclude-dir=examples --exclude-dir=.git --exclude-dir=.github "
DISALLOWED_FUNCTIONS=('os.Exit(', 'panic(', 'Fatal(', 'Fatalf(', 'Fatalln(')
for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}"
do
if grep -R $EXCLUDE_DIRECTORIES -e "$disallowedFunction" "$SCRIPT_PATH/.." | grep -v nolint; then
echo "$disallowedFunction may only be used in example code"
exit 1
fi
done

View File

@@ -1,17 +0,0 @@
#!/usr/bin/env bash
set -e
# Disallow usages of panic and os.Exit
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
EXCLUDE_DIRECTORIES="--exclude-dir=examples --exclude-dir=.git --exclude-dir=.github "
if grep -R $EXCLUDE_DIRECTORIES -e 'os.Exit(' "$SCRIPT_PATH/.." | grep -v nolint; then
echo "os.Exit( may only be used in example code"
exit 1
fi
if grep -R $EXCLUDE_DIRECTORIES -e 'panic(' "$SCRIPT_PATH/.." | grep -v nolint; then
echo "panic() may only be used in example code"
exit 1
fi

View File

@@ -20,4 +20,4 @@ script:
- golangci-lint run
- goveralls -v -race -covermode=atomic -service=travis-ci
- bash .github/assert-contributors.sh
- bash .github/lint-panic-and-exit.sh
- bash .github/lint-disallowed-functions-in-library.sh