mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
switch to golangci-lint from gometalinter 🚤
This commit is contained in:
parent
d8f0bc3e60
commit
da33dd04cc
@ -83,7 +83,7 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
set -ex
|
set -ex
|
||||||
export PATH="$GOBIN:$PATH"
|
export PATH="$GOBIN:$PATH"
|
||||||
make metalinter
|
make lint
|
||||||
- run:
|
- run:
|
||||||
name: check_dep
|
name: check_dep
|
||||||
command: |
|
command: |
|
||||||
|
65
.golangci.yml
Normal file
65
.golangci.yml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
run:
|
||||||
|
deadline: 1m
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable-all: true
|
||||||
|
disable:
|
||||||
|
- gocyclo
|
||||||
|
- golint
|
||||||
|
- maligned
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
- dupl
|
||||||
|
- ineffassign
|
||||||
|
- interfacer
|
||||||
|
- unconvert
|
||||||
|
- goconst
|
||||||
|
- unparam
|
||||||
|
- nakedret
|
||||||
|
- lll
|
||||||
|
- gochecknoglobals
|
||||||
|
- govet
|
||||||
|
- gocritic
|
||||||
|
- gosec
|
||||||
|
- gochecknoinits
|
||||||
|
- scopelint
|
||||||
|
- stylecheck
|
||||||
|
- deadcode
|
||||||
|
- prealloc
|
||||||
|
- unused
|
||||||
|
- gosimple
|
||||||
|
|
||||||
|
# linters-settings:
|
||||||
|
# govet:
|
||||||
|
# check-shadowing: true
|
||||||
|
# golint:
|
||||||
|
# min-confidence: 0
|
||||||
|
# gocyclo:
|
||||||
|
# min-complexity: 10
|
||||||
|
# maligned:
|
||||||
|
# suggest-new: true
|
||||||
|
# dupl:
|
||||||
|
# threshold: 100
|
||||||
|
# goconst:
|
||||||
|
# min-len: 2
|
||||||
|
# min-occurrences: 2
|
||||||
|
# depguard:
|
||||||
|
# list-type: blacklist
|
||||||
|
# packages:
|
||||||
|
# # logging is allowed only by logutils.Log, logrus
|
||||||
|
# # is allowed to use only in logutils package
|
||||||
|
# - github.com/sirupsen/logrus
|
||||||
|
# misspell:
|
||||||
|
# locale: US
|
||||||
|
# lll:
|
||||||
|
# line-length: 140
|
||||||
|
# goimports:
|
||||||
|
# local-prefixes: github.com/golangci/golangci-lint
|
||||||
|
# gocritic:
|
||||||
|
# enabled-tags:
|
||||||
|
# - performance
|
||||||
|
# - style
|
||||||
|
# - experimental
|
||||||
|
# disabled-checks:
|
||||||
|
# - wrapperFunc
|
||||||
|
# - commentFormatting # https://github.com/go-critic/go-critic/issues/755
|
43
Makefile
43
Makefile
@ -1,7 +1,7 @@
|
|||||||
GOTOOLS = \
|
GOTOOLS = \
|
||||||
github.com/mitchellh/gox \
|
github.com/mitchellh/gox \
|
||||||
github.com/golang/dep/cmd/dep \
|
github.com/golang/dep/cmd/dep \
|
||||||
github.com/alecthomas/gometalinter \
|
github.com/golangci/golangci-lint/cmd/golangci-lint \
|
||||||
github.com/gogo/protobuf/protoc-gen-gogo \
|
github.com/gogo/protobuf/protoc-gen-gogo \
|
||||||
github.com/square/certstrap
|
github.com/square/certstrap
|
||||||
GOBIN?=${GOPATH}/bin
|
GOBIN?=${GOPATH}/bin
|
||||||
@ -11,8 +11,6 @@ INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protob
|
|||||||
BUILD_TAGS?='tendermint'
|
BUILD_TAGS?='tendermint'
|
||||||
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`"
|
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`"
|
||||||
|
|
||||||
LINT_FLAGS = --exclude '.*\.pb\.go' --exclude 'vendor/*' --vendor --deadline=600s
|
|
||||||
|
|
||||||
all: check build test install
|
all: check build test install
|
||||||
|
|
||||||
check: check_tools get_vendor_deps
|
check: check_tools get_vendor_deps
|
||||||
@ -82,10 +80,6 @@ get_tools:
|
|||||||
@echo "--> Installing tools"
|
@echo "--> Installing tools"
|
||||||
./scripts/get_tools.sh
|
./scripts/get_tools.sh
|
||||||
|
|
||||||
get_dev_tools:
|
|
||||||
@echo "--> Downloading linters (this may take awhile)"
|
|
||||||
$(GOPATH)/src/github.com/alecthomas/gometalinter/scripts/install.sh -b $(GOBIN)
|
|
||||||
|
|
||||||
update_tools:
|
update_tools:
|
||||||
@echo "--> Updating tools"
|
@echo "--> Updating tools"
|
||||||
./scripts/get_tools.sh
|
./scripts/get_tools.sh
|
||||||
@ -246,38 +240,9 @@ cleanup_after_test_with_deadlock:
|
|||||||
fmt:
|
fmt:
|
||||||
@go fmt ./...
|
@go fmt ./...
|
||||||
|
|
||||||
metalinter:
|
lint:
|
||||||
@echo "--> Running linter"
|
@echo "--> Running linter"
|
||||||
@gometalinter $(LINT_FLAGS) --disable-all \
|
@golangci-lint run
|
||||||
--enable=vet \
|
|
||||||
--enable=vetshadow \
|
|
||||||
--enable=deadcode \
|
|
||||||
--enable=varcheck \
|
|
||||||
--enable=structcheck \
|
|
||||||
--enable=misspell \
|
|
||||||
--enable=safesql \
|
|
||||||
--enable=gosec \
|
|
||||||
--enable=goimports \
|
|
||||||
--enable=gofmt \
|
|
||||||
./...
|
|
||||||
#--enable=gotype \
|
|
||||||
#--enable=gotypex \
|
|
||||||
#--enable=gocyclo \
|
|
||||||
#--enable=golint \
|
|
||||||
#--enable=maligned \
|
|
||||||
#--enable=errcheck \
|
|
||||||
#--enable=staticcheck \
|
|
||||||
#--enable=dupl \
|
|
||||||
#--enable=ineffassign \
|
|
||||||
#--enable=interfacer \
|
|
||||||
#--enable=unconvert \
|
|
||||||
#--enable=goconst \
|
|
||||||
#--enable=unparam \
|
|
||||||
#--enable=nakedret \
|
|
||||||
|
|
||||||
metalinter_all:
|
|
||||||
@echo "--> Running linter (all)"
|
|
||||||
gometalinter $(LINT_FLAGS) --enable-all --disable=lll ./...
|
|
||||||
|
|
||||||
DESTINATION = ./index.html.md
|
DESTINATION = ./index.html.md
|
||||||
|
|
||||||
@ -343,4 +308,4 @@ build-slate:
|
|||||||
# To avoid unintended conflicts with file names, always add to .PHONY
|
# To avoid unintended conflicts with file names, always add to .PHONY
|
||||||
# unless there is a reason not to.
|
# unless there is a reason not to.
|
||||||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
|
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
|
||||||
.PHONY: check build build_race build_abci dist install install_abci check_dep check_tools get_tools get_dev_tools update_tools get_vendor_deps draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock metalinter metalinter_all
|
.PHONY: check build build_race build_abci dist install install_abci check_dep check_tools get_tools update_tools get_vendor_deps draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint
|
||||||
|
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@ -53,6 +53,6 @@ Vagrant.configure("2") do |config|
|
|||||||
|
|
||||||
# get all deps and tools, ready to install/test
|
# get all deps and tools, ready to install/test
|
||||||
su - vagrant -c 'source /home/vagrant/.bash_profile'
|
su - vagrant -c 'source /home/vagrant/.bash_profile'
|
||||||
su - vagrant -c 'cd /home/vagrant/go/src/github.com/tendermint/tendermint && make get_tools && make get_dev_tools && make get_vendor_deps'
|
su - vagrant -c 'cd /home/vagrant/go/src/github.com/tendermint/tendermint && make get_tools && make get_vendor_deps'
|
||||||
SHELL
|
SHELL
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# run the linter
|
# run the linter
|
||||||
# make metalinter_test
|
# make lint
|
||||||
|
|
||||||
# setup certs
|
# setup certs
|
||||||
make gen_certs
|
make gen_certs
|
||||||
|
@ -5,11 +5,14 @@ set -e
|
|||||||
# specific git hash.
|
# specific git hash.
|
||||||
#
|
#
|
||||||
# repos it installs:
|
# repos it installs:
|
||||||
# github.com/mitchellh/gox
|
|
||||||
# github.com/golang/dep/cmd/dep
|
# github.com/golang/dep/cmd/dep
|
||||||
# gopkg.in/alecthomas/gometalinter.v2
|
|
||||||
# github.com/gogo/protobuf/protoc-gen-gogo
|
# github.com/gogo/protobuf/protoc-gen-gogo
|
||||||
# github.com/square/certstrap
|
# github.com/square/certstrap
|
||||||
|
# github.com/mitchellh/gox
|
||||||
|
# github.com/golangci/golangci-lint
|
||||||
|
# github.com/petermattis/goid
|
||||||
|
# github.com/sasha-s/go-deadlock
|
||||||
|
# goimports
|
||||||
|
|
||||||
## check if GOPATH is set
|
## check if GOPATH is set
|
||||||
if [ -z ${GOPATH+x} ]; then
|
if [ -z ${GOPATH+x} ]; then
|
||||||
@ -45,14 +48,22 @@ installFromGithub() {
|
|||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
|
######################## COMMON TOOLS ########################################
|
||||||
installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
|
installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
|
||||||
## gometalinter v3.0.0
|
|
||||||
installFromGithub alecthomas/gometalinter df395bfa67c5d0630d936c0044cf07ff05086655
|
######################## DEVELOPER TOOLS #####################################
|
||||||
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
|
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
|
||||||
|
|
||||||
installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7
|
installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7
|
||||||
|
|
||||||
|
# used to build tm-monitor & tm-bench binaries
|
||||||
|
installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
|
||||||
|
|
||||||
|
## golangci-lint v1.13.2
|
||||||
|
installFromGithub golangci/golangci-lint 7b2421d55194c9dc385eff7720a037aa9244ca3c cmd/golangci-lint
|
||||||
|
|
||||||
## make test_with_deadlock
|
## make test_with_deadlock
|
||||||
|
## XXX: https://github.com/tendermint/tendermint/issues/3242
|
||||||
installFromGithub petermattis/goid b0b1615b78e5ee59739545bb38426383b2cda4c9
|
installFromGithub petermattis/goid b0b1615b78e5ee59739545bb38426383b2cda4c9
|
||||||
installFromGithub sasha-s/go-deadlock d68e2bc52ae3291765881b9056f2c1527f245f1e
|
installFromGithub sasha-s/go-deadlock d68e2bc52ae3291765881b9056f2c1527f245f1e
|
||||||
go get golang.org/x/tools/cmd/goimports
|
go get golang.org/x/tools/cmd/goimports
|
||||||
|
Loading…
x
Reference in New Issue
Block a user