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

linter autofixes #23961

Open
wants to merge 2 commits into
base: release/v0.53.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- typecheck
- unconvert
- unused
- usetesting

issues:
exclude-dirs:
Expand Down Expand Up @@ -118,6 +119,5 @@ linters-settings:
disabled-checks:
- regexpMust
- appendAssign
- ifElseChain
unused:
local-variables-are-used: false
local-variables-are-used: false
1 change: 0 additions & 1 deletion baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,6 @@ func TestABCI_GetBlockRetentionHeight(t *testing.T) {
}

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

tc.bapp.SetParamStore(&paramStore{db: dbm.NewMemDB()})
_, err = tc.bapp.InitChain(&abci.RequestInitChain{
Expand Down
4 changes: 2 additions & 2 deletions baseapp/abci_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"bytes"
"context"
"fmt"
"slices" //nolint: gci // ignore this line for this linter
"slices"

"github.com/cockroachdb/errors"
abci "github.com/cometbft/cometbft/abci/types"
cryptoenc "github.com/cometbft/cometbft/crypto/encoding"
cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
protoio "github.com/cosmos/gogoproto/io"
"github.com/cosmos/gogoproto/proto" //nolint: gci // ignore this line for this linter
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/core/comet"

Expand Down
2 changes: 1 addition & 1 deletion baseapp/internal/protocompat/protocompat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"reflect"

gogoproto "github.com/cosmos/gogoproto/proto"
"github.com/golang/protobuf/proto" // nolint: staticcheck // needed because gogoproto.Merge does not work consistently. See NOTE: comments.
"github.com/golang/protobuf/proto"

Check failure on line 9 in baseapp/internal/protocompat/protocompat.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead. (staticcheck)
"google.golang.org/grpc"
proto2 "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
Expand Down
1 change: 0 additions & 1 deletion baseapp/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) {
}, abci.ResponseOfferSnapshot_REJECT},
}
for name, tc := range testCases {
tc := tc
t.Run(name, func(t *testing.T) {
resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: tc.snapshot})
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
})))
}

grpcClient, err := grpc.Dial(grpcURI, dialOpts...) // nolint:staticcheck // grpc.Dial is deprecated but we still use it
grpcClient, err := grpc.Dial(grpcURI, dialOpts...)

Check failure on line 171 in client/cmd.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA1019: grpc.Dial is deprecated: use NewClient instead. Will be supported throughout 1.x. (staticcheck)
if err != nil {
return Context{}, err
}
Expand Down
2 changes: 0 additions & 2 deletions client/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func TestSetCmdClientContextHandler(t *testing.T) {
}

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

t.Run(tc.name, func(t *testing.T) {
cmd := newCmd()
_ = testutil.ApplyMockIODiscardOutErr(cmd)
Expand Down
8 changes: 4 additions & 4 deletions client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) {
// when client.toml does not exist create and init with default values
if _, err := os.Stat(configFilePath); os.IsNotExist(err) {
if err := os.MkdirAll(configPath, os.ModePerm); err != nil {
return ctx, fmt.Errorf("couldn't make client config: %v", err)
return ctx, fmt.Errorf("couldn't make client config: %w", err)
}

if ctx.ChainID != "" {
conf.ChainID = ctx.ChainID // chain-id will be written to the client.toml while initiating the chain.
}

if err := writeConfigToFile(configFilePath, conf); err != nil {
return ctx, fmt.Errorf("could not write client config to the file: %v", err)
return ctx, fmt.Errorf("could not write client config to the file: %w", err)
}
}

conf, err := getClientConfig(configPath, ctx.Viper)
if err != nil {
return ctx, fmt.Errorf("couldn't get client config: %v", err)
return ctx, fmt.Errorf("couldn't get client config: %w", err)
}
// we need to update KeyringDir field on Client Context first cause it is used in NewKeyringFromBackend
ctx = ctx.WithOutputFormat(conf.Output).
Expand All @@ -106,7 +106,7 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) {
// https://github.com/cosmos/cosmos-sdk/issues/8986
client, err := client.NewClientFromNode(conf.Node)
if err != nil {
return ctx, fmt.Errorf("couldn't get client from nodeURI: %v", err)
return ctx, fmt.Errorf("couldn't get client from nodeURI: %w", err)
}

ctx = ctx.WithNodeURI(conf.Node).
Expand Down
1 change: 0 additions & 1 deletion client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestConfigCmdEnvFlag(t *testing.T) {
}

for _, tc := range tt {
tc := tc
t.Run(tc.name, func(t *testing.T) {
testCmd := &cobra.Command{
Use: "test",
Expand Down
12 changes: 6 additions & 6 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ func getPubKeyFromRawString(pkstr, keytype string) (cryptotypes.PubKey, error) {
}
}

pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr)
if err == nil {
return pk, nil
}

pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr)
if err == nil {
return pk, nil
}

pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr)
if err == nil {
return pk, nil
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func PubkeyRawCmd() *cobra.Command {
var consensusPub string
edPK, ok := pk.(*ed25519.PubKey)
if ok && pubkeyType == ed {
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK) //nolint:staticcheck // we do old keys, they're keys after all.
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK)
if err != nil {
return err
}
Expand All @@ -219,11 +219,11 @@ func PubkeyRawCmd() *cobra.Command {
if err != nil {
return err
}
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk) //nolint:staticcheck // we do old keys, they're keys after all.
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk)
if err != nil {
return err
}
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk) //nolint:staticcheck // we do old keys, they're keys after all.
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk)
if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions client/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ func TestParseGasSetting(t *testing.T) {
}

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

