mirror of
https://github.com/pion/webrtc.git
synced 2025-12-24 11:51:03 +08:00
Update panic lint script with more functions
This commit is contained in:
16
.github/lint-disallowed-functions-in-library.sh
vendored
Executable file
16
.github/lint-disallowed-functions-in-library.sh
vendored
Executable 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
|
||||
17
.github/lint-panic-and-exit.sh
vendored
17
.github/lint-panic-and-exit.sh
vendored
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user