Skip to content

Commit

Permalink
Remove test package linting
Browse files Browse the repository at this point in the history
Having _test packages leads to unnecessary symbol exports
  • Loading branch information
Alfonso Acosta committed Jan 17, 2017
1 parent 2b3a1bb commit 2c6e83e
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions lint
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@
set -e

IGNORE_LINT_COMMENT=
IGNORE_TEST_PACKAGES=
IGNORE_SPELLINGS=
while true; do
case "$1" in
-nocomment)
IGNORE_LINT_COMMENT=1
shift 1
;;
-notestpackage)
IGNORE_TEST_PACKAGES=1
shift 1
;;
-ignorespelling)
IGNORE_SPELLINGS="$2,$IGNORE_SPELLINGS"
shift 2
Expand Down Expand Up @@ -65,30 +60,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 +154,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 2c6e83e

Please sign in to comment.