integrate linters into travis

This commit is contained in:
b00ris 2017-10-23 13:21:30 +03:00
parent 1c8d32c451
commit 22fb4dfc30
No known key found for this signature in database
GPG Key ID: 2F73E159EB73232C
4 changed files with 80 additions and 58 deletions

View File

@ -9,10 +9,14 @@ dist: trusty
install:
- go get golang.org/x/tools/cmd/cover
- make lint-deps
script:
- make ci
jobs:
include:
- stage: lint
script: make lint
- stage: ci
script: make ci
cache:
directories:
- .ethereumtest

View File

@ -1,6 +1,8 @@
.PHONY: statusgo all test xgo clean help
.PHONY: statusgo-android statusgo-ios
include ./static/tools/mk/lint.mk
GOBIN = build/bin
GO ?= latest
@ -79,56 +81,6 @@ generate: ##@other Regenerate assets and other auto-generated stuff
build/env.sh go generate ./static
rm ./static/scripts/web3.js
lint-deps:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
lint-cur:
gometalinter --disable-all --enable=deadcode $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
lint: ##@tests Run meta linter on code
@echo "Linter: go vet\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=vet $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: go vet --shadow\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=vetshadow $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: gofmt\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gofmt $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: goimports\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=goimports $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: golint\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=golint $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: deadcode\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=deadcode $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: misspell\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=misspell $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: unparam\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --deadline 45s --enable=unparam $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: unused\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --deadline 45s --enable=unused $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: gocyclo\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gocyclo --cyclo-over=20 $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: errcheck\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=errcheck $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: dupl\n--------------------"
@gometalinter $(LINT_EXCLUDE) --exclude='.*_test.go' --disable-all --enable=dupl --dupl-threshold=100 extkeys cmd/... geth/... | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: ineffassign\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=ineffassign $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: interfacer\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=interfacer $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: unconvert\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=unconvert $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: goconst\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=goconst $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: staticcheck\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --deadline 45s --enable=staticcheck $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: gas\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gas $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: varcheck\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --deadline 60s --enable=varcheck $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: structcheck\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=structcheck $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
@echo "Linter: gosimple\n--------------------"
@gometalinter $(LINT_EXCLUDE) --disable-all --deadline 45s --enable=gosimple $(LINT_FOLDERS) | grep -v -f ./static/config/linter_exclude_list.txt || echo "OK!"
mock-install: ##@other Install mocking tools
go get -u github.com/golang/mock/mockgen
@ -157,8 +109,4 @@ ci: mock-install mock test-coverage test-e2e ##@tests Run all tests in CI
clean: ##@other Cleanup
rm -fr build/bin/*
rm coverage.out coverage-all.out coverage.html
LINT_EXCLUDE := --exclude='.*_mock.go' --exclude='geth/jail/doc.go'
LINT_FOLDERS := extkeys cmd/... geth/... e2e/...
rm coverage.out coverage-all.out coverage.html

70
static/tools/mk/lint.mk Normal file
View File

@ -0,0 +1,70 @@
LINT_EXCLUDE := --exclude='.*_mock.go' --exclude='geth/jail/doc.go'
LINT_FOLDERS := extkeys cmd/... geth/... e2e/...
LINT_FOLDERS_WITHOUT_TESTS := extkeys cmd/... geth/...
lint-deps:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
lint: lint-vet lint-vetshadow lint-goimports lint-gofmt lint-deadcode lint-misspell lint-unparam lint-unused lint-gocyclo lint-errcheck lint-ineffassign lint-interfacer lint-unconvert lint-staticcheck lint-goconst lint-gas lint-varcheck lint-structcheck lint-gosimple
lint-vet:
@echo "lint-vet"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=vet --deadline=45s $(LINT_FOLDERS)
lint-vetshadow:
@echo "lint-vetshadow"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=vetshadow --deadline=45s $(LINT_FOLDERS)
lint-goimports:
@echo "lint-goimports"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=goimports --deadline=45s $(LINT_FOLDERS)
lint-golint:
@echo "lint-golint"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=golint --deadline=45s $(LINT_FOLDERS)
lint-gofmt:
@echo "lint-gofmt"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gofmt --deadline=45s $(LINT_FOLDERS)
lint-deadcode:
@echo "lint-deadcode"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=deadcode --deadline=45s $(LINT_FOLDERS)
lint-misspell:
@echo "lint-misspell"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=misspell --deadline=45s $(LINT_FOLDERS)
lint-unparam:
@echo "lint-unparam"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=unparam --deadline=45s $(LINT_FOLDERS)
lint-unused:
@echo "lint-unused"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=unused --deadline=45s $(LINT_FOLDERS)
lint-gocyclo:
@echo "lint-gocyclo"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gocyclo --cyclo-over=20 --deadline=45s $(LINT_FOLDERS)
lint-errcheck:
@echo "lint-errcheck"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=errcheck --deadline=45s $(LINT_FOLDERS)
lint-ineffassign:
@echo "lint-ineffassign"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=ineffassign --deadline=45s $(LINT_FOLDERS)
lint-interfacer:
@echo "lint-interfacer"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=interfacer --deadline=45s $(LINT_FOLDERS)
lint-unconvert:
@echo "lint-unconvert"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=unconvert --deadline=45s $(LINT_FOLDERS)
lint-staticcheck:
@echo "lint-staticcheck"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=staticcheck --deadline=45s $(LINT_FOLDERS)
lint-goconst:
@echo "lint-goconst"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=goconst --deadline=45s $(LINT_FOLDERS)
lint-gas:
@echo "lint-gas"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gas --deadline=45s $(LINT_FOLDERS)
lint-varcheck:
@echo "lint-varcheck"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=varcheck --deadline=45s $(LINT_FOLDERS)
lint-structcheck:
@echo "lint-structcheck"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=structcheck --deadline=45s $(LINT_FOLDERS)
lint-gosimple:
@echo "lint-gosimple"
@gometalinter $(LINT_EXCLUDE) --disable-all --enable=gosimple --deadline=45s $(LINT_FOLDERS)