Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jul 3, 2023
1 parent 6eaaf4a commit 387a9c5
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 49 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 9 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ run:
linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- goconst
Expand All @@ -18,7 +17,6 @@ linters:
- gosimple
- govet
- ineffassign
- nakedret
- nolintlint
- staticcheck
- stylecheck
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ benchmark:
###############################################################################

golangci_lint_cmd=golangci-lint
golangci_version=v1.50.1
golangci_version=v1.53.3

lint:
@echo "--> Running linter"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsc/rlp/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crypto/codec/tm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 2 additions & 3 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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()))
Expand Down Expand Up @@ -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()))
Expand Down
4 changes: 2 additions & 2 deletions types/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions x/crosschain/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
5 changes: 4 additions & 1 deletion x/gov/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cli

import (
"fmt"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"strconv"
"strings"

Expand All @@ -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"
Expand Down Expand Up @@ -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)
},
Expand Down
6 changes: 0 additions & 6 deletions x/oracle/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
9 changes: 6 additions & 3 deletions x/params/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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)
},
Expand Down
2 changes: 1 addition & 1 deletion x/staking/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion x/staking/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 387a9c5

Please sign in to comment.