-
Notifications
You must be signed in to change notification settings - Fork 52
/
checks.mk
76 lines (64 loc) · 1.79 KB
/
checks.mk
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
.PHONY: checks
checks: licensecheck gofmt goimports govet misspell ineffassign staticcheck
.PHONY: licensecheck
licensecheck:
@echo Running license check
@find . -name '*.go' | xargs addlicense -check || (echo "Missing license headers"; exit 1)
.PHONY: gofmt
gofmt:
@echo Running gofmt
@{ \
OUTPUT="$$(gofmt -l -s . || true)"; \
if [ -n "$$OUTPUT" ]; then \
echo "The following gofmt issues were flagged:"; \
echo "$$OUTPUT"; \
echo "The gofmt command 'gofmt -l -s -w' must be run for these files"; \
exit 1; \
fi \
}
.PHONY: goimports
goimports:
@echo Running goimports
@{ \
OUTPUT="$$(goimports -l .)"; \
if [ -n "$$OUTPUT" ]; then \
echo "The following files contain goimports errors"; \
echo "$$OUTPUT"; \
echo "The goimports command 'goimports -l -w' must be run for these files"; \
exit 1; \
fi \
}
.PHONY: govet
govet:
@echo Running go vet
@go vet -all $(shell go list -f '{{.Dir}}' ./...) || (echo "Found some issues identified by 'go vet -all'. Please fix them!"; exit 1;)
.PHONY: misspell
misspell:
@echo Running misspell
@{ \
OUTPUT="$$(misspell . || true)"; \
if [ -n "$$OUTPUT" ]; then \
echo "The following files are have spelling errors:"; \
echo "$$OUTPUT"; \
exit 1; \
fi \
}
.PHONY: staticcheck
staticcheck:
@echo Running staticcheck
@{ \
OUTPUT="$$(staticcheck -tests=false ./... | grep -v .pb.go || true)"; \
if [ -n "$$OUTPUT" ]; then \
echo "The following staticcheck issues were flagged:"; \
echo "$$OUTPUT"; \
exit 1; \
fi \
}
.PHONY: gocyclo
gocyclo:
@echo Running gocyclo
@gocyclo -over 15 $(shell go list -f '{{.Dir}}' ./...) || (echo "Found some code with a Cyclomatic complexity over 15! Better refactor"; exit 1;)
.PHONY: ineffassign
ineffassign:
@echo Running ineffassign
@ineffassign $(shell go list -f '{{.Dir}}' ./...)