t.Run(tc.name, func(t *testing.T) {
gs, err := flags.ParseGasSetting(tc.input)

Expand Down
2 changes: 1 addition & 1 deletion client/grpc/cmtservice/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{

// NewCometBFTCommands is a fake `appmodule.Module` to be considered as a module
// and be added in AutoCLI.
func NewCometBFTCommands() *cometModule { //nolint:revive // fake module and limiting import of core
func NewCometBFTCommands() *cometModule {
return &cometModule{}
}

Expand Down
2 changes: 1 addition & 1 deletion client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo
// print mnemonic unless requested not to.
if showMnemonic {
if _, err := fmt.Fprintf(cmd.ErrOrStderr(), "\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n", mnemonic); err != nil {
return fmt.Errorf("failed to print mnemonic: %v", err)
return fmt.Errorf("failed to print mnemonic: %w", err)
}
}
case flags.OutputFormatJSON:
Expand Down
1 change: 0 additions & 1 deletion client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func Test_runAddCmdLedgerDryRun(t *testing.T) {
}

for _, tt := range testData {
tt := tt
t.Run(tt.name, func(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands().PersistentFlags())
Expand Down
1 change: 0 additions & 1 deletion client/keys/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func Test_runAddCmdDryRun(t *testing.T) {
},
}
for _, tt := range testData {
tt := tt
t.Run(tt.name, func(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands().PersistentFlags())
Expand Down
1 change: 0 additions & 1 deletion client/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func Test_runListCmd(t *testing.T) {
{"keybase: w/key", kbHome2, false},
}
for _, tt := range testData {
tt := tt
t.Run(tt.name, func(t *testing.T) {
cmd.SetArgs([]string{
fmt.Sprintf("--%s=%s", flags.FlagKeyringDir, tt.kbDir),
Expand Down
1 change: 0 additions & 1 deletion client/keys/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestParseKey(t *testing.T) {
{"hex", []string{hexstr}, false},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), config, tt.args) != nil)
})
Expand Down
4 changes: 2 additions & 2 deletions client/keys/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
if len(args) == 1 {
k, err = fetchKey(clientCtx.Keyring, args[0])
if err != nil {
return fmt.Errorf("%s is not a valid name or address: %v", args[0], err)
return fmt.Errorf("%s is not a valid name or address: %w", args[0], err)
}
} else {
pks := make([]cryptotypes.PubKey, len(args))
for i, keyref := range args {
k, err := fetchKey(clientCtx.Keyring, keyref)
if err != nil {
return fmt.Errorf("%s is not a valid name or address: %v", keyref, err)
return fmt.Errorf("%s is not a valid name or address: %w", keyref, err)
}
key, err := k.GetPubKey()
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func Test_validateMultisigThreshold(t *testing.T) {
{"1-2", args{2, 1}, true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if err := validateMultisigThreshold(tt.args.k, tt.args.nKeys); (err != nil) != tt.wantErr {
t.Errorf("validateMultisigThreshold() error = %v, wantErr %v", err, tt.wantErr)
Expand All @@ -212,7 +211,6 @@ func Test_getBechKeyOut(t *testing.T) {
{"cons", args{sdk.PrefixConsensus}, MkConsKeyOutput, false},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := getBechKeyOut(tt.args.bechPrefix)
if tt.wantErr {
Expand Down
1 change: 0 additions & 1 deletion client/tx/aux_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func TestAuxTxBuilder(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
b = tx.NewAuxTxBuilder()
err := tc.malleate()
Expand Down
2 changes: 0 additions & 2 deletions codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func TestAminoCodecMarshalJSONIndent(t *testing.T) {
}

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

t.Run(tc.name, func(t *testing.T) {
cdc := codec.NewAminoCodec(createTestCodec())
bz, err := cdc.MarshalJSONIndent(tc.input, "", " ")
Expand Down
2 changes: 1 addition & 1 deletion codec/codec_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func testMarshaling(t *testing.T, cdc interface {
}

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

m1 := mustMarshaler{cdc.Marshal, cdc.MustMarshal, cdc.Unmarshal, cdc.MustUnmarshal}
m2 := mustMarshaler{cdc.MarshalLengthPrefixed, cdc.MustMarshalLengthPrefixed, cdc.UnmarshalLengthPrefixed, cdc.MustUnmarshalLengthPrefixed}
m3 := mustMarshaler{
Expand Down
1 change: 0 additions & 1 deletion codec/types/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// nolint:revive // XXX is reqired for proto compatibility
type Any struct {
// A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. This string must contain at least
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (d Dog) Greet() string { return d.Name }
func (d *Dog) Reset() { d.Name = "" }
func (d *Dog) String() string { return d.Name }
func (d *Dog) ProtoMessage() {}
func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive // XXX_ prefix is required
func (d *Dog) XXX_MessageName() string { return "tests/dog" }

type Animal interface {
Greet() string
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ proto.Message = (*errOnMarshal)(nil)

var errAlways = fmt.Errorf("always erroring")

func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive // XXX_ prefix is intentional
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return nil, errAlways
}

Expand Down
2 changes: 1 addition & 1 deletion codec/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
func (dog FakeDog) Reset() {}
func (dog FakeDog) String() string { return "fakedog" }
func (dog FakeDog) ProtoMessage() {}
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive // XXX_ prefix is intentional
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) }
func (dog FakeDog) Greet() string { return "fakedog" }

func TestRegister(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion codec/unknownproto/unit_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestWireTypeToString(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(fmt.Sprintf("wireType=%d", tt.typ), func(t *testing.T) {
if g, w := wireTypeToString(tt.typ), tt.want; g != w {
t.Fatalf("Mismatch:\nGot: %q\nWant: %q\n", g, w)
Expand Down
4 changes: 0 additions & 4 deletions codec/unknownproto/unknown_fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func TestRejectUnknownFieldsRepeated(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
protoBlob, err := proto.Marshal(tt.in)
if err != nil {
Expand Down Expand Up @@ -280,7 +279,6 @@ func TestRejectUnknownFields_allowUnknownNonCriticals(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
blob, err := proto.Marshal(tt.in)
if err != nil {
Expand Down Expand Up @@ -483,7 +481,6 @@ func TestRejectUnknownFieldsNested(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
protoBlob, err := proto.Marshal(tt.in)
if err != nil {
Expand Down Expand Up @@ -634,7 +631,6 @@ func TestRejectUnknownFieldsFlat(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
blob, err := proto.Marshal(tt.in)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions crypto/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func UnarmorInfoBytes(armorStr string) ([]byte, error) {
func UnarmorPubKeyBytes(armorStr string) (bz []byte, algo string, err error) {
bz, header, err := unarmorBytes(armorStr, blockTypePubKey)
if err != nil {
return nil, "", fmt.Errorf("couldn't unarmor bytes: %v", err)
return nil, "", fmt.Errorf("couldn't unarmor bytes: %w", err)
}

switch header[headerVersion] {
Expand Down Expand Up @@ -261,15 +261,15 @@ func EncodeArmor(blockType string, headers map[string]string, data []byte) strin
buf := new(bytes.Buffer)
w, err := armor.Encode(buf, blockType, headers)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
_, err = w.Write(data)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
err = w.Close()
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %s", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
return buf.String()
}
Expand Down
Loading
Loading