Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: var-naming linter errors #12135

Merged
merged 9 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135/) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work.
* (cli) [#12127](https://github.com/cosmos/cosmos-sdk/pull/12127) Fix the CLI not always taking into account `--fee-payer` and `--fee-granter` flags.
* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations.
* (baseapp) [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Include antehandler and runMsgs events in SimulateTx.
Expand Down
1 change: 0 additions & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,6 @@ func TestTxGasLimits(t *testing.T) {

return newCtx, nil
})

}

routerOpt := func(bapp *BaseApp) {
Expand Down
2 changes: 1 addition & 1 deletion client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
isAux, _ := flagSet.GetBool(flags.FlagAux)
clientCtx = clientCtx.WithAux(isAux)
if isAux {
// If the user didn't explicity set an --output flag, use JSON by
// If the user didn't explicitly set an --output flag, use JSON by
// default.
if clientCtx.OutputFormat == "" || !flagSet.Changed(cli.OutputFlag) {
clientCtx = clientCtx.WithOutputFormat("json")
Expand Down
4 changes: 2 additions & 2 deletions client/grpc/tmservice/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func GetProtoBlock(ctx context.Context, clientCtx client.Context, height *int64)
if err != nil {
return tmproto.BlockID{}, nil, err
}
protoBlockId := block.BlockID.ToProto()
protoBlockID := block.BlockID.ToProto()

return protoBlockId, protoBlock, nil
return protoBlockID, protoBlock, nil
}
2 changes: 1 addition & 1 deletion client/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (f failingInterfaceRegistry) UnpackAny(any *types.Any, iface interface{}) e
return errCodecNotSet
}

func (f failingInterfaceRegistry) Resolve(typeUrl string) (proto.Message, error) {
func (f failingInterfaceRegistry) Resolve(typeURL string) (proto.Message, error) {
return nil, errCodecNotSet
}

Expand Down
1 change: 0 additions & 1 deletion core/appconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config {
config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface()
err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{})
if err != nil {

return depinject.Error(err)
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestKeyManagementKeyRing(t *testing.T) {
// create some random directory inside the keyring directory to check migrate ignores
// all files other than *.info
newPath := filepath.Join(tempDir, "random")
require.NoError(t, os.Mkdir(newPath, 0755))
require.NoError(t, os.Mkdir(newPath, 0o755))
items, err := os.ReadDir(tempDir)
require.GreaterOrEqual(t, len(items), 2)
keyS, err = kb.List()
Expand Down
8 changes: 4 additions & 4 deletions crypto/keys/secp256k1/internal/secp256k1/curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool {
x3.Mul(x3, x) // x³

x3.Add(x3, BitCurve.B) // x³+B
x3.Mod(x3, BitCurve.P) //(x³+B)%P
x3.Mod(x3, BitCurve.P) // (x³+B)%P

return x3.Cmp(y2) == 0
}
Expand Down Expand Up @@ -222,9 +222,9 @@ func (BitCurve *BitCurve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int,
c := new(big.Int).Mul(b, b) // B²

d := new(big.Int).Add(x, b) // X1+B
d.Mul(d, d) //(X1+B)²
d.Sub(d, a) //(X1+B)²-A
d.Sub(d, c) //(X1+B)²-A-C
d.Mul(d, d) // (X1+B)²
d.Sub(d, a) // (X1+B)²-A
d.Sub(d, c) // (X1+B)²-A-C
d.Mul(d, big.NewInt(2)) // 2*((X1+B)²-A-C)

e := new(big.Int).Mul(big.NewInt(3), a) // 3*A
Expand Down
2 changes: 1 addition & 1 deletion depinject/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (c *debugConfig) enableLogVisualizer() {
func (c *debugConfig) addFileVisualizer(filename string) {
c.visualizers = append(c.visualizers, func(_ string) {
dotStr := c.graph.String()
err := os.WriteFile(filename, []byte(dotStr), 0644)
err := os.WriteFile(filename, []byte(dotStr), 0o644)
if err != nil {
c.logf("Error saving graphviz file %s: %+v", filename, err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion pruning/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// Manager is an abstraction to handle the logic needed for
// determinging when to prune old heights of the store
// determining when to prune old heights of the store
// based on the strategy described by the pruning options.
type Manager struct {
db dbm.DB
Expand Down
3 changes: 2 additions & 1 deletion runtime/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func provideCodecs(moduleBasics map[string]AppModuleBasicWrapper) (
codec.Codec,
*codec.LegacyAmino,
appWrapper,
codec.ProtoCodecMarshaler) {
codec.ProtoCodecMarshaler,
) {
interfaceRegistry := codectypes.NewInterfaceRegistry()
amino := codec.NewLegacyAmino()

Expand Down
6 changes: 4 additions & 2 deletions server/mock/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ func (msg kvstoreTx) Reset() {}
func (msg kvstoreTx) String() string { return "TODO" }
func (msg kvstoreTx) ProtoMessage() {}

var _ sdk.Tx = kvstoreTx{}
var _ sdk.Msg = kvstoreTx{}
var (
_ sdk.Tx = kvstoreTx{}
_ sdk.Msg = kvstoreTx{}
)

func NewTx(key, value string) kvstoreTx {
bytes := fmt.Sprintf("%s=%s", key, value)
Expand Down
2 changes: 0 additions & 2 deletions server/tm_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func makeKeyMigrateCmd() *cobra.Command {
ID: dbctx,
Config: config,
})

if err != nil {
return fmt.Errorf("constructing database handle: %w", err)
}
Expand All @@ -178,7 +177,6 @@ func makeKeyMigrateCmd() *cobra.Command {
if dbctx == "blockstore" {
if err := scmigrate.Migrate(ctx, db); err != nil {
return fmt.Errorf("running seen commit migration: %w", err)

}
}
}
Expand Down
7 changes: 4 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,13 @@ func NewSimApp(
// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder := []string{capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
genesisModuleOrder := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName}
vestingtypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)

Expand Down Expand Up @@ -434,7 +436,6 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig, indexEventsStr []str
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
)

if err != nil {
panic(err)
}
Expand Down
5 changes: 3 additions & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/depinject"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"strconv"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/depinject"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
faddat marked this conversation as resolved.
Show resolved Hide resolved

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
Expand Down
2 changes: 1 addition & 1 deletion snapshots/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
protoio "github.com/gogo/protobuf/io"
)

// WriteExtensionItem writes an item payload for current extention snapshotter.
// WriteExtensionItem writes an item payload for current extension snapshotter.
func WriteExtensionItem(protoWriter protoio.Writer, item []byte) error {
return protoWriter.WriteMsg(&SnapshotItem{
Item: &SnapshotItem_ExtensionPayload{
Expand Down
1 change: 0 additions & 1 deletion store/streaming/constructor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func TestLoadStreamingServices(t *testing.T) {
require.Equal(t, tc.activeStreamersLen, len(activeStreamers))
})
}

}

type streamingAppOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion store/v2alpha1/smt/ics23.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func convertInnerOps(path []byte, sideNodes [][]byte) []*ics23.InnerOp {
Hash: ics23.HashOp_SHA256,
Prefix: []byte{1},
}
if getBitAtFromMSB(path[:], depth-1-i) == 1 {
if getBitAtFromMSB(path, depth-1-i) == 1 {
// right child is on path
op.Prefix = append(op.Prefix, sideNodes[i]...)
} else {
Expand Down
2 changes: 1 addition & 1 deletion types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (coins Coins) SafeSub(coinsB ...Coin) (Coins, bool) {
}

// MulInt performs the scalar multiplication of coins with a `multiplier`
// All coins are multipled by x
// All coins are multiplied by x
// e.g.
// {2A, 3B} * 2 = {4A, 6B}
// {2A} * 0 panics
Expand Down
2 changes: 1 addition & 1 deletion types/kv/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (l *List) remove(e *Element) *Element {
}

// move moves e to next to at and returns e.
// nolint: unparam

func (l *List) move(e, at *Element) *Element {
if e == at {
return e
Expand Down
1 change: 0 additions & 1 deletion x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ func (suite *AnteTestSuite) TestAnteHandlerFees() {

for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.desc), func() {

suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()
tc.malleate()

Expand Down
2 changes: 0 additions & 2 deletions x/auth/ante/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() {
// require that antehandler passes and does not underestimate decorator cost
suite.Require().Nil(err, "ConsumeTxSizeGasDecorator returned error: %v", err)
suite.Require().True(consumedSimGas >= expectedGas, "Simulate mode underestimates gas on AnteDecorator. Simulated cost: %d, expected cost: %d", consumedSimGas, expectedGas)

})
}

}

func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() {
Expand Down
4 changes: 1 addition & 3 deletions x/auth/ante/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

var (
_ GasTx = (*legacytx.StdTx)(nil) // assert StdTx implements GasTx
)
var _ GasTx = (*legacytx.StdTx)(nil) // assert StdTx implements GasTx

// GasTx defines a Tx with a GetGas() method which is needed to use SetUpContextDecorator
type GasTx interface {
Expand Down
1 change: 0 additions & 1 deletion x/auth/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ func ConsumeMultisignatureVerificationGas(
meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey,
params types.Params, accSeq uint64,
) error {

size := sig.BitArray.Count()
sigIndex := 0

Expand Down
4 changes: 2 additions & 2 deletions x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func provideModule(
config *modulev1.Module,
key *store.KVStoreKey,
cdc codec.Codec,
subspace paramtypes.Subspace) authOutputs {

subspace paramtypes.Subspace,
) authOutputs {
maccPerms := map[string][]string{}
for _, permission := range config.ModuleAccountPermissions {
maccPerms[permission.Account] = permission.Permissions
Expand Down
10 changes: 5 additions & 5 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ type wrapper struct {
}

var (
_ authsigning.Tx = &wrapper{}
_ client.TxBuilder = &wrapper{}
_ tx.TipTx = &wrapper{}
_ authsigning.Tx = &wrapper{}
_ client.TxBuilder = &wrapper{}
_ tx.TipTx = &wrapper{}
_ ante.HasExtensionOptionsTx = &wrapper{}
_ ExtensionOptionsTxBuilder = &wrapper{}
_ tx.TipTx = &wrapper{}
_ ExtensionOptionsTxBuilder = &wrapper{}
_ tx.TipTx = &wrapper{}
)

// ExtensionOptionsTxBuilder defines a TxBuilder that can also set extensions.
Expand Down
4 changes: 2 additions & 2 deletions x/auth/tx/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (s txServer) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockWith
"or greater than the current height %d", req.Height, currentHeight)
}

blockId, block, err := tmservice.GetProtoBlock(ctx, s.clientCtx, &req.Height)
blockID, block, err := tmservice.GetProtoBlock(ctx, s.clientCtx, &req.Height)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func (s txServer) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockWith

return &txtypes.GetBlockWithTxsResponse{
Txs: txs,
BlockId: &blockId,
BlockId: &blockID,
Block: block,
Pagination: &pagination.PageResponse{
Total: blockTxsLn,
Expand Down
8 changes: 4 additions & 4 deletions x/authz/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran
_, _, msgType := parseGrantStoreKey(grantKey)
queueItems := queueItem.MsgTypeUrls

for index, typeUrl := range queueItems {
for index, typeURL := range queueItems {
ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue")

if typeUrl == msgType {
if typeURL == msgType {
end := len(queueItem.MsgTypeUrls) - 1
queueItems[index] = queueItems[end]
queueItems = queueItems[:end]
Expand Down Expand Up @@ -363,8 +363,8 @@ func (k Keeper) DequeueAndDeleteExpiredGrants(ctx sdk.Context) error {

store.Delete(iterator.Key())

for _, typeUrl := range queueItem.MsgTypeUrls {
store.Delete(grantStoreKey(grantee, granter, typeUrl))
for _, typeURL := range queueItem.MsgTypeUrls {
store.Delete(grantStoreKey(grantee, granter, typeURL))
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/authz/module/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz/keeper"
)

// BeginBlocker is called at the begining of every block
// BeginBlocker is called at the beginning of every block
func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) {
// delete all the mature grants
if err := keeper.DequeueAndDeleteExpiredGrants(ctx); err != nil {
Expand Down
5 changes: 2 additions & 3 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"time"

modulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
"github.com/cosmos/cosmos-sdk/depinject"
store "github.com/cosmos/cosmos-sdk/store/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/crypto"

"math/rand"
"time"

"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

Expand Down
Loading