This repository has been archived by the owner on Nov 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
checks.sh
executable file
·78 lines (68 loc) · 1.81 KB
/
checks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
set -e
dirs=$(go list ./... | sed -e 's!github.com/contiv/objdb!.!g' | grep -v ./vendor)
files=$(find . -type f -name '*.go' | grep -v ./vendor)
echo "Running gofmt..."
set +e
out=$(gofmt -s -l ${files})
set -e
# gofmt can include empty lines in its output
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "gofmt errors in:"
echo 1>&2 "${out}"
exit 1
fi
echo "Running ineffassign..."
[ -n "$(which ineffassign)" ] || go get github.com/gordonklaus/ineffassign
for i in ${dirs}; do
ineffassign $i
done
echo "Running golint..."
[ -n "$(which golint)" ] || go get github.com/golang/lint/golint
set +e
out=$(golint ./... | grep -vE '^vendor')
set -e
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "golint errors in:"
echo 1>&2 "${out}"
exit 1
fi
echo "Running govet..."
set +e
out=$(go tool vet -composites=false ${dirs} 2>&1 | grep -v vendor)
set -e
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "go vet errors in:"
echo 1>&2 "${out}"
exit 1
fi
echo "Running gocyclo..."
[ -n "$(which gocyclo)" ] || go get github.com/fzipp/gocyclo
set +e
out=$(gocyclo -over 20 . | grep -v vendor)
set -e
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "gocycle errors in:"
echo 1>&2 "${out}"
exit 1
fi
echo "Running misspell..."
[ -n "$(which misspell)" ] || go get github.com/client9/misspell/...
set +e
out=$(misspell -locale US -error -i exportfs ${files})
set -e
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "misspell errors in:"
echo 1>&2 "${out}"
exit 1
fi
echo "Running deadcode..."
[ -n "$(which deadcode)" ] || go get github.com/remyoudompheng/go-misc/deadcode/...
set +e
out=$(deadcode ${dirs} 2>&1)
set -e
if [ "$(echo $out | sed '/^$/d' | wc -l)" -gt 0 ]; then
echo 1>&2 "deadcode errors in:"
echo 1>&2 "${out}"
exit 1
fi