Skip to content

Commit

Permalink
chore: ban naked returns (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp authored May 31, 2023
1 parent 79dfc5a commit db15dcb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ linters:
- exportloopref
- gofumpt
- misspell
- nakedret
- revive
- prealloc

linters-settings:
nakedret:
# Ban the use of naked returns because they reduce code readability.
max-func-lines: 0 # override the default: 30
4 changes: 2 additions & 2 deletions x/blob/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
// GasPerBlobByte returns the GasPerBlobByte param
func (k Keeper) GasPerBlobByte(ctx sdk.Context) (res uint32) {
k.paramStore.Get(ctx, types.KeyGasPerBlobByte, &res)
return
return res
}

// GovSquareSizeUpperBound returns the GovMaxSquareSize param
func (k Keeper) GovSquareSizeUpperBound(ctx sdk.Context) (res uint64) {
k.paramStore.Get(ctx, types.KeyGovMaxSquareSize, &res)
return
return res
}
2 changes: 1 addition & 1 deletion x/blob/types/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,5 @@ func QueryAccount(ctx context.Context, conn *grpc.ClientConn, encCfg encoding.Co
}

accNum, seqNum = acc.GetAccountNumber(), acc.GetSequence()
return
return accNum, seqNum, nil
}
2 changes: 1 addition & 1 deletion x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
}

k.cdc.MustUnmarshal(b, &minter)
return
return minter
}

// SetMinter sets the minter.
Expand Down
20 changes: 10 additions & 10 deletions x/qgb/client/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
logger.Debug("getting shares proof from tendermint node")
sharesProofs, err := trpc.ProveShares(ctx, height, startShare, endShare)
if err != nil {
return
return false, err
}

logger.Debug("verifying shares proofs")
Expand All @@ -224,14 +224,14 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
// which the nmt shares proof is verified against.
if !sharesProofs.VerifyProof() {
logger.Info("proofs from shares to data root are invalid")
return
return false, err
}

logger.Info("proofs from shares to data root are valid")

qgbGRPC, err := grpc.Dial(config.CelesGRPC, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return
return false, err
}
defer func(qgbGRPC *grpc.ClientConn) {
err := qgbGRPC.Close()
Expand All @@ -247,7 +247,7 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
&types.QueryDataCommitmentRangeForHeightRequest{Height: height},
)
if err != nil {
return
return false, err
}

logger.Info(
Expand All @@ -265,24 +265,24 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
logger.Debug("getting the data root to commitment inclusion proof")
dcProof, err := trpc.DataRootInclusionProof(ctx, height, resp.DataCommitment.BeginBlock, resp.DataCommitment.EndBlock)
if err != nil {
return
return false, err
}

heightI := int64(height)
block, err := trpc.Block(ctx, &heightI)
if err != nil {
return
return false, err
}

ethClient, err := ethclient.Dial(config.EVMRPC)
if err != nil {
return
return false, err
}
defer ethClient.Close()

qgbWrapper, err := wrapper.NewQuantumGravityBridge(config.ContractAddr, ethClient)
if err != nil {
return
return false, err
}

logger.Info("verifying that the data root was committed to in the QGB contract")
Expand All @@ -295,7 +295,7 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
dcProof.Proof,
)
if err != nil {
return
return false, err
}

if isCommittedTo {
Expand All @@ -304,7 +304,7 @@ func VerifyShares(ctx context.Context, logger tmlog.Logger, config VerifyConfig,
logger.Info("the QGB contract didn't commit to the provided shares")
}

return
return isCommittedTo, nil
}

func VerifyDataRootInclusion(
Expand Down
2 changes: 1 addition & 1 deletion x/qgb/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, paramSpace p
// GetParams returns the parameters from the store
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSpace.GetParamSet(ctx, &params)
return
return params
}

// SetParams sets the parameters in the store
Expand Down
2 changes: 1 addition & 1 deletion x/qgb/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (ibv InternalBridgeValidators) TotalPower() (out uint64) {
for _, v := range ibv {
out += v.Power
}
return
return out
}

// HasDuplicates returns true if there are duplicates in the set.
Expand Down

0 comments on commit db15dcb

Please sign in to comment.