-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more check tools, and fix reported things
- Loading branch information
Showing
4 changed files
with
27 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,9 @@ | ||
SRC_DIR=./hipchat | ||
VETARGS=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr | ||
|
||
all: test testrace vet | ||
include checks.mk | ||
|
||
default: test | ||
default: test checks | ||
|
||
# test runs the unit tests and vets the code | ||
test: | ||
go test -v $(SRC_DIR) $(TESTARGS) -timeout=30s -parallel=4 | ||
|
||
# testrace runs the race checker | ||
testrace: | ||
go test -race $(SRC_DIR) $(TESTARGS) | ||
|
||
# vet runs the Go source code static analysis tool `vet` to find | ||
# any common errors | ||
vet: | ||
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \ | ||
go get golang.org/x/tools/cmd/vet; \ | ||
fi | ||
@echo "go tool vet $(VETARGS) $(SRC_DIR) " | ||
@go tool vet $(VETARGS) $(SRC_DIR) ; if [ $$? -eq 1 ]; then \ | ||
echo ""; \ | ||
echo "Vet found suspicious constructs. Please check the reported constructs"; \ | ||
echo "and fix them if necessary before submitting the code for review."; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: all default test vet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
checks: | ||
go test -race $(SRC_DIR) | ||
@$(call checkbin,go tool vet,golang.org/x/tools/cms/vet) | ||
go tool vet $(SRC_DIR) | ||
@$(call checkbin,golint,github.com/golang/lint/golint) | ||
golint -set_exit_status $(SRC_DIR) | ||
@$(call checkbin,errcheck,github.com/kisielk/errcheck) | ||
errcheck -ignore 'Close' -ignoretests $(SRC_DIR) | ||
@$(call checkbin,structcheck,github.com/opennota/check/cmd/structcheck) | ||
structcheck $(SRC_DIR) | ||
@$(call checkbin,varcheck,github.com/opennota/check/cmd/varcheck) | ||
varcheck $(SRC_DIR) | ||
|
||
checkbin = $1 2> /dev/null; if [ $$? -eq 127 ]; then\ | ||
echo "Retrieving missing tool $1...";\ | ||
go get $2; \ | ||
fi; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters