Skip to content

Commit 7fd79df

Browse files
authored
chore: fix all linting (#24101)
1 parent b7fb7f4 commit 7fd79df

File tree

329 files changed

+1278
-1247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+1278
-1247
lines changed

.golangci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ linters:
3737
issues:
3838
exclude-dirs:
3939
- testutil/testdata
40+
- x/params
41+
- x/crisis
4042
exclude-files:
4143
- server/grpc/gogoreflection/fix_registration.go
4244
- "fix_registration.go"

Makefile

+1-7
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,13 @@ benchmark:
382382
### Linting ###
383383
###############################################################################
384384

385-
golangci_version=v1.64.7
385+
golangci_version=v1.64.8
386386

387387
lint-install:
388388
@echo "--> Installing golangci-lint $(golangci_version)"
389389
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
390390

391391
lint:
392-
@echo "--> Running linter on diffed files only."
393-
$(MAKE) lint-install
394-
@./scripts/go-lint-changes.bash --timeout=15m
395-
396-
397-
lint-all:
398392
@echo "--> Running linter on all files"
399393
$(MAKE) lint-install
400394
@./scripts/go-lint-all.bash --timeout=15m

UPGRADING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ If you are still using the legacy wiring, you must enable unordered transactions
6565
if manager := app.SnapshotManager(); manager != nil {
6666
err := manager.RegisterExtensions(unorderedtx.NewSnapshotter(app.UnorderedTxManager))
6767
if err != nil {
68-
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
68+
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
6969
}
7070
}
7171
```

baseapp/abci_test.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) {
716716
msgs = append(msgs, &baseapptestutil.MsgCounter2{Counter: 0, Signer: addr.String()})
717717
msgs = append(msgs, &baseapptestutil.MsgCounter2{Counter: 1, Signer: addr.String()})
718718

719-
builder.SetMsgs(msgs...)
719+
require.NoError(t, builder.SetMsgs(msgs...))
720720
builder.SetMemo(tx.GetMemo())
721721
setTxSignature(t, builder, 0)
722722

@@ -888,7 +888,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
888888
{
889889
txBuilder := suite.txConfig.NewTxBuilder()
890890
_, _, addr := testdata.KeyTestPubAddr()
891-
txBuilder.SetMsgs(&baseapptestutil.MsgCounter2{Signer: addr.String()})
891+
require.NoError(t, txBuilder.SetMsgs(&baseapptestutil.MsgCounter2{Signer: addr.String()}))
892892
setTxSignature(t, txBuilder, 0)
893893
unknownRouteTx := txBuilder.GetTx()
894894

@@ -901,10 +901,10 @@ func TestABCI_InvalidTransaction(t *testing.T) {
901901
require.EqualValues(t, sdkerrors.ErrUnknownRequest.ABCICode(), code, err)
902902

903903
txBuilder = suite.txConfig.NewTxBuilder()
904-
txBuilder.SetMsgs(
904+
require.NoError(t, txBuilder.SetMsgs(
905905
&baseapptestutil.MsgCounter{Signer: addr.String()},
906906
&baseapptestutil.MsgCounter2{Signer: addr.String()},
907-
)
907+
))
908908
setTxSignature(t, txBuilder, 0)
909909
unknownRouteTx = txBuilder.GetTx()
910910

@@ -920,7 +920,7 @@ func TestABCI_InvalidTransaction(t *testing.T) {
920920
// Transaction with an unregistered message
921921
{
922922
txBuilder := suite.txConfig.NewTxBuilder()
923-
txBuilder.SetMsgs(&testdata.MsgCreateDog{})
923+
require.NoError(t, txBuilder.SetMsgs(&testdata.MsgCreateDog{}))
924924
tx := txBuilder.GetTx()
925925

926926
_, _, err := suite.baseApp.SimDeliver(suite.txConfig.TxEncoder(), tx)
@@ -1543,10 +1543,11 @@ func TestABCI_Proposals_WithVE(t *testing.T) {
15431543

15441544
suite := NewBaseAppSuite(t, setInitChainerOpt, prepareOpt)
15451545

1546-
suite.baseApp.InitChain(&abci.RequestInitChain{
1546+
_, err := suite.baseApp.InitChain(&abci.RequestInitChain{
15471547
InitialHeight: 1,
15481548
ConsensusParams: &cmtproto.ConsensusParams{},
15491549
})
1550+
require.NoError(t, err)
15501551

15511552
reqPrepareProposal := abci.RequestPrepareProposal{
15521553
MaxTxBytes: 100000,
@@ -1683,11 +1684,12 @@ func TestABCI_PrepareProposal_MaxGas(t *testing.T) {
16831684
baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{})
16841685

16851686
// set max block gas limit to 100
1686-
suite.baseApp.InitChain(&abci.RequestInitChain{
1687+
_, err := suite.baseApp.InitChain(&abci.RequestInitChain{
16871688
ConsensusParams: &cmtproto.ConsensusParams{
16881689
Block: &cmtproto.BlockParams{MaxGas: 100},
16891690
},
16901691
})
1692+
require.NoError(t, err)
16911693

16921694
// insert 100 txs, each with a gas limit of 10
16931695
_, _, addr := testdata.KeyTestPubAddr()
@@ -1696,7 +1698,7 @@ func TestABCI_PrepareProposal_MaxGas(t *testing.T) {
16961698
msgs := []sdk.Msg{msg}
16971699

16981700
builder := suite.txConfig.NewTxBuilder()
1699-
builder.SetMsgs(msgs...)
1701+
require.NoError(t, builder.SetMsgs(msgs...))
17001702
builder.SetMemo("counter=" + strconv.FormatInt(i, 10) + "&failOnAnte=false")
17011703
builder.SetGasLimit(10)
17021704
setTxSignature(t, builder, uint64(i))
@@ -2010,13 +2012,14 @@ func TestABCI_HaltChain(t *testing.T) {
20102012
for _, tc := range testCases {
20112013
t.Run(tc.name, func(t *testing.T) {
20122014
suite := NewBaseAppSuite(t, baseapp.SetHaltHeight(tc.haltHeight), baseapp.SetHaltTime(tc.haltTime))
2013-
suite.baseApp.InitChain(&abci.RequestInitChain{
2015+
_, err := suite.baseApp.InitChain(&abci.RequestInitChain{
20142016
ConsensusParams: &cmtproto.ConsensusParams{},
20152017
InitialHeight: tc.blockHeight,
20162018
})
2019+
require.NoError(t, err)
20172020

20182021
app := suite.baseApp
2019-
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
2022+
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
20202023
Height: tc.blockHeight,
20212024
Time: time.Unix(tc.blockTime, 0),
20222025
})

baseapp/abci_utils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"slices" //nolint: gci // ignore this line for this linter
7+
"slices"
88

99
"github.com/cockroachdb/errors"
1010
abci "github.com/cometbft/cometbft/abci/types"
@@ -13,7 +13,7 @@ import (
1313
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
1414
cmttypes "github.com/cometbft/cometbft/types"
1515
protoio "github.com/cosmos/gogoproto/io"
16-
"github.com/cosmos/gogoproto/proto" //nolint: gci // ignore this line for this linter
16+
"github.com/cosmos/gogoproto/proto"
1717

1818
"cosmossdk.io/core/comet"
1919

baseapp/baseapp_test.go

+18-8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type (
6262
)
6363

6464
func NewBaseAppSuite(t *testing.T, opts ...func(*baseapp.BaseApp)) *BaseAppSuite {
65+
t.Helper()
66+
6567
cdc := codectestutil.CodecOptions{}.NewCodec()
6668
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())
6769

@@ -112,6 +114,8 @@ func getQueryBaseapp(t *testing.T) *baseapp.BaseApp {
112114
}
113115

114116
func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...func(*baseapp.BaseApp)) *BaseAppSuite {
117+
t.Helper()
118+
115119
snapshotTimeout := 1 * time.Minute
116120
snapshotStore, err := snapshots.NewStore(dbm.NewMemDB(), testutil.GetTempDir(t))
117121
require.NoError(t, err)
@@ -140,7 +144,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun
140144
_, _, addr := testdata.KeyTestPubAddr()
141145
txs := [][]byte{}
142146
for txNum := 0; txNum < cfg.blockTxs; txNum++ {
143-
msgs := []sdk.Msg{}
147+
var msgs []sdk.Msg
144148
for msgNum := 0; msgNum < 100; msgNum++ {
145149
key := []byte(fmt.Sprintf("%v", keyCounter))
146150
value := make([]byte, 10000)
@@ -153,7 +157,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun
153157
}
154158

155159
builder := suite.txConfig.NewTxBuilder()
156-
builder.SetMsgs(msgs...)
160+
require.NoError(t, builder.SetMsgs(msgs...))
157161
setTxSignature(t, builder, 0)
158162

159163
txBytes, err := suite.txConfig.TxEncoder()(builder.GetTx())
@@ -294,6 +298,8 @@ func TestSetLoader(t *testing.T) {
294298
}
295299

296300
initStore := func(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
301+
t.Helper()
302+
297303
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
298304
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
299305

@@ -314,6 +320,8 @@ func TestSetLoader(t *testing.T) {
314320
}
315321

316322
checkStore := func(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
323+
t.Helper()
324+
317325
rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
318326
rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault))
319327

@@ -549,7 +557,8 @@ func TestCustomRunTxPanicHandler(t *testing.T) {
549557
require.PanicsWithValue(t, customPanicMsg, func() {
550558
bz, err := suite.txConfig.TxEncoder()(tx)
551559
require.NoError(t, err)
552-
suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{bz}})
560+
_, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{bz}})
561+
require.Error(t, err)
553562
})
554563
}
555564
}
@@ -623,7 +632,8 @@ func TestBaseAppAnteHandler(t *testing.T) {
623632
require.Equal(t, int64(2), getIntFromStore(t, store, anteKey))
624633
require.Equal(t, int64(1), getIntFromStore(t, store, deliverKey))
625634

626-
suite.baseApp.Commit()
635+
_, err = suite.baseApp.Commit()
636+
require.NoError(t, err)
627637
}
628638

629639
func TestBaseAppPostHandler(t *testing.T) {
@@ -869,16 +879,16 @@ func TestGetMaximumBlockGas(t *testing.T) {
869879

870880
ctx := suite.baseApp.NewContext(true)
871881

872-
suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 0}})
882+
require.NoError(t, suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 0}}))
873883
require.Equal(t, uint64(0), suite.baseApp.GetMaximumBlockGas(ctx))
874884

875-
suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: -1}})
885+
require.NoError(t, suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: -1}}))
876886
require.Equal(t, uint64(0), suite.baseApp.GetMaximumBlockGas(ctx))
877887

878-
suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 5000000}})
888+
require.NoError(t, suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 5000000}}))
879889
require.Equal(t, uint64(5000000), suite.baseApp.GetMaximumBlockGas(ctx))
880890

881-
suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: -5000000}})
891+
require.NoError(t, suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: -5000000}}))
882892
require.Panics(t, func() { suite.baseApp.GetMaximumBlockGas(ctx) })
883893
}
884894

baseapp/grpcrouter_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func TestQueryDataRaces_uniqueConnectionsToSameHandler(t *testing.T) {
162162
}
163163

164164
func testQueryDataRacesSameHandler(t *testing.T, makeClientConn func(*baseapp.GRPCQueryRouter) *baseapp.QueryServiceTestHelper) {
165+
t.Helper()
165166
t.Parallel()
166167

167168
qr := baseapp.NewGRPCQueryRouter()

baseapp/snapshot_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) {
245245
}, abci.ResponseOfferSnapshot_REJECT},
246246
}
247247
for name, tc := range testCases {
248-
tc := tc
249248
t.Run(name, func(t *testing.T) {
250249
resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: tc.snapshot})
251250
require.NoError(t, err)

baseapp/streaming_test.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) {
5151
addListenerOpt := func(bapp *baseapp.BaseApp) { bapp.CommitMultiStore().AddListeners([]storetypes.StoreKey{distKey1}) }
5252
suite := NewBaseAppSuite(t, anteOpt, distOpt, streamingManagerOpt, addListenerOpt)
5353

54-
suite.baseApp.InitChain(
54+
_, err := suite.baseApp.InitChain(
5555
&abci.RequestInitChain{
5656
ConsensusParams: &tmproto.ConsensusParams{},
5757
},
5858
)
59+
require.NoError(t, err)
5960

6061
deliverKey := []byte("deliver-key")
6162
baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, deliverKey})
@@ -103,7 +104,8 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) {
103104
// require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0], events[2], "msg handler update counter event")
104105
}
105106

106-
suite.baseApp.Commit()
107+
_, err = suite.baseApp.Commit()
108+
require.NoError(t, err)
107109

108110
require.Equal(t, expectedChangeSet, mockListener1.ChangeSet, "should contain the same changeSet")
109111
require.Equal(t, expectedChangeSet, mockListener2.ChangeSet, "should contain the same changeSet")
@@ -119,9 +121,10 @@ func Test_Ctx_with_StreamingManager(t *testing.T) {
119121
addListenerOpt := func(bapp *baseapp.BaseApp) { bapp.CommitMultiStore().AddListeners([]storetypes.StoreKey{distKey1}) }
120122
suite := NewBaseAppSuite(t, streamingManagerOpt, addListenerOpt)
121123

122-
suite.baseApp.InitChain(&abci.RequestInitChain{
124+
_, err := suite.baseApp.InitChain(&abci.RequestInitChain{
123125
ConsensusParams: &tmproto.ConsensusParams{},
124126
})
127+
require.NoError(t, err)
125128

126129
ctx := getFinalizeBlockStateCtx(suite.baseApp)
127130
sm := ctx.StreamingManager()
@@ -133,14 +136,16 @@ func Test_Ctx_with_StreamingManager(t *testing.T) {
133136

134137
for blockN := 0; blockN < nBlocks; blockN++ {
135138

136-
suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1})
139+
_, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1})
140+
require.NoError(t, err)
137141

138142
ctx := getFinalizeBlockStateCtx(suite.baseApp)
139143
sm := ctx.StreamingManager()
140144
require.NotNil(t, sm, fmt.Sprintf("nil StreamingManager: %v", sm))
141145
require.Equal(t, listeners, sm.ABCIListeners, fmt.Sprintf("should contain same listeners: %v", listeners))
142146
require.Equal(t, true, sm.StopNodeOnErr, "should contain StopNodeOnErr = true")
143147

144-
suite.baseApp.Commit()
148+
_, err = suite.baseApp.Commit()
149+
require.NoError(t, err)
145150
}
146151
}

0 commit comments

Comments
 (0)