Skip to content

Commit

Permalink
lint: golangci new version fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpioborn committed Nov 4, 2024
1 parent 163e2d2 commit 66e0ee1
Show file tree
Hide file tree
Showing 93 changed files with 96 additions and 147 deletions.
12 changes: 10 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ run:
timeout: 15m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata_pulsar
concurrency: 4

linters:
Expand Down Expand Up @@ -48,7 +47,16 @@ linters:
- revive

issues:
exclude-rules: []
exclude-rules:
- path: (.+)_test.go
linters:
- gosec
- path: suite.go
linters:
- gosec
- path: testutil
linters:
- gosec
max-issues-per-linter: 10000
max-same-issues: 10000

Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v10/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func CreateUpgradeHandler(
configurator module.Configurator,
_ *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, fromVM)
}
}
4 changes: 1 addition & 3 deletions app/upgrades/v9/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ func CreateUpgradeHandler(
configurator module.Configurator,
k *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// https://github.com/cosmos/cosmos-sdk/pull/12363/files
// Set param key table for params module migration
for _, subspace := range k.ParamsKeeper.GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
switch subspace.Name() {
case authtypes.ModuleName:
Expand Down
1 change: 0 additions & 1 deletion cmd/sged/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func TestSampleCMD(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string

Expand Down
1 change: 0 additions & 1 deletion tests/e2e/bet/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (s *E2ETestSuite) TestBetsGRPCHandler() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/bet/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ func (s *E2ETestSuite) TestWagerTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/house/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (s *E2ETestSuite) TestDepositsGRPCHandler() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)
Expand Down Expand Up @@ -93,7 +92,6 @@ func (s *E2ETestSuite) TestGRPCHandler() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)
Expand Down
8 changes: 0 additions & 8 deletions tests/e2e/house/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ func (s *E2ETestSuite) TestDepositTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down Expand Up @@ -472,8 +470,6 @@ func (s *E2ETestSuite) TestDepositWithAuthzTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down Expand Up @@ -791,8 +787,6 @@ func (s *E2ETestSuite) TestWithdrawTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down Expand Up @@ -1000,8 +994,6 @@ func (s *E2ETestSuite) TestWithdrawWithAuthzTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/market/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (s *E2ETestSuite) TestMarketsGRPCHandler() {
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/market/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ func (s *E2ETestSuite) TestMarketAddTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
ticket, err := simapp.CreateJwtTicket(tc.ticketClaims)
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/reward/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ func (s *E2ETestSuite) TestNewCampaignTxCmd() {
}

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

s.Require().NoError(s.network.WaitForNextBlock())
s.Run(tc.name, func() {
clientCtx := val.ClientCtx
Expand Down
2 changes: 1 addition & 1 deletion utils/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (f *ModuleAccFunder) Refund(
// Transfer funds
err := f.bk.SendCoinsFromModuleToAccount(ctx, mAcc, receiverAcc, amt)
if err != nil {
return sdkerrors.Wrapf(f.bankError, err.Error())
return sdkerrors.Wrap(f.bankError, err.Error())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion x/bet/client/cli/query_bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func CmdListBet() *cobra.Command {
Use: "bets",
Short: "get list of bets",
Long: "Get list of bets in paginated response.",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

pageReq, err := client.ReadPageRequest(cmd.Flags())
Expand Down
2 changes: 0 additions & 2 deletions x/bet/client/cli/query_bet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func TestQueryBet(t *testing.T) {
err: status.Error(codes.NotFound, "not found"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
args := []string{
tc.creator,
Expand Down Expand Up @@ -371,7 +370,6 @@ func TestQueryBet(t *testing.T) {
obj: objs,
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
args := []string{
strings.Join(tc.items, ","),
Expand Down
2 changes: 1 addition & 1 deletion x/bet/client/cli/query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func CmdQueryParams() *cobra.Command {
Use: "params",
Short: "shows the parameters of the module",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
Expand Down
1 change: 0 additions & 1 deletion x/bet/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestGetQueryCmd(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string

Expand Down
1 change: 0 additions & 1 deletion x/bet/client/cli/tx_bet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestTXBetCLI(t *testing.T) {
err: fmt.Errorf("any error"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
args := []string{
tc.uid,
Expand Down
1 change: 0 additions & 1 deletion x/bet/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestGetTxCmd(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string

Expand Down
8 changes: 4 additions & 4 deletions x/bet/keeper/grpc_query_bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (k Keeper) Bets(c context.Context, req *types.QueryBetsRequest) (*types.Que

betStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.BetListPrefix)

pageRes, err := query.Paginate(betStore, req.Pagination, func(key, value []byte) error {
pageRes, err := query.Paginate(betStore, req.Pagination, func(_, value []byte) error {
var bet types.Bet
if err := k.cdc.Unmarshal(value, &bet); err != nil {
return err
Expand Down Expand Up @@ -62,7 +62,7 @@ func (k Keeper) BetsByCreator(

betStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.BetListByCreatorPrefix(req.Creator))

pageRes, err := query.Paginate(betStore, req.Pagination, func(key, value []byte) error {
pageRes, err := query.Paginate(betStore, req.Pagination, func(_, value []byte) error {
var bet types.Bet
if err := k.cdc.Unmarshal(value, &bet); err != nil {
return err
Expand Down Expand Up @@ -153,7 +153,7 @@ func (k Keeper) PendingBets(
pageRes, err := query.Paginate(
pendingBetStore,
req.Pagination,
func(key, value []byte) error {
func(_, value []byte) error {
var pendingBet types.PendingBet
if err := k.cdc.Unmarshal(value, &pendingBet); err != nil {
return err
Expand Down Expand Up @@ -197,7 +197,7 @@ func (k Keeper) SettledBetsOfHeight(
pageRes, err := query.Paginate(
settledBetStore,
req.Pagination,
func(key, value []byte) error {
func(_, value []byte) error {
var settledBet types.SettledBet
if err := k.cdc.Unmarshal(value, &settledBet); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/bet/simulation/bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func SimulateMsgWager(
bk types.BankKeeper,
k keeper.Keeper,
) simtypes.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, _ string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)

Expand Down
1 change: 0 additions & 1 deletion x/bet/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func TestDecodeStore(t *testing.T) {
}

for i, tt := range tests {
i, tt := i, tt
t.Run(tt.name, func(t *testing.T) {
switch i {
case len(tests) - 1:
Expand Down
9 changes: 5 additions & 4 deletions x/bet/simulation/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/address"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/spf13/cast"

"github.com/sge-network/sge/x/bet/types"
)
Expand Down Expand Up @@ -36,11 +37,11 @@ func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account)
var authority sdk.AccAddress = address.Module("gov")

params := types.DefaultParams()
params.BatchSettlementCount = uint32(r.Intn(10000))
params.MaxBetByUidQueryCount = uint32(r.Intn(1000))
params.BatchSettlementCount = cast.ToUint32(r.Intn(10000))
params.MaxBetByUidQueryCount = cast.ToUint32(r.Intn(1000))
params.Constraints = types.Constraints{
MinAmount: sdkmath.NewInt(int64(r.Intn(1000))),
Fee: sdkmath.NewInt(int64(r.Intn(99))),
MinAmount: sdkmath.NewInt(cast.ToInt64(r.Intn(1000))),
Fee: sdkmath.NewInt(cast.ToInt64(r.Intn(99))),
}

return &types.MsgUpdateParams{
Expand Down
2 changes: 1 addition & 1 deletion x/house/client/cli/query_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ %s query house deposits
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/house/client/cli/query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func CmdQueryParams() *cobra.Command {
Use: "params",
Short: "shows the parameters of the module",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
Expand Down
1 change: 0 additions & 1 deletion x/house/client/cli/query_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestQueryParams(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string
args = append(args, tc.args...)
Expand Down
1 change: 0 additions & 1 deletion x/house/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestGetQueryCmd(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string
args = append(args, tc.args...)
Expand Down
1 change: 0 additions & 1 deletion x/house/client/cli/tx_deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestTXDepositCLI(t *testing.T) {
err: fmt.Errorf("any error"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
args := []string{
tc.marketUID,
Expand Down
1 change: 0 additions & 1 deletion x/house/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestGetTxCmd(t *testing.T) {
args: []string{},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
var args []string
args = append(args, tc.args...)
Expand Down
4 changes: 2 additions & 2 deletions x/house/client/cli/tx_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func CmdWithdraw() *cobra.Command {

argTicket := args[2]

mode, err := cast.ToInt64E(args[3])
mode, err := cast.ToInt32E(args[3])
if err != nil {
return fmt.Errorf("mode provided must be a non-negative-integer: %v", mode)
}

var argAmountCosmosInt sdkmath.Int
if mode == int64(types.WithdrawalMode_WITHDRAWAL_MODE_PARTIAL) {
if mode == int32(types.WithdrawalMode_WITHDRAWAL_MODE_PARTIAL) {
if len(args) != 5 {
return fmt.Errorf("amount is mandatory for partial mode")
}
Expand Down
1 change: 0 additions & 1 deletion x/house/client/cli/tx_withdraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestTXWithdrawCLI(t *testing.T) {
err: fmt.Errorf("any error"),
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
args := []string{
tc.marketUID,
Expand Down
4 changes: 2 additions & 2 deletions x/house/keeper/grpc_query_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (k Keeper) Deposits(
ctx := sdk.UnwrapSDKContext(c)

store := k.getDepositStore(ctx)
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
pageRes, err := query.Paginate(store, req.Pagination, func(_, value []byte) error {
var deposit types.Deposit
if err := k.cdc.Unmarshal(value, &deposit); err != nil {
return err
Expand Down Expand Up @@ -55,7 +55,7 @@ func (k Keeper) DepositsByAccount(c context.Context,
ctx := sdk.UnwrapSDKContext(c)

store := prefix.NewStore(k.getDepositStore(ctx), types.GetDepositListPrefix(req.Address))
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
pageRes, err := query.Paginate(store, req.Pagination, func(_, value []byte) error {
var deposit types.Deposit
if err := k.cdc.Unmarshal(value, &deposit); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/house/keeper/grpc_query_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (k Keeper) WithdrawalsByAccount(c context.Context,
ctx := sdk.UnwrapSDKContext(c)

store := prefix.NewStore(k.getWithdrawalStore(ctx), types.GetWithdrawalListPrefix(req.Address))
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
pageRes, err := query.Paginate(store, req.Pagination, func(_, value []byte) error {
var withdrawal types.Withdrawal
if err := k.cdc.Unmarshal(value, &withdrawal); err != nil {
return err
Expand Down
Loading

0 comments on commit 66e0ee1

Please sign in to comment.