Skip to content

Commit

Permalink
fix: make lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
skyargos committed Nov 6, 2024
1 parent 0c2aa0e commit 4e911ab
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 372 deletions.
2 changes: 1 addition & 1 deletion app/upgrade_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
upgradeName = "v2.12.0"
)

func (app ShentuApp) setUpgradeHandler(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) {
func (app ShentuApp) setUpgradeHandler(_ codec.BinaryCodec, clientKeeper clientkeeper.Keeper) {

Check failure on line 19 in app/upgrade_handler.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

`(ShentuApp).setUpgradeHandler` - `clientKeeper` is unused (unparam)

Check failure on line 19 in app/upgrade_handler.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

`(ShentuApp).setUpgradeHandler` - `clientKeeper` is unused (unparam)
app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
github.com/cosmos/tools/cmd/runsim v1.0.0
github.com/golangci/golangci-lint v1.52.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/magiconair/properties v1.8.7
github.com/ory/dockertest/v3 v3.10.0
github.com/rakyll/statik v0.1.7
Expand Down Expand Up @@ -192,6 +191,7 @@ require (
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
Expand Down
5 changes: 0 additions & 5 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
banksim.RandomizedGenState(simState)
}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// RegisterStoreDecoder performs a no-op.
func (AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
//sdr[types.StoreKey] = simtypes.NewStoreDecoderFuncFromCollectionsSchema(am.keeper.(keeper.BaseKeeper).Schema)
Expand Down
1 change: 0 additions & 1 deletion x/cert/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var (

// AppModuleBasic specifies the app module basics object.
type AppModuleBasic struct {
cdc codec.Codec
}

// NewAppModuleBasic create a new AppModuleBasic object in cert module
Expand Down
3 changes: 3 additions & 0 deletions x/gov/keeper/certifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (k Keeper) IsCertifier(ctx context.Context, addr sdk.AccAddress) (bool, err

func (k Keeper) CertifierVoteIsRequired(ctx context.Context, proposalID uint64) (bool, error) {
proposal, err := k.Proposals.Get(ctx, proposalID)
if err != nil {
return false, err
}
proposalMsgs, err := proposal.GetMsgs()
if err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// validateInitialDeposit validates if initial deposit is greater than or equal to the minimum
// required at the time of proposal submission. This threshold amount is determined by
// the deposit parameters. Returns nil on success, error otherwise.
func (keeper Keeper) validateInitialDeposit(ctx context.Context, params v1.Params, initialDeposit sdk.Coins, expedited bool) error {
func (keeper Keeper) validateInitialDeposit(_ context.Context, params v1.Params, initialDeposit sdk.Coins, expedited bool) error {
if !initialDeposit.IsValid() || initialDeposit.IsAnyNegative() {
return errors.Wrap(sdkerrors.ErrInvalidCoins, initialDeposit.String())
}
Expand Down Expand Up @@ -46,7 +46,7 @@ func (keeper Keeper) validateInitialDeposit(ctx context.Context, params v1.Param
}

// validateDepositDenom validates if the deposit denom is accepted by the governance module.
func (keeper Keeper) validateDepositDenom(ctx context.Context, params v1.Params, depositAmount sdk.Coins) error {
func (keeper Keeper) validateDepositDenom(_ context.Context, params v1.Params, depositAmount sdk.Coins) error {
denoms := []string{}
acceptedDenoms := make(map[string]bool, len(params.MinDeposit))
for _, coin := range params.MinDeposit {
Expand Down
15 changes: 11 additions & 4 deletions x/gov/keeper/tally.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (k Keeper) Tally(ctx context.Context, proposal govtypesv1.Proposal) (passes
}
}

pass, veto := passAndVetoStakeResult(k, ctx, th)
pass, veto := passAndVetoStakeResult(ctx, k, th)

return pass, veto, tallyResults, nil
}
Expand Down Expand Up @@ -203,7 +203,7 @@ func delegatorVoting(ctx context.Context, k Keeper, vote govtypesv1.Vote, valida
})
}

func passAndVetoStakeResult(k Keeper, ctx context.Context, th TallyHelper) (pass bool, veto bool) {
func passAndVetoStakeResult(ctx context.Context, k Keeper, th TallyHelper) (pass bool, veto bool) {
// If there is no staked coins, the proposal fails.
totalBonded, err := k.stakingKeeper.TotalBondedTokens(ctx)
if err != nil {
Expand Down Expand Up @@ -244,7 +244,7 @@ func passAndVetoStakeResult(k Keeper, ctx context.Context, th TallyHelper) (pass

// passAndVetoSecurityResult has two storeKey differences from passAndVetoStakeResult:
// 1. Every certifier has equal voting power (1 head = 1 vote)
func passAndVetoSecurityResult(k Keeper, ctx context.Context, th TallyHelper) (pass bool) {
func passAndVetoSecurityResult(ctx context.Context, k Keeper, th TallyHelper) (pass bool) {
// If no one votes (everyone abstains), proposal fails.
if th.totalVotingPower.IsZero() {
return false
Expand Down Expand Up @@ -287,6 +287,9 @@ func SecurityTally(ctx context.Context, k Keeper, proposal govtypesv1.Proposal)
currVotes = append(currVotes, vote)
return true, nil
})
if err != nil {
return false, false, govtypesv1.TallyResult{}
}

for _, vote := range currVotes {
if len(vote.Options) != 1 {
Expand All @@ -296,6 +299,10 @@ func SecurityTally(ctx context.Context, k Keeper, proposal govtypesv1.Proposal)
totalHeadCounts = totalHeadCounts.Add(math.LegacyNewDec(1))
}
customParams, err := k.GetCustomParams(ctx)
if err != nil {
return false, false, govtypesv1.TallyResult{}
}

tallyResults := govtypesv1.NewTallyResultFromMap(results)

ctally := customParams.CertifierUpdateSecurityVoteTally
Expand All @@ -309,7 +316,7 @@ func SecurityTally(ctx context.Context, k Keeper, proposal govtypesv1.Proposal)
},
results,
}
pass := passAndVetoSecurityResult(k, ctx, th)
pass := passAndVetoSecurityResult(ctx, k, th)

var endVoting, isCertifierUpdateProposal bool
// For CertifierUpdateProposal: If security round didn't pass, continue to
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func (k Keeper) AddVote(ctx context.Context, proposalID uint64, voterAddr sdk.Ac
}

// DeleteVotes deletes all the votes from a given proposalID.
func (keeper Keeper) DeleteVotes(ctx context.Context, proposalID uint64) error {
func (k Keeper) DeleteVotes(ctx context.Context, proposalID uint64) error {
rng := collections.NewPrefixedPairRange[uint64, sdk.AccAddress](proposalID)
err := keeper.Votes.Clear(ctx, rng)
err := k.Votes.Clear(ctx, rng)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions x/gov/types/v1/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func ValidateGenesis(data *GenesisState) error {
// weed out duplicate votes
errGroup.Go(func() error {
type voteKey struct {
//nolint:revive
ProposalId uint64 //nolint:revive // staying consistent with main and v0.47

Check failure on line 92 in x/gov/types/v1/genesis.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

struct field `ProposalId` should be `ProposalID` (golint)

Check failure on line 92 in x/gov/types/v1/genesis.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

struct field `ProposalId` should be `ProposalID` (golint)
Voter string
}
Expand Down
14 changes: 4 additions & 10 deletions x/gov/types/v1alpha1/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package v1alpha1
import (
"fmt"

"cosmossdk.io/math"
yaml "gopkg.in/yaml.v2"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

Expand Down Expand Up @@ -105,19 +104,19 @@ func validateTallyParams(tallyParams govtypesv1beta1.TallyParams) error {
if tallyParams.Quorum.IsNegative() {
return fmt.Errorf("quorom cannot be negative: %s", tallyParams.Quorum)
}
if tallyParams.Quorum.GT(sdk.OneDec()) {
if tallyParams.Quorum.GT(math.LegacyOneDec()) {
return fmt.Errorf("quorom too large: %s", tallyParams)
}
if !tallyParams.Threshold.IsPositive() {
return fmt.Errorf("vote threshold must be positive: %s", tallyParams.Threshold)
}
if tallyParams.Threshold.GT(sdk.OneDec()) {
if tallyParams.Threshold.GT(math.LegacyOneDec()) {
return fmt.Errorf("vote threshold too large: %s", tallyParams)
}
if !tallyParams.VetoThreshold.IsPositive() {
return fmt.Errorf("veto threshold must be positive: %s", tallyParams.Threshold)
}
if tallyParams.VetoThreshold.GT(sdk.OneDec()) {
if tallyParams.VetoThreshold.GT(math.LegacyOneDec()) {
return fmt.Errorf("veto threshold too large: %s", tallyParams)
}

Expand All @@ -136,8 +135,3 @@ func validateVotingParams(i interface{}) error {

return nil
}

// CertVotesKey gets the first part of the cert votes key based on the proposalID
func CertVotesKey(proposalID uint64) []byte {
return append(CertVotesKeyPrefix, govtypes.GetProposalIDBytes(proposalID)...)
}
5 changes: 0 additions & 5 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
//simulation.RandomizedGenState(simState)
}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// RegisterStoreDecoder registers a decoder for mint module's types.
func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
//sdr[minttypes.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
4 changes: 2 additions & 2 deletions x/oracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) error {
if err != nil {
return err
}
toAggTaskIDs := append(tasks, closingTaskIDs...)
for _, taskID := range toAggTaskIDs {
tasks = append(tasks, closingTaskIDs...)
for _, taskID := range tasks {
err := k.Aggregate(ctx, taskID.Tid)
if err != nil {
continue
Expand Down
4 changes: 2 additions & 2 deletions x/oracle/keeper/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ func (k Keeper) SetShortcutTasks(ctx context.Context, tid []byte) error {
if err != nil {
return err
}
taskIDs := append(tasks, types.TaskID{Tid: tid})
bz := k.cdc.MustMarshalLengthPrefixed(&types.TaskIDs{TaskIds: taskIDs})
tasks = append(tasks, types.TaskID{Tid: tid})
bz := k.cdc.MustMarshalLengthPrefixed(&types.TaskIDs{TaskIds: tasks})
return store.Set(types.ShortcutTasksKeyPrefix, bz)
}

Expand Down
15 changes: 2 additions & 13 deletions x/oracle/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var (

// AppModuleBasic specifies the app module basics object.
type AppModuleBasic struct {
cdc codec.Codec
}

// NewAppModuleBasic creates a new AppModuleBasic object in oracle module.
Expand Down Expand Up @@ -165,12 +164,12 @@ func (am AppModule) EndBlock(ctx context.Context) error {
// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of this module.
func (AppModuleBasic) GenerateGenesisState(simState *module.SimulationState) {
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
//simulation.RandomizedGenState(simState)
}

// RegisterStoreDecoder registers a decoder for oracle module.
func (am AppModuleBasic) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
//sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
}

Expand All @@ -179,13 +178,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
return nil
//return simulation.WeightedOperations(simState.AppParams, simState.Cdc, am.keeper, am.keeper.GetAccountKeeper(), am.bankKeeper)
}

// ProposalContents returns functions that generate gov proposals for the module.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

//// RandomizedParams returns functions that generate params for the module.
//func (AppModuleBasic) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
// return simulation.ParamChanges(r)
//}
55 changes: 0 additions & 55 deletions x/oracle/simulation/decoder.go

This file was deleted.

Loading

0 comments on commit 4e911ab

Please sign in to comment.