Add lint config and fix lint errors (#7)

* Add config file for linter

* Fix lint errors

* Fix gofumpt errors

* Fix pre-allocate slices lint error

* Remove unused lint rule

* Disable style check ID error

* Add gomodguard section in yml file

* Remove trailing white spaces

* Remove unnecessary comments

---------

Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Isha Venikar
2024-07-16 09:25:39 +05:30
committed by nabarun
co-authored by prathamesh
parent 8c14d578f7
commit f23f691646
22 changed files with 199 additions and 53 deletions
+4 -2
View File
@@ -71,8 +71,10 @@ func NewKeeper(
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
Params: collections.NewItem(sb, bondtypes.ParamsPrefix, "params", codec.CollValue[bondtypes.Params](cdc)),
Bonds: collections.NewIndexedMap(sb, bondtypes.BondsPrefix, "bonds", collections.StringKey, codec.CollValue[bondtypes.Bond](cdc), newBondIndexes(sb)),
usageKeepers: nil,
Bonds: collections.NewIndexedMap(
sb, bondtypes.BondsPrefix, "bonds", collections.StringKey, codec.CollValue[bondtypes.Bond](cdc), newBondIndexes(sb),
),
usageKeepers: nil,
}
schema, err := sb.Build()
+14 -4
View File
@@ -63,12 +63,17 @@ func (qs queryServer) GetBondById(c context.Context, req *bondtypes.QueryGetBond
}
// GetBondsByOwner implements bond.QueryServer.
func (qs queryServer) GetBondsByOwner(c context.Context, req *bondtypes.QueryGetBondsByOwnerRequest) (*bondtypes.QueryGetBondsByOwnerResponse, error) {
func (qs queryServer) GetBondsByOwner(
c context.Context,
req *bondtypes.QueryGetBondsByOwnerRequest,
) (*bondtypes.QueryGetBondsByOwnerResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
owner := req.GetOwner()
if len(owner) == 0 {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "owner required")
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest,
"owner required",
)
}
bonds, err := qs.k.GetBondsByOwner(ctx, owner)
@@ -80,9 +85,14 @@ func (qs queryServer) GetBondsByOwner(c context.Context, req *bondtypes.QueryGet
}
// GetBondModuleBalance implements bond.QueryServer.
func (qs queryServer) GetBondModuleBalance(c context.Context, _ *bondtypes.QueryGetBondModuleBalanceRequest) (*bondtypes.QueryGetBondModuleBalanceResponse, error) {
func (qs queryServer) GetBondModuleBalance(
c context.Context,
_ *bondtypes.QueryGetBondModuleBalanceRequest,
) (*bondtypes.QueryGetBondModuleBalanceResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
balances := qs.k.GetBondModuleBalances(ctx)
return &bondtypes.QueryGetBondModuleBalanceResponse{Balance: balances}, nil
return &bondtypes.QueryGetBondModuleBalanceResponse{
Balance: balances,
}, nil
}
+3 -5
View File
@@ -4,7 +4,6 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"golang.org/x/exp/maps"
"github.com/cosmos/cosmos-sdk/codec"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
@@ -60,15 +59,14 @@ func InvokeSetBondHooks(
keeper *keeper.Keeper,
bondHooks map[string]bond.BondHooksWrapper,
) error {
// all arguments to invokers are optional
// All arguments to invokers are optional
if keeper == nil || config == nil {
return nil
}
var usageKeepers []bond.BondUsageKeeper
usageKeepers := make([]bond.BondUsageKeeper, 0, len(bondHooks))
for _, modName := range maps.Keys(bondHooks) {
hook := bondHooks[modName]
for _, hook := range bondHooks {
usageKeepers = append(usageKeepers, hook)
}
+1 -3
View File
@@ -6,9 +6,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var (
_ sdk.Msg = &MsgCreateBond{}
)
var _ sdk.Msg = &MsgCreateBond{}
// NewMsgCreateBond is the constructor function for MsgCreateBond.
func NewMsgCreateBond(coins sdk.Coins, signer sdk.AccAddress) MsgCreateBond {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Default parameter values.
// DefaultMaxBondAmountTokens are the default parameter values.
var DefaultMaxBondAmountTokens = sdkmath.NewInt(100000000000)
func NewParams(maxBondAmount sdk.Coin) Params {