From 5461481168cfb741b83a353633bcdec37a8c619a Mon Sep 17 00:00:00 2001 From: Benjamin Bollen <ben@monax.io> Date: Fri, 25 Nov 2016 18:05:14 +0100 Subject: [PATCH] make: introduce first make commands for formatting and lint --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ client/client.go | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..71eb33d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +# TARGET = eris-db +# IMAGE = quay.io/eris/db + +SHELL := /bin/bash +GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path "./vendor/*") +PACKAGES_NOVENDOR := $(shell go list github.com/eris-ltd/eris-db/... | grep -v /vendor/) +VERSION_MIN := $(shell cat ./version/version.go | tail -n 1 | cut -d \ -f 4 | tr -d '"') +VERSION_MAJ := $(shell echo ${VERSION_MIN} | cut -d . -f 1-2) + +.PHONY: greet +greet: + @echo "Hi! I'm the marmot that will help you with eris-db v${VERSION_MIN}" + +### Formatting, linting and vetting + +# check the code for style standards; currently enforces go formatting. +# display output first, then check for success +.PHONY: check +check: + @echo "Checking code for formatting style compliance." + @gofmt -l -d ${GOFILES_NOVENDOR} + @gofmt -l ${GOFILES_NOVENDOR} | read && echo && echo "Your marmot has found a problem with the formatting style of the code." 1>&2 && exit 1 || true + +# fmt runs gofmt -w on the code, modifying any files that do not match +# the style guide. +.PHONY: fmt +fmt: + @echo "Correcting any formatting style corrections." + @gofmt -l -w ${GOFILES_NOVENDOR} + +# lint installs golint and prints recommendations for coding style. +lint: + @echo "Running lint checks." + go get -u github.com/golang/lint/golint + @for file in $(GOFILES_NOVENDOR); do \ + echo; \ + golint --set_exit_status $${file}; \ + done + +# vet runs extended compilation checks to find recommendations for +# suspicious code constructs. +.PHONY: vet +vet: + @echo "Running go vet." + @go vet ${PACKAGES_NOVENDOR} \ No newline at end of file diff --git a/client/client.go b/client/client.go index 24eeb033..34275c8b 100644 --- a/client/client.go +++ b/client/client.go @@ -80,7 +80,7 @@ func NewErisNodeClient(rpcString string) *ErisNodeClient { // it needs to be initialised before go-rpc, hence it's placement here. func init() { h := tendermint_log.LvlFilterHandler(tendermint_log.LvlWarn, tendermint_log.StdoutHandler) - tendermint_log.Root().SetHandler(h) + tendermint_log.Root().SetHandler(h) } //------------------------------------------------------------------------------------ -- GitLab