chore: bump golangci-lint and fix all linting issues (#21761)

This commit is contained in:
Julien Robert
2024-09-16 19:11:19 +00:00
committed by GitHub
parent 52ba264c80
commit cbdfd9bdfa
186 changed files with 114 additions and 455 deletions
-2
View File
@@ -422,7 +422,6 @@ func (s *addressTestSuite) TestBech32ifyAddressBytes() {
{"20-byte address", args{"prefixb", addr20byte}, "prefixb1qqqsyqcyq5rqwzqfpg9scrgwpugpzysnrujsuw", false},
}
for _, tt := range tests {
tt := tt
s.T().Run(tt.name, func(t *testing.T) {
got, err := types.Bech32ifyAddressBytes(tt.args.prefix, tt.args.bs)
if (err != nil) != tt.wantErr {
@@ -453,7 +452,6 @@ func (s *addressTestSuite) TestMustBech32ifyAddressBytes() {
{"20-byte address", args{"prefixb", addr20byte}, "prefixb1qqqsyqcyq5rqwzqfpg9scrgwpugpzysnrujsuw", false},
}
for _, tt := range tests {
tt := tt
s.T().Run(tt.name, func(t *testing.T) {
if tt.wantPanic {
require.Panics(t, func() { types.MustBech32ifyAddressBytes(tt.args.prefix, tt.args.bs) })
-2
View File
@@ -432,7 +432,6 @@ func (coins Coins) SafeMulInt(x math.Int) (Coins, bool) {
res := make(Coins, len(coins))
for i, coin := range coins {
coin := coin
res[i] = NewCoin(coin.Denom, coin.Amount.Mul(x))
}
@@ -466,7 +465,6 @@ func (coins Coins) SafeQuoInt(x math.Int) (Coins, bool) {
var res Coins
for _, coin := range coins {
coin := coin
res = append(res, NewCoin(coin.Denom, coin.Amount.Quo(x)))
}
+2 -11
View File
@@ -178,7 +178,6 @@ func (s *coinTestSuite) TestAddCoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.shouldPanic {
s.Require().Panics(func() { tc.inputOne.Add(tc.inputTwo) })
} else {
@@ -218,7 +217,6 @@ func (s *coinTestSuite) TestSubCoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.shouldPanic {
s.Require().Panics(func() { tc.inputOne.Sub(tc.inputTwo) })
} else {
@@ -274,7 +272,6 @@ func (s *coinTestSuite) TestMulIntCoins() {
assert := s.Assert()
for i, tc := range testCases {
tc := tc
if tc.shouldPanic {
assert.Panics(func() { tc.input.MulInt(tc.multiplier) })
} else {
@@ -301,7 +298,6 @@ func (s *coinTestSuite) TestQuoIntCoins() {
assert := s.Assert()
for i, tc := range testCases {
tc := tc
if tc.shouldPanic {
assert.Panics(func() { tc.input.QuoInt(tc.divisor) })
} else {
@@ -326,7 +322,6 @@ func (s *coinTestSuite) TestIsGTCoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.panics {
s.Require().Panics(func() { tc.inputOne.IsGT(tc.inputTwo) })
} else {
@@ -350,7 +345,6 @@ func (s *coinTestSuite) TestIsGTECoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.panics {
s.Require().Panics(func() { tc.inputOne.IsGTE(tc.inputTwo) })
} else {
@@ -374,7 +368,6 @@ func (s *coinTestSuite) TestIsLTECoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.panics {
s.Require().Panics(func() { tc.inputOne.IsLTE(tc.inputTwo) })
} else {
@@ -400,7 +393,6 @@ func (s *coinTestSuite) TestIsLTCoin() {
}
for tcIndex, tc := range cases {
tc := tc
if tc.panics {
s.Require().Panics(func() { tc.inputOne.IsLT(tc.inputTwo) })
} else {
@@ -683,7 +675,6 @@ func (s *coinTestSuite) TestSubCoins() {
assert := s.Assert()
for i, tc := range testCases {
tc := tc
if tc.shouldPanic {
assert.Panics(func() { tc.inputOne.Sub(tc.inputTwo...) })
} else {
@@ -708,7 +699,7 @@ func (s *coinTestSuite) TestSafeSubCoin() {
}
for _, tc := range cases {
tc := tc
res, err := tc.inputOne.SafeSub(tc.inputTwo)
if err != nil {
s.Require().Contains(err.Error(), tc.expErrMsg)
@@ -1373,7 +1364,7 @@ func (s *coinTestSuite) TestCoinValidate() {
}
for _, tc := range testCases {
tc := tc
t := s.T()
t.Run(tc.name, func(t *testing.T) {
err := tc.coin.Validate()
-1
View File
@@ -203,7 +203,6 @@ func (s *contextTestSuite) TestContextHeaderClone() {
}
for name, tc := range cases {
tc := tc
s.T().Run(name, func(t *testing.T) {
ctx := types.NewContext(nil, false, nil).WithBlockHeader(tc.h)
s.Require().Equal(tc.h.Height, ctx.BlockHeight())
-14
View File
@@ -211,7 +211,6 @@ func (s *decCoinTestSuite) TestIsValid() {
}
for _, tc := range tests {
tc := tc
if tc.expectPass {
s.Require().True(tc.coin.IsValid(), tc.msg)
} else {
@@ -246,7 +245,6 @@ func (s *decCoinTestSuite) TestSubDecCoin() {
decCoin := sdk.NewDecCoin("mytoken", math.NewInt(10))
for _, tc := range tests {
tc := tc
if tc.expectPass {
equal := tc.coin.Sub(decCoin)
s.Require().Equal(equal, decCoin, tc.msg)
@@ -282,7 +280,6 @@ func (s *decCoinTestSuite) TestSubDecCoins() {
decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", math.NewInt(10)), sdk.NewCoin("eth", math.NewInt(15)), sdk.NewCoin("mytoken", math.NewInt(5)))
for _, tc := range tests {
tc := tc
if tc.expectPass {
equal := tc.coins.Sub(decCoins)
s.Require().Equal(equal, decCoins, tc.msg)
@@ -527,7 +524,6 @@ func (s *decCoinTestSuite) TestDecCoinsQuoDecTruncate() {
}
for i, tc := range testCases {
tc := tc
if tc.panics {
s.Require().Panics(func() { tc.coins.QuoDecTruncate(tc.input) })
} else {
@@ -564,7 +560,6 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() {
}
for _, tc := range tests {
tc := tc
if tc.expectPass {
s.Require().True(tc.coin.IsValid(), tc.msg)
} else {
@@ -591,7 +586,6 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithZeroCoins() {
}
for _, tc := range tests {
tc := tc
s.Require().Equal(sdk.NewDecCoinsFromCoins(tc.coins...).Len(), tc.expectLength)
}
}
@@ -623,7 +617,6 @@ func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() {
}
for _, tc := range tests {
tc := tc
if tc.expectPass {
s.Require().True(tc.coin.IsValid(), tc.msg)
} else {
@@ -679,7 +672,6 @@ func (s *decCoinTestSuite) TestDecCoins_GetDenomByIndex() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.expectedErr {
s.Require().Panics(func() { tc.input.GetDenomByIndex(tc.index) }, "Test should have panicked")
@@ -721,7 +713,6 @@ func (s *decCoinTestSuite) TestDecCoins_IsAllPositive() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.expectedResult {
s.Require().True(tc.input.IsAllPositive(), "Test case #%d: %s", i, tc.name)
@@ -791,7 +782,6 @@ func (s *decCoinTestSuite) TestDecCoin_IsGTE() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.expectedPanic {
s.Require().Panics(func() { tc.coin.IsGTE(tc.otherCoin) }, "Test case #%d: %s", i, tc.name)
@@ -835,7 +825,6 @@ func (s *decCoinTestSuite) TestDecCoins_IsZero() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.expectedResult {
s.Require().True(tc.coins.IsZero(), "Test case #%d: %s", i, tc.name)
@@ -890,7 +879,6 @@ func (s *decCoinTestSuite) TestDecCoins_MulDec() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
res := tc.coins.MulDec(tc.multiplier)
s.Require().Equal(tc.expectedResult, res, "Test case #%d: %s", i, tc.name)
@@ -939,7 +927,6 @@ func (s *decCoinTestSuite) TestDecCoins_MulDecTruncate() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.expectedPanic {
s.Require().Panics(func() { tc.coins.MulDecTruncate(tc.multiplier) }, "Test case #%d: %s", i, tc.name)
@@ -992,7 +979,6 @@ func (s *decCoinTestSuite) TestDecCoins_QuoDec() {
}
for i, tc := range testCases {
tc := tc
s.T().Run(tc.name, func(t *testing.T) {
if tc.panics {
s.Require().Panics(func() { tc.coins.QuoDec(tc.input) }, "Test case #%d: %s", i, tc.name)
-1
View File
@@ -268,7 +268,6 @@ func (s *eventsTestSuite) TestMarkEventsToIndex() {
}
for name, tc := range testCases {
tc := tc
s.T().Run(name, func(_ *testing.T) {
s.Require().Equal(tc.expected, sdk.MarkEventsToIndex(tc.events, tc.indexSet))
})
-2
View File
@@ -594,7 +594,6 @@ func (m *Manager) assertNoForgottenModules(setOrderFnName string, moduleNames []
}
var missing []string
for m := range m.Modules {
m := m
if pass != nil && pass(m) {
continue
}
@@ -834,7 +833,6 @@ func (m *Manager) GetVersionMap() appmodule.VersionMap {
if v, ok := v.(appmodule.HasConsensusVersion); ok {
version = v.ConsensusVersion()
}
name := name
vermap[name] = version
}
@@ -140,7 +140,6 @@ func TestCollectionPagination(t *testing.T) {
}
for name, tc := range tcs {
tc := tc
t.Run(name, func(t *testing.T) {
gotResults, gotResponse, err := CollectionFilteredPaginate(
ctx,
-3
View File
@@ -24,7 +24,6 @@ func TestRandomAccounts(t *testing.T) {
{"100-accounts", 100, 100},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got := simulation.RandomAccounts(r, tt.n)
require.Equal(t, tt.want, len(got))
@@ -66,8 +65,6 @@ func TestRandomFees(t *testing.T) {
{"1 coin with 0 amount", sdk.Coins{sdk.NewInt64Coin("ccc", 0)}, true, true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := simulation.RandomFees(r, tt.spendableCoins)
if (err != nil) != tt.wantErr {
-1
View File
@@ -28,7 +28,6 @@ func TestRandSubsetCoins(t *testing.T) {
{"too small amount", rand.New(rand.NewSource(99)), sdk.Coins{sdk.Coin{Denom: "aaa", Amount: math.NewInt(0)}}},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got := simulation.RandSubsetCoins(tt.r, tt.coins)
gotStringRep := got.String()
-2
View File
@@ -33,7 +33,6 @@ func TestSignDocDirectAux(t *testing.T) {
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.sd.ValidateBasic()
@@ -68,7 +67,6 @@ func TestAuxSignerData(t *testing.T) {
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.sd.ValidateBasic()
+1 -3
View File
@@ -33,7 +33,7 @@ func (s *utilsTestSuite) TestTimeFormatAndParse() {
{"2011-01-10T23:10:05.758230235Z", "2011-01-10T23:10:05.758230235", true},
}
for _, tc := range cases {
tc := tc
timeFromRFC, err := time.Parse(time.RFC3339Nano, tc.RFC3339NanoStr)
s.Require().Nil(err)
timeFromSDKFormat, err := time.Parse(sdk.SortableTimeFormat, tc.SDKSortableTimeStr)
@@ -116,8 +116,6 @@ func (s *utilsTestSuite) TestParseTime() {
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
tm, err := sdk.ParseTime(tc.input)
if tc.expectErr {