diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cb01e03fb7..e051398f35 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,17 +10,16 @@ permissions: # Optional: allow read access to pull request. Use with `only-new-issues` option. # pull-requests: read jobs: -# golangci: -# name: golangci-lint -# runs-on: ubuntu-latest -# steps: -# - uses: actions/setup-go@v3 -# with: -# go-version: 1.19.8 -# - uses: actions/checkout@v3 -# - name: golangci-lint -# uses: golangci/golangci-lint-action@v3 -# with: -# # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version -# version: v1.50.1 - + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.20.5 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v1.53.3 diff --git a/.golangci.yml b/.golangci.yml index 62beeaef40..a9c005e171 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,7 +8,6 @@ run: linters: disable-all: true enable: - - depguard - dogsled - exportloopref - goconst @@ -18,7 +17,6 @@ linters: - gosimple - govet - ineffassign - - nakedret - nolintlint - staticcheck - stylecheck @@ -39,6 +37,15 @@ issues: - text: "ST1016:" linters: - stylecheck + - text: "SA1019: errors" + linters: + - staticcheck + - text: "SA1019: sdkerr" + linters: + - staticcheck + - text: "SA1019: sdkerrors" + linters: + - staticcheck - path: "migrations" text: "SA1019:" linters: diff --git a/Makefile b/Makefile index 42273bb038..d1ff539237 100644 --- a/Makefile +++ b/Makefile @@ -348,7 +348,7 @@ benchmark: ############################################################################### golangci_lint_cmd=golangci-lint -golangci_version=v1.50.1 +golangci_version=v1.53.3 lint: @echo "--> Running linter" diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 3c7882669d..c77e94d980 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -51,7 +51,7 @@ const ( var _ abci.Application = (*BaseApp)(nil) // BaseApp reflects the ABCI application implementation. -type BaseApp struct { // nolint: maligned +type BaseApp struct { //nolint: maligned // initialized on creation logger log.Logger name string // application name from abci.Info diff --git a/bsc/rlp/encode.go b/bsc/rlp/encode.go index d6e5a73393..0f89d07d37 100644 --- a/bsc/rlp/encode.go +++ b/bsc/rlp/encode.go @@ -398,7 +398,7 @@ func writeBigIntNoPtr(val reflect.Value, w *encbuf) error { } func writeBigInt(i *big.Int, w *encbuf) error { - if cmp := i.Cmp(big0); cmp == -1 { //nolint:all + if cmp := i.Cmp(big0); cmp == -1 { return fmt.Errorf("rlp: cannot encode negative *big.Int") } else if cmp == 0 { w.str = append(w.str, 0x80) diff --git a/crypto/codec/tm.go b/crypto/codec/tm.go index c07e687fcc..873c1dcde5 100644 --- a/crypto/codec/tm.go +++ b/crypto/codec/tm.go @@ -6,10 +6,10 @@ import ( tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1" ) // FromTmProtoPublicKey converts a TM's tmprotocrypto.PublicKey into our own PubKey. diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 9f7cffe353..7e02b7f8d6 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -748,7 +748,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { continue } - if err := os.WriteFile(dir+"/keyhash", passwordHash, 0o555); err != nil { + if err := os.WriteFile(dir+"/keyhash", passwordHash, 0o555); err != nil { //nolint:gosec return "", err } diff --git a/server/start.go b/server/start.go index d5ec954801..011c93e060 100644 --- a/server/start.go +++ b/server/start.go @@ -12,7 +12,6 @@ import ( "time" db "github.com/cometbft/cometbft-db" - dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/abci/server" tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" "github.com/cometbft/cometbft/node" @@ -620,8 +619,8 @@ func wrapCPUProfile(ctx *Context, callback func() error) error { // - state // - tx_index // - evidence -func makeDBOptions(ctx *Context) map[string]*dbm.NewDatabaseOption { - return map[string]*dbm.NewDatabaseOption{ +func makeDBOptions(ctx *Context) map[string]*db.NewDatabaseOption { + return map[string]*db.NewDatabaseOption{ "blockstore": { Cache: ctx.Viper.GetInt(FlagDBCache) * ctx.Viper.GetInt(FlagDBBlockStorePercentage) / 100 * opt.MiB, Handles: ctx.Viper.GetInt(FlagDBFDLimit) * ctx.Viper.GetInt(FlagDBBlockStorePercentage) / 100, diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 70105e7cd1..a8b30d531d 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -18,6 +18,7 @@ import ( "github.com/pkg/errors" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/store/cache" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/dbadapter" "github.com/cosmos/cosmos-sdk/store/iavl" @@ -29,7 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/transient" "github.com/cosmos/cosmos-sdk/store/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/store/cache" ) const ( diff --git a/types/address.go b/types/address.go index 49862231ca..ab38985771 100644 --- a/types/address.go +++ b/types/address.go @@ -326,8 +326,8 @@ func (aa AccAddress) String() string { } // Format implements the fmt.Formatter interface. -//nolint: errcheck func (aa AccAddress) Format(s fmt.State, verb rune) { + //nolint: errcheck switch verb { case 's': s.Write([]byte(aa.String())) @@ -464,8 +464,8 @@ func (va ValAddress) String() string { } // Format implements the fmt.Formatter interface. -//nolint: errcheck func (va ValAddress) Format(s fmt.State, verb rune) { + //nolint: errcheck switch verb { case 's': s.Write([]byte(va.String())) @@ -631,8 +631,8 @@ func MustBech32ifyAddressBytes(prefix string, bs []byte) string { } // Format implements the fmt.Formatter interface. -//nolint: errcheck func (ca ConsAddress) Format(s fmt.State, verb rune) { + //nolint: errcheck switch verb { case 's': s.Write([]byte(ca.String())) diff --git a/types/module/simulation.go b/types/module/simulation.go index ec9fa52d7a..dccb5a7fd8 100644 --- a/types/module/simulation.go +++ b/types/module/simulation.go @@ -153,7 +153,7 @@ type SimulationState struct { GenTimestamp time.Time // genesis timestamp UnbondTime time.Duration // staking unbond time stored to use it as the slashing maximum evidence duration LegacyParamChange []simulation.LegacyParamChange // simulated parameter changes from modules - //nolint:staticcheck - LegacyProposalContents []simulation.WeightedProposalContent // proposal content generator functions with their default weight and app sim key + + LegacyProposalContents []simulation.WeightedProposalContent //nolint:staticcheck // proposal content generator functions with their default weight and app sim key ProposalMsgs []simulation.WeightedProposalMsg // proposal msg generator functions with their default weight and app sim key } diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index aa4ac527ad..7765415ab7 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -60,7 +60,7 @@ type AccountKeeper struct { // The prototypical AccountI constructor. proto func() types.AccountI - addressCdc address.Codec + addressCdc address.Codec //nolint:unused // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. diff --git a/x/crosschain/module.go b/x/crosschain/module.go index 9c059ce4d8..6361f1ef02 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -120,12 +120,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } -// ProposalContents returns all the params content functions used to -// simulate governance proposals. -func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RegisterStoreDecoder doesn't register any type. func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 36ed55fdbb..f1c9407377 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "strconv" "strings" @@ -13,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" @@ -207,6 +207,9 @@ $ %s tx gov submit-legacy-proposal --title="Test Proposal" --description="My awe return fmt.Errorf("invalid message: %w", err) } msg, err := v1.NewMsgSubmitProposal([]sdk.Msg{contentMsg}, amount, clientCtx.GetFromAddress().String(), "", proposal.Title, proposal.Description) + if err != nil { + return fmt.Errorf("invalid message: %w", err) + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/oracle/module.go b/x/oracle/module.go index c74c0dc83d..7003e17e16 100644 --- a/x/oracle/module.go +++ b/x/oracle/module.go @@ -121,12 +121,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } -// ProposalContents returns all the params content functions used to -// simulate governance proposals. -func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // RegisterStoreDecoder doesn't register any type. func (AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {} diff --git a/x/params/client/cli/tx.go b/x/params/client/cli/tx.go index 039275e990..ba87be761a 100644 --- a/x/params/client/cli/tx.go +++ b/x/params/client/cli/tx.go @@ -2,9 +2,6 @@ package cli import ( "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "strings" "github.com/spf13/cobra" @@ -13,6 +10,9 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" ) @@ -84,6 +84,9 @@ Where proposal.json contains: return err } msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{contentMsg}, deposit, from.String(), "", content.Title, content.Description) + if err != nil { + return err + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/staking/client/cli/flags.go b/x/staking/client/cli/flags.go index 22494853fe..2560a36f73 100644 --- a/x/staking/client/cli/flags.go +++ b/x/staking/client/cli/flags.go @@ -126,7 +126,7 @@ func flagSetCommissionUpdate() *flag.FlagSet { return fs } -func flagSetDescriptionCreate() *flag.FlagSet { +func flagSetDescriptionCreate() *flag.FlagSet { //nolint:unused fs := flag.NewFlagSet("", flag.ContinueOnError) fs.String(FlagMoniker, "", "The validator's name") diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 45f9044b8e..1c6839ab15 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -92,7 +92,7 @@ func (msg MsgCreateValidator) ValidateBasic() error { if err != nil { return sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) } - if !sdk.AccAddress(valAddr).Equals(delAddr) { + if !valAddr.Equals(delAddr) { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "validator address is invalid") }