Merge PR #1429: tools: Add ineffassign linter

* tools: Add ineffassign linter

This errors on assignments that don't actually do anything. i.e.

x, err := myFunc(1)
y, err = myFunc(2)

This will call out that the first function's call error was never
used.

* Fix makefile, add misspell to makefile
This commit is contained in:
Dev Ojha
2018-06-28 19:12:02 +02:00
committed by Christopher Goes
parent 2755c66545
commit 3e14868bd6
13 changed files with 81 additions and 28 deletions
+30
View File
@@ -8,11 +8,15 @@ DEP = github.com/golang/dep/cmd/dep
GOLINT = github.com/tendermint/lint/golint
GOMETALINTER = gopkg.in/alecthomas/gometalinter.v2
UNCONVERT = github.com/mdempsky/unconvert
INEFFASSIGN = github.com/gordonklaus/ineffassign
MISSPELL = github.com/client9/misspell/cmd/misspell
DEP_CHECK := $(shell command -v dep 2> /dev/null)
GOLINT_CHECK := $(shell command -v golint 2> /dev/null)
GOMETALINTER_CHECK := $(shell command -v gometalinter.v2 2> /dev/null)
UNCONVERT_CHECK := $(shell command -v unconvert 2> /dev/null)
INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null)
MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null)
check_tools:
ifndef DEP_CHECK
@@ -35,6 +39,16 @@ ifndef UNCONVERT_CHECK
else
@echo "Found unconvert in path."
endif
ifndef INEFFASSIGN_CHECK
@echo "No ineffassign in path. Install with 'make get_tools'."
else
@echo "Found ineffassign in path."
endif
ifndef MISSPELL_CHECK
@echo "No misspell in path. Install with 'make get_tools'."
else
@echo "Found misspell in path."
endif
get_tools:
ifdef DEP_CHECK
@@ -61,6 +75,18 @@ else
@echo "Installing unconvert"
go get -v $(UNCONVERT)
endif
ifdef INEFFASSIGN_CHECK
@echo "Ineffassign is already installed. Run 'make update_tools' to update."
else
@echo "Installing ineffassign"
go get -v $(INEFFASSIGN)
endif
ifdef MISSPELL_CHECK
@echo "misspell is already installed. Run 'make update_tools' to update."
else
@echo "Installing misspell"
go get -v $(MISSPELL)
endif
update_tools:
@echo "Updating dep"
@@ -71,6 +97,10 @@ update_tools:
go get -u -v $(GOMETALINTER)
@echo "Updating unconvert"
go get -u -v $(UNCONVERT)
@echo "Updating ineffassign"
go get -u -v $(INEFFASSIGN)
@echo "Updating misspell"
go get -u -v $(MISSPELL)
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.