Feature/integrate linters into ci#387 (#427)
Solves #387 linters was integrated into ci Added inergration linters to CI Important changes: - new linter warnings was fixed - extracted linters targets into separated mk file
This commit is contained in:
commit
f80827dc1f
10
.travis.yml
10
.travis.yml
|
@ -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
|
||||
|
|
58
Makefile
58
Makefile
|
@ -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
|
||||
|
@ -158,8 +110,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
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import "C"
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
|
|
@ -12,8 +12,7 @@ import (
|
|||
// NodeManagerTestSuite defines a test suit with NodeManager.
|
||||
type NodeManagerTestSuite struct {
|
||||
suite.Suite
|
||||
NodeManager common.NodeManager
|
||||
nodeSyncCompleted bool
|
||||
NodeManager common.NodeManager
|
||||
}
|
||||
|
||||
// StartTestNode initiazes a NodeManager instances with configuration retrieved
|
||||
|
@ -52,8 +51,7 @@ func (s *NodeManagerTestSuite) StopTestNode() {
|
|||
// and a few utility methods to start and stop node or get various services.
|
||||
type BackendTestSuite struct {
|
||||
suite.Suite
|
||||
Backend *api.StatusBackend
|
||||
nodeSyncCompleted bool
|
||||
Backend *api.StatusBackend
|
||||
}
|
||||
|
||||
// SetupTest initializes Backend.
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
//nolint: unused, varcheck
|
||||
whisperMessage1 = `test message 1 (K1 -> K2, signed+encrypted, from us)`
|
||||
whisperMessage2 = `test message 3 (K1 -> "", signed broadcast)`
|
||||
whisperMessage3 = `test message 4 ("" -> "", anon broadcast)`
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue