diff --git a/build.Dockerfile b/build.Dockerfile index 758d12f1e..439409c53 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -3,7 +3,8 @@ FROM golang:1.7 RUN go get github.com/Masterminds/glide \ && go get github.com/jteeuwen/go-bindata/... \ && go get github.com/golang/lint/golint \ -&& go get github.com/kisielk/errcheck +&& go get github.com/kisielk/errcheck \ +&& go get github.com/client9/misspell/cmd/misspell # Which docker version to test on ARG DOCKER_VERSION=1.10.1 diff --git a/script/validate-misspell b/script/validate-misspell new file mode 100755 index 000000000..bf64fcc70 --- /dev/null +++ b/script/validate-misspell @@ -0,0 +1,31 @@ +#!/bin/bash + +source "$(dirname "$BASH_SOURCE")/.validate" + +IFS=$'\n' +files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/\|autogen' || true) ) +unset IFS + +errors=() +for f in "${files[@]}"; do + # we use source text here so we also check spelling of variable names + failedSpell=$(misspell -source=text "$f") + if [ "$failedSpell" ]; then + errors+=( "$failedSpell" ) + fi +done + +if [ ${#errors[@]} -eq 0 ]; then + echo 'Congratulations! All Go source files have been checked for common mispellings.' +else + { + echo "Errors from misspell:" + for err in "${errors[@]}"; do + echo "$err" + done + echo + echo 'Please fix the above errors. You can test via "misspell" and commit the result.' + echo + } >&2 + false +fi