mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-27 17:21:34 +00:00
Add support for weave in lint script.
This commit is contained in:
32
lint
32
lint
@@ -11,7 +11,25 @@
|
||||
# To use this script automatically, run:
|
||||
# ln -s ../../bin/lint .git/hooks/pre-commit
|
||||
|
||||
set -eu
|
||||
set -e
|
||||
|
||||
IGNORE_LINT_COMMENT=
|
||||
IGNORE_TEST_PACKAGES=
|
||||
while true; do
|
||||
case "$1" in
|
||||
-nocomment)
|
||||
IGNORE_LINT_COMMENT=1
|
||||
shift 1
|
||||
;;
|
||||
-notestpackage)
|
||||
IGNORE_TEST_PACKAGES=1
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
function spell_check {
|
||||
filename="$1"
|
||||
@@ -64,7 +82,11 @@ function lint_go {
|
||||
# don't have it installed.
|
||||
if type golint >/dev/null 2>&1; then
|
||||
# golint doesn't set an exit code it seems
|
||||
lintoutput=$(golint "${filename}")
|
||||
if [ "$IGNORE_LINT_COMMENT" = "1" ]; then
|
||||
lintoutput=$(golint "${filename}" | grep -vE 'comment|dot imports')
|
||||
else
|
||||
lintoutput=$(golint "${filename}")
|
||||
fi
|
||||
if [ "$lintoutput" != "" ]; then
|
||||
lint_result=1
|
||||
echo "$lintoutput"
|
||||
@@ -105,8 +127,10 @@ function lint {
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $filename == *"_test.go" ]]; then
|
||||
test_mismatch "${filename}" || lint_result=1
|
||||
if [ -z "$IGNORE_TEST_PACKAGES" ]; then
|
||||
if [[ "$filename" == *"_test.go" ]]; then
|
||||
test_mismatch "${filename}" || lint_result=1
|
||||
fi
|
||||
fi
|
||||
|
||||
spell_check "${filename}" || lint_result=1
|
||||
|
||||
Reference in New Issue
Block a user