Skip to content

Commit

Permalink
style: fix lint errors using latest golangci (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanchristo authored Mar 21, 2023
1 parent 7673be6 commit 5c132ff
Show file tree
Hide file tree
Showing 33 changed files with 135 additions and 175 deletions.
2 changes: 1 addition & 1 deletion app/testsuite/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func genesisStateWithValSet(t *testing.T,
type EmptyAppOptions struct{}

// Get implements AppOptions
func (ao EmptyAppOptions) Get(o string) interface{} {
func (ao EmptyAppOptions) Get(_ string) interface{} {
return nil
}

Expand Down
6 changes: 1 addition & 5 deletions x/data/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ func ValidateGenesis(jsonData json.RawMessage) error {
return err
}

if err := moduleDB.ValidateJSON(jsonSource); err != nil {
return err
}

return nil
return moduleDB.ValidateJSON(jsonSource)
}

func validateMsg(m proto.Message) error {
Expand Down
14 changes: 8 additions & 6 deletions x/data/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (a Module) QuerierRoute() string {
return data.ModuleName
}

func (a Module) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier {
func (a Module) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return nil
}

Expand Down Expand Up @@ -97,9 +97,11 @@ func (a Module) RegisterInterfaces(registry types.InterfaceRegistry) {
data.RegisterTypes(registry)
}

//nolint
func (a Module) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) {
data.RegisterQueryHandlerClient(context.Background(), mux, data.NewQueryClient(clientCtx))
err := data.RegisterQueryHandlerClient(context.Background(), mux, data.NewQueryClient(clientCtx))
if err != nil {
panic(err)
}
}

func (a Module) DefaultGenesis(codec.JSONCodec) json.RawMessage {
Expand Down Expand Up @@ -169,17 +171,17 @@ func (Module) GenerateGenesisState(simState *module.SimulationState) {

// ProposalContents returns all the data content functions used to
// simulate proposals.
func (Module) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
func (Module) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// RandomizedParams creates randomized data param changes for the simulator.
func (Module) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
func (Module) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for data module's types
func (Module) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (Module) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {
}

// WeightedOperations returns all the data module operations with their respective weights.
Expand Down
4 changes: 2 additions & 2 deletions x/data/server/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// InitGenesis performs genesis initialization for the data module. It
// returns no validator updates.
func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) {
func (s serverImpl) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, data json.RawMessage) ([]abci.ValidatorUpdate, error) {
jsonSource, err := ormjson.NewRawMessageSource(data)
if err != nil {
return nil, err
Expand All @@ -26,7 +26,7 @@ func (s serverImpl) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
}

// ExportGenesis will dump the data module state into a serializable GenesisState.
func (s serverImpl) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) (json.RawMessage, error) {
func (s serverImpl) ExportGenesis(ctx sdk.Context, _ codec.JSONCodec) (json.RawMessage, error) {
jsonTarget := ormjson.NewRawMessageTarget()
err := s.db.ExportJSON(sdk.WrapSDKContext(ctx), jsonTarget)
if err != nil {
Expand Down
16 changes: 4 additions & 12 deletions x/ecocredit/base/keeper/msg_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,13 @@ func (k Keeper) sendTradable(ctx context.Context, params sendParams) error {
}

// update recipient balance with new tradable amount
if err := k.stateStore.BatchBalanceTable().Save(ctx, &api.BatchBalance{
return k.stateStore.BatchBalanceTable().Save(ctx, &api.BatchBalance{
BatchKey: params.batchKey,
Address: params.recipient,
TradableAmount: newRecipientTradable.String(),
RetiredAmount: recipientBalance.RetiredAmount,
EscrowedAmount: recipientBalance.EscrowedAmount,
}); err != nil {
return err
}

return nil
})
}

func (k Keeper) sendRetired(ctx sdk.Context, params sendParams) error {
Expand Down Expand Up @@ -306,14 +302,10 @@ func (k Keeper) sendRetired(ctx sdk.Context, params sendParams) error {
}

// update batch supply with new tradable and retired amounts
if err := k.stateStore.BatchSupplyTable().Update(ctx, &api.BatchSupply{
return k.stateStore.BatchSupplyTable().Update(ctx, &api.BatchSupply{
BatchKey: params.batchKey,
TradableAmount: newSupplyTradable.String(),
RetiredAmount: newSupplyRetired.String(),
CancelledAmount: batchSupply.CancelledAmount,
}); err != nil {
return err
}

return nil
})
}
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/query_class_creator_allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// ClassCreatorAllowlist queries credit class allowlist setting.
func (k Keeper) ClassCreatorAllowlist(ctx context.Context, request *types.QueryClassCreatorAllowlistRequest) (*types.QueryClassCreatorAllowlistResponse, error) {
func (k Keeper) ClassCreatorAllowlist(ctx context.Context, _ *types.QueryClassCreatorAllowlistRequest) (*types.QueryClassCreatorAllowlistResponse, error) {
result, err := k.stateStore.ClassCreatorAllowlistTable().Get(ctx)
if err != nil {
return nil, regenerrors.ErrInternal.Wrapf("failed to get class creator allowlist: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/base/keeper/query_class_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// ClassFee queries credit class creation fees.
func (k Keeper) ClassFee(ctx context.Context, request *types.QueryClassFeeRequest) (*types.QueryClassFeeResponse, error) {
func (k Keeper) ClassFee(ctx context.Context, _ *types.QueryClassFeeRequest) (*types.QueryClassFeeResponse, error) {
classFee, err := k.stateStore.ClassFeeTable().Get(ctx)
if err != nil {
return nil, regenerrors.ErrInternal.Wrapf("failed to get class fee: %s", err.Error())
Expand Down
4 changes: 2 additions & 2 deletions x/ecocredit/base/simulation/msg_add_class_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func SimulateMsgAddClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.BankKee
Creator: proposerAddr,
}

any, err := codectypes.NewAnyWithValue(&proposalMsg)
anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg)
if err != nil {
return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgAddClassCreator, err.Error()), nil, err
}

msg := &govtypes.MsgSubmitProposal{
Messages: []*codectypes.Any{any},
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Expand Down
4 changes: 2 additions & 2 deletions x/ecocredit/base/simulation/msg_add_credit_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func SimulateMsgAddCreditType(ak ecocredit.AccountKeeper, bk ecocredit.BankKeepe
},
}

any, err := codectypes.NewAnyWithValue(&proposalMsg)
anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg)
if err != nil {
return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgAddCreditType, err.Error()), nil, err
}

msg := &govtypes.MsgSubmitProposal{
Messages: []*codectypes.Any{any},
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Expand Down
4 changes: 2 additions & 2 deletions x/ecocredit/base/simulation/msg_remove_class_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func SimulateMsgRemoveClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.Bank
Creator: proposerAddr,
}

any, err := codectypes.NewAnyWithValue(&proposalMsg)
anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg)
if err != nil {
return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgRemoveClassCreator, err.Error()), nil, err
}

msg := &govtypes.MsgSubmitProposal{
Messages: []*codectypes.Any{any},
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const WeightSetClassCreatorAllowlist = 33

// SimulateMsgSetClassCreatorAllowlist generates a MsgSetClassCreatorAllowlist with random values.
func SimulateMsgSetClassCreatorAllowlist(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, govk ecocredit.GovKeeper,
qryClient types.QueryServer, authority sdk.AccAddress) simtypes.Operation {
_ types.QueryServer, authority sdk.AccAddress) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
Expand All @@ -50,13 +50,13 @@ func SimulateMsgSetClassCreatorAllowlist(ak ecocredit.AccountKeeper, bk ecocredi
Enabled: r.Float32() < 0.3, // 30% chance of allowlist being enabled,
}

any, err := codectypes.NewAnyWithValue(&proposalMsg)
anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg)
if err != nil {
return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgSetClassCreatorAllowlist, err.Error()), nil, err
}

msg := &govtypes.MsgSubmitProposal{
Messages: []*codectypes.Any{any},
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Expand Down
6 changes: 3 additions & 3 deletions x/ecocredit/base/simulation/msg_update_class_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const WeightUpdateClassFee = 33

// SimulateMsgUpdateClassFee generates a MsgToggleClassAllowlist with random values.
func SimulateMsgUpdateClassFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper, govk ecocredit.GovKeeper,
qryClient types.QueryServer, authority sdk.AccAddress) simtypes.Operation {
_ types.QueryServer, authority sdk.AccAddress) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
Expand Down Expand Up @@ -55,13 +55,13 @@ func SimulateMsgUpdateClassFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeep
Fee: &fee,
}

any, err := codectypes.NewAnyWithValue(&proposalMsg)
anyMsg, err := codectypes.NewAnyWithValue(&proposalMsg)
if err != nil {
return simtypes.NoOpMsg(ecocredit.ModuleName, TypeMsgUpdateClassFee, err.Error()), nil, err
}

msg := &govtypes.MsgSubmitProposal{
Messages: []*codectypes.Any{any},
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Expand Down
4 changes: 2 additions & 2 deletions x/ecocredit/base/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func WeightedOperations(
appParams simtypes.AppParams, cdc codec.JSONCodec,
ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper,
govk ecocredit.GovKeeper,
qryClient types.QueryServer, basketQryClient baskettypes.QueryServer,
mktQryClient markettypes.QueryServer, authority sdk.AccAddress) simulation.WeightedOperations {
qryClient types.QueryServer, _ baskettypes.QueryServer,
_ markettypes.QueryServer, authority sdk.AccAddress) simulation.WeightedOperations {

var (
weightMsgCreateClass int
Expand Down
6 changes: 1 addition & 5 deletions x/ecocredit/base/types/v1/msg_bridge_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ func (m *MsgBridgeReceive) ValidateBasic() error {
}

// basic origin tx validation (includes valid ethereum contract address if contract is not empty)
if err := m.OriginTx.Validate(); err != nil {
return err
}

return nil
return m.OriginTx.Validate()
}

// GetSigners returns the expected signers for MsgCancel.
Expand Down
18 changes: 3 additions & 15 deletions x/ecocredit/base/types/v1/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ func (p Params) Validate() error {
return err
}

if err := validateBasketFee(p.BasketFee); err != nil {
return err
}

return nil
return validateBasketFee(p.BasketFee)
}

func validateCreditClassFee(i interface{}) error {
Expand All @@ -65,11 +61,7 @@ func validateCreditClassFee(i interface{}) error {
return sdkerrors.ErrInvalidType.Wrapf("invalid parameter type: %T", i)
}

if err := v.Validate(); err != nil {
return err
}

return nil
return v.Validate()
}

func validateAllowedClassCreators(i interface{}) error {
Expand Down Expand Up @@ -101,11 +93,7 @@ func validateBasketFee(i interface{}) error {
return sdkerrors.ErrInvalidType.Wrapf("invalid parameter type: %T", i)
}

if err := v.Validate(); err != nil {
return err
}

return nil
return v.Validate()
}

// NewParams creates a new Params object.
Expand Down
6 changes: 2 additions & 4 deletions x/ecocredit/basket/keeper/msg_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ func (k Keeper) transferToBasket(ctx context.Context, sender sdk.AccAddress, amt
}
bal.Balance = newBalance.String()
}
if err = k.stateStore.BasketBalanceTable().Save(ctx, bal); err != nil {
return err
}
return nil

return k.stateStore.BasketBalanceTable().Save(ctx, bal)
}
58 changes: 29 additions & 29 deletions x/ecocredit/basket/keeper/msg_take.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,39 +141,39 @@ func (k Keeper) Take(ctx context.Context, msg *types.MsgTake) (*types.MsgTakeRes
}

break
} else {
credits = append(credits, &types.BasketCredit{
BatchDenom: basketBalance.BatchDenom,
Amount: balance.String(),
})
}

err = k.addCreditBalance(
ctx,
acct,
basketBalance.BatchDenom,
balance,
retire,
retirementJurisdiction,
msg.RetirementReason,
)
if err != nil {
return nil, err
}
credits = append(credits, &types.BasketCredit{
BatchDenom: basketBalance.BatchDenom,
Amount: balance.String(),
})

err = k.stateStore.BasketBalanceTable().Delete(ctx, basketBalance)
if err != nil {
return nil, err
}
err = k.addCreditBalance(
ctx,
acct,
basketBalance.BatchDenom,
balance,
retire,
retirementJurisdiction,
msg.RetirementReason,
)
if err != nil {
return nil, err
}

// basket balance == credits needed
if cmp == 0 {
break
}
err = k.stateStore.BasketBalanceTable().Delete(ctx, basketBalance)
if err != nil {
return nil, err
}

amountCreditsNeeded, err = amountCreditsNeeded.Sub(balance)
if err != nil {
return nil, err
}
// basket balance == credits needed
if cmp == 0 {
break
}

amountCreditsNeeded, err = amountCreditsNeeded.Sub(balance)
if err != nil {
return nil, err
}

sdkCtx.GasMeter().ConsumeGas(ecocredit.GasCostPerIteration, "ecocredit/basket/MsgTake balance iteration")
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/basket/keeper/query_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
types "github.com/regen-network/regen-ledger/x/ecocredit/v3/basket/types/v1"
)

func (k Keeper) BasketFee(ctx context.Context, req *types.QueryBasketFeeRequest) (*types.QueryBasketFeeResponse, error) {
func (k Keeper) BasketFee(ctx context.Context, _ *types.QueryBasketFeeRequest) (*types.QueryBasketFeeResponse, error) {
basketFee, err := k.stateStore.BasketFeeTable().Get(ctx)
if err != nil {
return nil, regenerrors.ErrInternal.Wrap(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion x/ecocredit/basket/simulation/msg_take.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var TypeMsgTake = types.MsgTake{}.Route()

// SimulateMsgTake generates a Basket/MsgTake with random values.
func SimulateMsgTake(ak ecocredit.AccountKeeper, bk ecocredit.BankKeeper,
qryClient basetypes.QueryServer, bsktQryClient types.QueryServer) simtypes.Operation {
_ basetypes.QueryServer, bsktQryClient types.QueryServer) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
Expand Down
Loading

0 comments on commit 5c132ff

Please sign in to comment.