Skip to content

Commit

Permalink
golangci-lint: enable all the linters by default (tendermint#1838)
Browse files Browse the repository at this point in the history
* golangci-lint: enable all the linters by default

* fix scanWhile

* bring back getKeys

* update mocks

* fix labels

* bring back getKeys

* bring back makeAddrs

* remove unused tag

* remove extra slash
  • Loading branch information
melekes authored Dec 18, 2023
1 parent c7196f7 commit 99fcbc4
Show file tree
Hide file tree
Showing 335 changed files with 1,633 additions and 1,839 deletions.
74 changes: 47 additions & 27 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
run:
tests: false
timeout: 5m

linters:
enable:
- asciicheck
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- goconst
- gofmt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- staticcheck
# - structcheck // to be fixed by golangci-lint
- stylecheck
enable-all: true
disable:
- containedctx
- contextcheck
- cyclop
- dupword
- errname
- errorlint
- exhaustive
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- gocyclo
- godox
- goerr113
- golint
- gomnd
- gomoddirectives
- ifshort
- interfacebloat
- interfacer
- ireturn
- lll
- maintidx
- maligned
- nestif
- nilnil
- nlreturn
- nonamedreturns
- nosnakecase
- predeclared
- tagliatelle
- typecheck
- unconvert
- unused
- varnamelen
- wrapcheck
- wsl
- scopelint
- unparam
- revive

issues:
exclude-rules:
Expand All @@ -42,8 +64,6 @@ issues:
linters-settings:
dogsled:
max-blank-identifiers: 3
golint:
min-confidence: 0
goconst:
ignore-tests: true
maligned:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ lint:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run
.PHONY: lint

lint-format:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run --fix
@go run mvdan.cc/gofumpt -l -w ./..
.PHONY: lint-format

vulncheck:
@go run golang.org/x/vuln/cmd/govulncheck@latest ./...
.PHONY: vulncheck
Expand Down
10 changes: 5 additions & 5 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ type Client interface {
// TODO: remove as each method now returns an error
Error() error
// TODO: remove as this is not implemented
Flush(context.Context) error
Echo(context.Context, string) (*types.EchoResponse, error)
Flush(ctx context.Context) error
Echo(ctx context.Context, echo string) (*types.EchoResponse, error)

// FIXME: All other operations are run synchronously and rely
// on the caller to dictate concurrency (i.e. run a go routine),
// with the exception of `CheckTxAsync` which we maintain
// for the v0 mempool. We should explore refactoring the
// mempool to remove this vestige behavior.
SetResponseCallback(Callback)
CheckTxAsync(context.Context, *types.CheckTxRequest) (*ReqRes, error)
SetResponseCallback(cb Callback)
CheckTxAsync(ctx context.Context, req *types.CheckTxRequest) (*ReqRes, error)
}

//----------------------------------------

// NewClient returns a new ABCI client of the specified transport type.
// It returns an error if the transport is not "socket" or "grpc"
// It returns an error if the transport is not "socket" or "grpc".
func NewClient(addr, transport string, mustConnect bool) (client Client, err error) {
switch transport {
case "socket":
Expand Down
2 changes: 1 addition & 1 deletion abci/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cometbft/cometbft/abci/types"
)

// ErrUnknownAbciTransport is returned when trying to create a client with an invalid transport option
// ErrUnknownAbciTransport is returned when trying to create a client with an invalid transport option.
type ErrUnknownAbciTransport struct {
Transport string
}
Expand Down
7 changes: 3 additions & 4 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import (
"sync"
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/internal/service"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

var _ Client = (*grpcClient)(nil)

// A stripped copy of the remoteClient that makes
// synchronous calls using grpc
// synchronous calls using grpc.
type grpcClient struct {
service.BaseService
mustConnect bool
Expand Down
16 changes: 5 additions & 11 deletions abci/client/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ import (
"testing"
"time"

abciserver "github.com/cometbft/cometbft/abci/server"
"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/libs/log"
"github.com/stretchr/testify/require"

"google.golang.org/grpc"

"golang.org/x/net/context"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/libs/log"

abciserver "github.com/cometbft/cometbft/abci/server"
"github.com/cometbft/cometbft/abci/types"
)

func TestGRPC(t *testing.T) {
Expand Down Expand Up @@ -77,7 +72,6 @@ func TestGRPC(t *testing.T) {
time.Sleep(time.Second * 1) // Wait for a bit to allow counter overflow
}()
}

}
}

Expand Down
Loading

0 comments on commit 99fcbc4

Please sign in to comment.