diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c60b80184..dfdc17ed4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,13 @@ -name: Lint -# Lint runs golangci-lint over the entire Ostracon repository -# This workflow is run on every pull request and push to master -# The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified. +name: Golang Linter +# Lint runs golangci-lint over the entire Ostracon repository. +# +# This workflow is run on every pull request and push to main. +# +# The `golangci` job will pass without running if no *.{go, mod, sum} +# files have been modified. +# +# To run this locally, simply run `make lint` from the root of the repo. + on: pull_request: push: @@ -11,6 +17,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 8 steps: + - uses: actions/setup-go@v3 + with: + go-version: '1.18' - uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6.1.1 with: @@ -20,8 +29,7 @@ jobs: go.sum - uses: golangci/golangci-lint-action@v3.3.1 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.42.1 + version: v1.50.1 args: --timeout 10m github-token: ${{ secrets.github_token }} if: env.GIT_DIFF diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index d2b5880aa..000000000 --- a/.golangci.yml +++ /dev/null @@ -1,62 +0,0 @@ -linters: - enable: - - asciicheck - - bodyclose - - deadcode - - depguard - - dogsled - - dupl - - errcheck - - exportloopref - # - funlen - # - gochecknoglobals - # - gochecknoinits - # - gocognit - - goconst - # - gocritic - # - gocyclo - # - godox - - gofmt - - goimports - - revive - - gosec - - gosimple - - govet - - ineffassign - # - interfacer - - lll - # - maligned - # - misspell - - nakedret - - nolintlint - - prealloc - - staticcheck - - structcheck - - stylecheck - - typecheck - - unconvert - # - unparam - - unused - - varcheck - # - whitespace - # - wsl - -issues: - exclude-rules: - - path: _test\.go - linters: - - gosec - - linters: - - lll - source: "https://" - max-same-issues: 50 - -linters-settings: - dogsled: - max-blank-identifiers: 3 - golint: - min-confidence: 0 - maligned: - suggest-new: true - misspell: - locale: US diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index dd51411db..72b93e67c 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -461,8 +461,8 @@ func TestByzantineConflictingProposalsWithPartition(t *testing.T) { case <-done: case <-tick.C: for i, reactor := range reactors { - t.Log(fmt.Sprintf("Consensus Reactor %v", i)) - t.Log(fmt.Sprintf("%v", reactor)) + t.Logf("Consensus Reactor %v", i) + t.Logf("%v", reactor) } t.Fatalf("Timed out waiting for all validators to commit first block") } diff --git a/crypto/bls/bls_test.go b/crypto/bls/bls_test.go index 702325c01..05ab9ad08 100644 --- a/crypto/bls/bls_test.go +++ b/crypto/bls/bls_test.go @@ -185,7 +185,7 @@ func generatePubKeysAndSigns(t *testing.T, size int) ([]bls.PubKey, [][]byte, [] msgs[i] = []byte(fmt.Sprintf("hello, workd #%d", i)) sigs[i], err = privKey.Sign(msgs[i]) if err != nil { - t.Fatal(fmt.Sprintf("fail to sign: %s", err)) + t.Fatalf("fail to sign: %s", err) } if !pubKeys[i].VerifySignature(msgs[i], sigs[i]) { t.Fatal("fail to verify signature") @@ -203,7 +203,7 @@ func blsPublicKey(t *testing.T, pubKey crypto.PubKey) bls.PubKey { } else { keyType = t.Name() } - t.Fatal(fmt.Sprintf("specified public key is not for BLS: %s", keyType)) + t.Fatalf("specified public key is not for BLS: %s", keyType) } return blsPubKey } diff --git a/p2p/transport_test.go b/p2p/transport_test.go index 80a497d6e..7b5af5656 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -80,9 +80,9 @@ func TestTransportMultiplexConnFilter(t *testing.T) { } _, err = mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsFiltered() { - t.Errorf("expected peer to be filtered, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsFiltered() { + t.Errorf("expected peer to be filtered, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -387,9 +387,9 @@ func TestTransportMultiplexValidateNodeInfo(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsNodeInfoInvalid() { - t.Errorf("expected NodeInfo to be invalid, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsNodeInfoInvalid() { + t.Errorf("expected NodeInfo to be invalid, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -426,9 +426,9 @@ func TestTransportMultiplexRejectMissmatchID(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsAuthFailure() { - t.Errorf("expected auth failure, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsAuthFailure() { + t.Errorf("expected auth failure, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -454,8 +454,8 @@ func TestTransportMultiplexDialRejectWrongID(t *testing.T) { _, err := dialer.Dial(*addr, peerConfig{}) if err != nil { t.Logf("connection failed: %v", err) - if err, ok := err.(ErrRejected); ok { - if !err.IsAuthFailure() { + if e, ok := err.(ErrRejected); ok { + if !e.IsAuthFailure() { t.Errorf("expected auth failure, got %v", err) } } else { @@ -491,9 +491,9 @@ func TestTransportMultiplexRejectIncompatible(t *testing.T) { }() _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsIncompatible() { - t.Errorf("expected to reject incompatible, got %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsIncompatible() { + t.Errorf("expected to reject incompatible, got %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -518,9 +518,9 @@ func TestTransportMultiplexRejectSelf(t *testing.T) { }() if err := <-errc; err != nil { - if err, ok := err.(ErrRejected); ok { - if !err.IsSelf() { - t.Errorf("expected to reject self, got: %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsSelf() { + t.Errorf("expected to reject self, got: %v", e) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -530,12 +530,12 @@ func TestTransportMultiplexRejectSelf(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsSelf() { - t.Errorf("expected to reject self, got: %v", err) + if e, ok := err.(ErrRejected); ok { + if !e.IsSelf() { + t.Errorf("expected to reject self, got: %v", e) } } else { - t.Errorf("expected ErrRejected, got %v", nil) + t.Errorf("expected ErrRejected, got %v", err) } }