Browse Source

switch to golangci-lint from gometalinter 🚤

pull/3261/head
Anton Kaliaev 5 years ago
parent
commit
da33dd04cc
No known key found for this signature in database GPG Key ID: 7B6881D965918214
6 changed files with 88 additions and 47 deletions
  1. +1
    -1
      .circleci/config.yml
  2. +65
    -0
      .golangci.yml
  3. +4
    -39
      Makefile
  4. +1
    -1
      Vagrantfile
  5. +1
    -1
      libs/test.sh
  6. +16
    -5
      scripts/get_tools.sh

+ 1
- 1
.circleci/config.yml View File

@ -83,7 +83,7 @@ jobs:
command: |
set -ex
export PATH="$GOBIN:$PATH"
make metalinter
make lint
- run:
name: check_dep
command: |


+ 65
- 0
.golangci.yml View 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

+ 4
- 39
Makefile View File

@ -1,7 +1,7 @@
GOTOOLS = \
github.com/mitchellh/gox \
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/square/certstrap
GOBIN?=${GOPATH}/bin
@ -11,8 +11,6 @@ INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protob
BUILD_TAGS?='tendermint'
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
check: check_tools get_vendor_deps
@ -82,10 +80,6 @@ get_tools:
@echo "--> Installing tools"
./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:
@echo "--> Updating tools"
./scripts/get_tools.sh
@ -246,38 +240,9 @@ cleanup_after_test_with_deadlock:
fmt:
@go fmt ./...
metalinter:
lint:
@echo "--> Running linter"
@gometalinter $(LINT_FLAGS) --disable-all \
--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 ./...
@golangci-lint run
DESTINATION = ./index.html.md
@ -343,4 +308,4 @@ build-slate:
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# 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

+ 1
- 1
Vagrantfile View File

@ -53,6 +53,6 @@ Vagrant.configure("2") do |config|
# get all deps and tools, ready to install/test
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
end

+ 1
- 1
libs/test.sh View File

@ -2,7 +2,7 @@
set -e
# run the linter
# make metalinter_test
# make lint
# setup certs
make gen_certs


+ 16
- 5
scripts/get_tools.sh View File

@ -5,11 +5,14 @@ set -e
# specific git hash.
#
# repos it installs:
# github.com/mitchellh/gox
# github.com/golang/dep/cmd/dep
# gopkg.in/alecthomas/gometalinter.v2
# github.com/gogo/protobuf/protoc-gen-gogo
# 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
if [ -z ${GOPATH+x} ]; then
@ -45,14 +48,22 @@ installFromGithub() {
echo ""
}
installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
######################## COMMON TOOLS ########################################
installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
## gometalinter v3.0.0
installFromGithub alecthomas/gometalinter df395bfa67c5d0630d936c0044cf07ff05086655
######################## DEVELOPER TOOLS #####################################
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
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
## XXX: https://github.com/tendermint/tendermint/issues/3242
installFromGithub petermattis/goid b0b1615b78e5ee59739545bb38426383b2cda4c9
installFromGithub sasha-s/go-deadlock d68e2bc52ae3291765881b9056f2c1527f245f1e
go get golang.org/x/tools/cmd/goimports

Loading…
Cancel
Save