diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..ad499d9af --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,12 @@ +name: Lint +on: [pull_request] +jobs: + golangci-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-check diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index 108f6f500..0b5f0b388 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -77,7 +77,9 @@ type mockBlockApplier struct { } // XXX: Add whitelist/blacklist? -func (mba *mockBlockApplier) ApplyBlock(state sm.State, blockID types.BlockID, block *types.Block) (sm.State, int64, error) { +func (mba *mockBlockApplier) ApplyBlock( + state sm.State, blockID types.BlockID, block *types.Block, +) (sm.State, int64, error) { state.LastBlockHeight++ return state, 0, nil } @@ -121,12 +123,6 @@ func (sio *mockSwitchIo) trySwitchToConsensus(state sm.State, blocksSynced int) sio.switchedToConsensus = true } -func (sio *mockSwitchIo) hasSwitchedToConsensus() bool { - sio.mtx.Lock() - defer sio.mtx.Unlock() - return sio.switchedToConsensus -} - func (sio *mockSwitchIo) broadcastStatusRequest(base int64, height int64) { } diff --git a/lite2/client.go b/lite2/client.go index 215e26bdb..6fcb7d173 100644 --- a/lite2/client.go +++ b/lite2/client.go @@ -140,8 +140,7 @@ type Client struct { // See ConfirmationFunction option confirmationFn func(action string) bool - routinesWaitGroup sync.WaitGroup - quit chan struct{} + quit chan struct{} logger log.Logger } diff --git a/state/execution.go b/state/execution.go index c6d0b8475..cd45484ce 100644 --- a/state/execution.go +++ b/state/execution.go @@ -123,7 +123,9 @@ func (blockExec *BlockExecutor) ValidateBlock(state State, block *types.Block) e // It's the only function that needs to be called // from outside this package to process and commit an entire block. // It takes a blockID to avoid recomputing the parts hash. -func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, block *types.Block) (State, int64, error) { +func (blockExec *BlockExecutor) ApplyBlock( + state State, blockID types.BlockID, block *types.Block, +) (State, int64, error) { if err := blockExec.ValidateBlock(state, block); err != nil { return state, 0, ErrInvalidBlock(err) diff --git a/state/store_test.go b/state/store_test.go index d46eaa9eb..46e1a7dd1 100644 --- a/state/store_test.go +++ b/state/store_test.go @@ -81,8 +81,10 @@ func TestPruneStates(t *testing.T) { "error when from == to": {100, 3, 3, true, nil, nil, nil}, "error when to does not exist": {100, 1, 101, true, nil, nil, nil}, "prune all": {100, 1, 100, false, []int64{93, 100}, []int64{95, 100}, []int64{100}}, - "prune some": {10, 2, 8, false, []int64{1, 3, 8, 9, 10}, []int64{1, 5, 8, 9, 10}, []int64{1, 8, 9, 10}}, - "prune across checkpoint": {100001, 1, 100001, false, []int64{99993, 100000, 100001}, []int64{99995, 100001}, []int64{100001}}, + "prune some": {10, 2, 8, false, []int64{1, 3, 8, 9, 10}, + []int64{1, 5, 8, 9, 10}, []int64{1, 8, 9, 10}}, + "prune across checkpoint": {100001, 1, 100001, false, []int64{99993, 100000, 100001}, + []int64{99995, 100001}, []int64{100001}}, } for name, tc := range testcases { tc := tc diff --git a/types/validator_set_test.go b/types/validator_set_test.go index bc12b69c2..2a6dff9f6 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -3,7 +3,6 @@ package types import ( "bytes" "fmt" - "github.com/stretchr/testify/require" "math" "sort" "strings" @@ -12,6 +11,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519"