diff --git a/CHANGELOG.md b/CHANGELOG.md index e63d01c4b..48ddab70f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ FEATURES * ineffassign * errcheck * unparam + * gocyclo * [tools] Add `make format` command to automate fixing misspell and gofmt errors. * [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates * [tests] Add WaitForNextNBlocksTM helper method diff --git a/tools/Makefile b/tools/Makefile index 195e67aa5..d58f52d1b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,6 +12,7 @@ INEFFASSIGN = github.com/gordonklaus/ineffassign MISSPELL = github.com/client9/misspell/cmd/misspell ERRCHECK = github.com/kisielk/errcheck UNPARAM = mvdan.cc/unparam +GOCYCLO = github.com/alecthomas/gocyclo DEP_CHECK := $(shell command -v dep 2> /dev/null) GOLINT_CHECK := $(shell command -v golint 2> /dev/null) @@ -21,6 +22,7 @@ INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null) MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null) ERRCHECK_CHECK := $(shell command -v errcheck 2> /dev/null) UNPARAM_CHECK := $(shell command -v unparam 2> /dev/null) +GOCYCLO_CHECK := $(shell command -v gocyclo 2> /dev/null) check_tools: ifndef DEP_CHECK @@ -63,6 +65,11 @@ ifndef UNPARAM_CHECK else @echo "Found unparam in path." endif +ifndef GOCYCLO_CHECK + @echo "No gocyclo in path. Install with 'make get_tools'." +else + @echo "Found gocyclo in path." +endif get_tools: ifdef DEP_CHECK @@ -113,6 +120,12 @@ else @echo "Installing unparam" go get -v $(UNPARAM) endif +ifdef GOYCLO_CHECK + @echo "goyclo is already installed. Run 'make update_tools' to update." +else + @echo "Installing goyclo" + go get -v $(GOCYCLO) +endif update_tools: @echo "Updating dep" @@ -131,6 +144,8 @@ update_tools: go get -u -v $(ERRCHECK) @echo "Updating unparam" go get -u -v $(UNPARAM) + @echo "Updating goyclo" + go get -u -v $(GOCYCLO) # To avoid unintended conflicts with file names, always add to .PHONY # unless there is a reason not to. diff --git a/tools/gometalinter.json b/tools/gometalinter.json index a6c74eebb..32ae434c4 100644 --- a/tools/gometalinter.json +++ b/tools/gometalinter.json @@ -2,7 +2,8 @@ "Linters": { "vet": "go tool vet -composites=false :PATH:LINE:MESSAGE" }, - "Enable": ["golint", "vet", "ineffassign", "unparam", "unconvert", "misspell"], + "Enable": ["golint", "vet", "ineffassign", "unparam", "unconvert", "misspell", "gocyclo"], "Deadline": "500s", - "Vendor": true + "Vendor": true, + "Cyclo": 10 } \ No newline at end of file