Skip to content

Commit

Permalink
chore: bump golangci-lint to v1.54.2 (#17538)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Aug 25, 2023
1 parent 03fb7da commit 5839c3a
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ benchmark:
### Linting ###
###############################################################################

golangci_version=v1.53.3
golangci_version=v1.54.2

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
Expand Down
3 changes: 1 addition & 2 deletions crypto/keys/secp256k1/internal/secp256k1/secp256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func generateKeyPair() (pubkey, privkey []byte) {
if err != nil {
panic(err)
}
pubkey = elliptic.Marshal(S256(), key.X, key.Y)

pubkey = elliptic.Marshal(S256(), key.X, key.Y) //nolint:staticcheck // crypto will be refactored soon.
privkey = make([]byte, 32)
blob := key.D.Bytes()
copy(privkey[32-len(blob):], blob)
Expand Down
9 changes: 1 addition & 8 deletions internal/conv/string.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package conv

import (
"reflect"
"unsafe"
)

// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes
// must not be altered after this function is called as it will cause a segmentation fault.
func UnsafeStrToBytes(s string) []byte {
var buf []byte
sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
bufHdr.Data = sHdr.Data
bufHdr.Cap = sHdr.Len
bufHdr.Len = sHdr.Len
return buf
return unsafe.Slice(unsafe.StringData(s), len(s)) // ref https://github.com/golang/go/issues/53003#issuecomment-1140276077
}

// UnsafeBytesToStr is meant to make a zero allocation conversion
Expand Down
16 changes: 0 additions & 16 deletions internal/util.go

This file was deleted.

9 changes: 1 addition & 8 deletions store/internal/conv/string.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package conv

import (
"reflect"
"unsafe"
)

// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes
// must not be altered after this function is called as it will cause a segmentation fault.
func UnsafeStrToBytes(s string) []byte {
var buf []byte
sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
bufHdr.Data = sHdr.Data
bufHdr.Cap = sHdr.Len
bufHdr.Len = sHdr.Len
return buf
return unsafe.Slice(unsafe.StringData(s), len(s)) // ref https://github.com/golang/go/issues/53003#issuecomment-1140276077
}

// UnsafeBytesToStr is meant to make a zero allocation conversion
Expand Down
16 changes: 9 additions & 7 deletions tests/integration/staking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,18 @@ func TestCancelUnbondingDelegation(t *testing.T) {
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
_, err := msgServer.CancelUnbondingDelegation(ctx, &testCase.req)
if testCase.exceptErr {
assert.ErrorContains(t, err, testCase.expErrMsg)
for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
_, err := msgServer.CancelUnbondingDelegation(ctx, &tc.req)
if tc.exceptErr {
assert.ErrorContains(t, err, tc.expErrMsg)
} else {
assert.NilError(t, err)
balanceForNotBondedPool := f.bankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom)
assert.DeepEqual(t, balanceForNotBondedPool, moduleBalance.Sub(testCase.req.Amount))
moduleBalance = moduleBalance.Sub(testCase.req.Amount)
assert.DeepEqual(t, balanceForNotBondedPool, moduleBalance.Sub(tc.req.Amount))
moduleBalance = moduleBalance.Sub(tc.req.Amount)
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions tools/cosmovisor/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
}

for _, tc := range tests {
tc := tc

s.T().Run(tc.name, func(t *testing.T) {
s.setEnv(t, &tc.envVals)
cfg, err := GetConfigFromEnv()
Expand Down
2 changes: 2 additions & 0 deletions tools/cosmovisor/cmd/cosmovisor/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ func (s *InitTestSuite) TestInitializeCosmovisorNegativeValidation() {
}

for _, tc := range tests {
tc := tc

s.T().Run(tc.name, func(t *testing.T) {
s.setEnv(t, &tc.env)
buffer, logger := s.NewCapturingLogger()
Expand Down
2 changes: 2 additions & 0 deletions x/auth/tx/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func getBlocksForTxResults(clientCtx client.Context, resTxs []*coretypes.ResultT
resBlocks := make(map[int64]*coretypes.ResultBlock)

for _, resTx := range resTxs {
resTx := resTx

if _, ok := resBlocks[resTx.Height]; !ok {
resBlock, err := node.Block(context.Background(), &resTx.Height)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/authz/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ func (suite *TestSuite) TestGRPCQueryGranteeGrants() {
}

for _, tc := range testCases {
tc := tc

suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
tc.preRun()
result, err := queryClient.GranteeGrants(gocontext.Background(), &tc.request)
Expand Down
2 changes: 2 additions & 0 deletions x/bank/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
2 changes: 2 additions & 0 deletions x/consensus/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.msg, func() {
s.SetupTest() // reset

Expand Down
2 changes: 2 additions & 0 deletions x/distribution/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
2 changes: 2 additions & 0 deletions x/gov/migrations/v3/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func TestConvertToLegacyTallyResult(t *testing.T) {
},
}
for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
_, err := v3.ConvertToLegacyTallyResult(&tc.tallyResult)
if tc.expErr {
Expand Down
2 changes: 2 additions & 0 deletions x/gov/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
7 changes: 7 additions & 0 deletions x/group/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func TestQueryGroupInfo(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
_, err := fixture.queryClient.GroupInfo(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down Expand Up @@ -157,6 +159,7 @@ func TestQueryGroupPolicyInfo(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
_, err := fixture.queryClient.GroupPolicyInfo(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down Expand Up @@ -197,6 +200,7 @@ func TestQueryGroupMembers(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
resp, err := fixture.queryClient.GroupMembers(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down Expand Up @@ -242,6 +246,7 @@ func TestQueryGroupsByAdmin(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
resp, err := fixture.queryClient.GroupsByAdmin(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down Expand Up @@ -282,6 +287,7 @@ func TestQueryGroupPoliciesByGroup(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
resp, err := fixture.keeper.GroupPoliciesByGroup(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down Expand Up @@ -327,6 +333,7 @@ func TestQueryGroupPoliciesByAdmin(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
resp, err := fixture.keeper.GroupPoliciesByAdmin(fixture.ctx, &tc.req)
if tc.expErrMsg != "" {
Expand Down
2 changes: 2 additions & 0 deletions x/group/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ func (k Keeper) PruneProposals(ctx sdk.Context) error {
return nil
}
for _, proposal := range proposals {
proposal := proposal

err := k.pruneProposal(ctx, proposal.Id)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions x/mint/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
9 changes: 1 addition & 8 deletions x/nft/internal/conv/string.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package conv

import (
"reflect"
"unsafe"
)

// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes
// must not be altered after this function is called as it will cause a segmentation fault.
func UnsafeStrToBytes(s string) []byte {
var buf []byte
sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
bufHdr.Data = sHdr.Data
bufHdr.Cap = sHdr.Len
bufHdr.Len = sHdr.Len
return buf
return unsafe.Slice(unsafe.StringData(s), len(s)) // ref https://github.com/golang/go/issues/53003#issuecomment-1140276077
}

// UnsafeBytesToStr is meant to make a zero allocation conversion
Expand Down
2 changes: 2 additions & 0 deletions x/slashing/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
2 changes: 2 additions & 0 deletions x/staking/simulation/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func TestRandomizedGenState1(t *testing.T) {
}

for _, tt := range tests {
tt := tt

require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
}
9 changes: 1 addition & 8 deletions x/upgrade/internal/conv/string.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package conv

import (
"reflect"
"unsafe"
)

// UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes
// must not be altered after this function is called as it will cause a segmentation fault.
func UnsafeStrToBytes(s string) []byte {
var buf []byte
sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
bufHdr.Data = sHdr.Data
bufHdr.Cap = sHdr.Len
bufHdr.Len = sHdr.Len
return buf
return unsafe.Slice(unsafe.StringData(s), len(s)) // ref https://github.com/golang/go/issues/53003#issuecomment-1140276077
}
2 changes: 2 additions & 0 deletions x/upgrade/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ func (suite *UpgradeTestSuite) TestModuleVersions() {
suite.Require().NoError(err)

for _, tc := range testCases {
tc := tc

suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset

Expand Down

0 comments on commit 5839c3a

Please sign in to comment.