diff --git a/.travis.yml b/.travis.yml index 0544c392..ce02339b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ go: before_install: - go get -v github.com/golang/lint/golint + - go get -v github.com/fzipp/gocyclo # hack for building on forks - repo=`basename $PWD`; src=`dirname $PWD`; dest="`dirname $src`/intel" - if [[ "$src" != "$dest" ]]; then mv "$src" "$dest"; cd ../../intel/$repo; export TRAVIS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/$repo; fi @@ -13,6 +14,7 @@ script: - make lint - make - make vet + - make cyclomatic-check - make test after_success: diff --git a/Makefile b/Makefile index 20add736..d8b7e608 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ GO := go +GOCYCLO := gocyclo pkgs = $(shell $(GO) list ./... | grep -v vendor) cmds = $(shell ls cmd) @@ -16,6 +17,9 @@ format: vet: @$(GO) vet -v -shadow $(pkgs) +cyclomatic-check: + @report=`$(GOCYCLO) -over 15 cmd internal`; if [ -n "$$report" ]; then echo "Complexity is over 15 in"; echo $$report; exit 1; fi + test: ifndef WHAT @$(GO) test -race -coverprofile=coverage.txt -covermode=atomic $(pkgs) @@ -43,4 +47,4 @@ $(images): images: $(images) -.PHONY: all format vet test lint build images $(cmds) $(images) +.PHONY: all format vet cyclomatic-check test lint build images $(cmds) $(images)