Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2016-03-21 17:49:18 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-03-22 21:40:27 +0300
commite8cf8b40dfd93f84fbbd63b57295e2e39e828d19 (patch)
tree8978e6c053542eafd194bd983b64b9554831b224 /Makefile
parent048e07422d6706ec9277d47cdec4900b79cbf0d5 (diff)
hugo: Add check tasks to Makefile
Add some helpful tasks to the Makefile to make it easier to test code quality prior to committing. Use `make check` to run the standard checks. As of now, the cyclo and lint tasks are not part of the standard checks since Hugo doesn't pass those checks.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 33 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 46e75fce7..f4dfe0dad 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,8 @@ COMMIT_HASH=`git rev-parse --short HEAD 2>/dev/null`
BUILD_DATE=`date +%FT%T%z`
LDFLAGS=-ldflags "-X github.com/spf13/hugo/hugolib.CommitHash=${COMMIT_HASH} -X github.com/spf13/hugo/hugolib.BuildDate=${BUILD_DATE}"
+DIRS=$(shell go list -f {{.Dir}} ./...)
+
all: gitinfo
install: install-gitinfo
@@ -31,3 +33,34 @@ docker:
docker run --name hugo-build hugo ls /go/bin
docker cp hugo-build:/go/bin/hugo .
docker rm hugo-build
+
+
+check: fmt vet test
+
+cyclo:
+ @for d in $(DIRS) ; do \
+ if [ "`gocyclo -over 20 $$d | tee /dev/stderr`" ]; then \
+ echo "^ cyclomatic complexity exceeds 20, refactor the code!" && echo && exit 1; \
+ fi \
+ done
+
+fmt:
+ @for d in $(DIRS) ; do \
+ if [ "`gofmt -l $$d/*.go | tee /dev/stderr`" ]; then \
+ echo "^ improperly formatted go files" && echo && exit 1; \
+ fi \
+ done
+
+lint:
+ @if [ "`golint ./... | tee /dev/stderr`" ]; then \
+ echo "^ golint errors!" && echo && exit 1; \
+ fi
+
+test:
+ go test ./...
+
+vet:
+ @if [ "`go vet ./... | tee /dev/stderr`" ]; then \
+ echo "^ go vet errors!" && echo && exit 1; \
+ fi
+