forked from box-builder/box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecks.sh
87 lines (76 loc) · 1.9 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
79
80
81
82
83
84
85
86
87
#!/bin/sh
set -e
package="github.com/erikh/box"
dirs=$(go list ./... | sed -e "s!${package}!.!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 15 . | 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 ${dirs} | grep -vE '^vendor')
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