From 71053c1e1655ee9a9ca7db2cb68c0cbe99ffcb30 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Wed, 27 Feb 2019 23:05:45 -0800 Subject: [PATCH] Add lint for filenames We have established a pattern of Alpha and underscores for filenames. This adds a hook to keep this pattern going. Also fixes a misnamed file I found in the process. Resolves #456 --- .github/lint-filename.sh | 14 ++++++++++++++ .travis.yml | 1 + rtptranceiver.go => rtptransceiver.go | 0 3 files changed, 15 insertions(+) create mode 100755 .github/lint-filename.sh rename rtptranceiver.go => rtptransceiver.go (100%) diff --git a/.github/lint-filename.sh b/.github/lint-filename.sh new file mode 100755 index 00000000..11f83f23 --- /dev/null +++ b/.github/lint-filename.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +GO_REGEX="^[a-zA-Z_]+\.go$" + +find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do + filename=$(basename -- "$fullpath") + + if ! [[ $filename =~ $GO_REGEX ]]; then + echo "$filename is not a valid filename for Go code, only alpha and underscores are supported" + exit 1 + fi +done diff --git a/.travis.yml b/.travis.yml index 63064c03..0957074b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,3 +26,4 @@ script: - bash .github/assert-contributors.sh - bash .github/lint-disallowed-functions-in-library.sh - bash .github/lint-commit-message.sh + - bash .github/lint-filename.sh diff --git a/rtptranceiver.go b/rtptransceiver.go similarity index 100% rename from rtptranceiver.go rename to rtptransceiver.go