Skip to content

Commit

Permalink
Merge pull request #64 from weaveworks/remove-test-package-linting
Browse files Browse the repository at this point in the history
Remove test package linting
  • Loading branch information
Alfonso Acosta committed Jan 17, 2017
2 parents 2b3a1bb + f088e83 commit eb26c68
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions lint
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
set -e

IGNORE_LINT_COMMENT=
IGNORE_TEST_PACKAGES=
IGNORE_SPELLINGS=
while true; do
case "$1" in
Expand All @@ -27,9 +26,8 @@ while true; do
shift 1
;;
-notestpackage)
IGNORE_TEST_PACKAGES=1
# NOOP, still accepted for backwards compatibility
shift 1
;;
-ignorespelling)
IGNORE_SPELLINGS="$2,$IGNORE_SPELLINGS"
shift 2
Expand Down Expand Up @@ -65,30 +63,6 @@ spell_check() {
return $lint_result
}

test_mismatch() {
local filename="$1"
local package=$(grep '^package ' "$filename" | awk '{print $2}')
local lint_result=0

if [[ $package == "main" ]]; then
return # in package main, all bets are off
fi

if [[ $filename == *"_internal_test.go" ]]; then
if [[ $package == *"_test" ]]; then
lint_result=1
echo "${filename}: should not be part of a _test package"
fi
else
if [[ ! $package == *"_test" ]]; then
lint_result=1
echo "${filename}: should be part of a _test package"
fi
fi

return $lint_result
}

lint_go() {
local filename="$1"
local lint_result=0
Expand Down Expand Up @@ -183,12 +157,6 @@ lint() {
tf) lint_tf "${filename}" || lint_result=1 ;;
esac

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

return $lint_result
Expand Down

0 comments on commit eb26c68

Please sign in to comment.