Skip to content

Commit

Permalink
lint: enable unused in golangci-lint (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn authored Jul 4, 2022
1 parent 8f018a6 commit aca83eb
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 66 deletions.
9 changes: 8 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ linters:
- typecheck
- unconvert
# - unparam <- looks for unused parameters (enable later)
# - unused <- looks for unused variables (enable later)
- unused # looks for unused variables, subset of staticcheck binary.
# - varcheck <- later
# - varnamelen <- disabled because defies idiom
# - wastedassign
Expand All @@ -95,5 +95,12 @@ issues:
- path: client/docs
linters:
- all
- path: x/gamm/pool-models/stableswap
linters:
# Stableswap is in development.
# We should re-enable deadcode and unused linting
# across its files, once stableswap is fully complete.
- unused
- deadcode
max-issues-per-linter: 10000
max-same-issues: 10000
2 changes: 1 addition & 1 deletion osmomath/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var powPrecision, _ = sdk.NewDecFromStr("0.00000001")

// Singletons.
//nolint:deadcode
// nolint: deadcode, unused
var zero sdk.Dec = sdk.ZeroDec()

var (
Expand Down
5 changes: 0 additions & 5 deletions store/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ func (node Node) find(key []byte) (idx int, match bool) {
return len(node.Children), false
}

func (node *Node) set(idx int, child *Child) *Node {
node.Children[idx] = child
return node
}

func (node *Node) setAcc(idx int, acc sdk.Int) *Node {
node.Children[idx] = &Child{node.Children[idx].Index, acc}
return node
Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ const (
// This image should be pre-built with `make docker-build-debug` either in CI or locally.
CurrentBranchOsmoRepository = "osmosis"
CurrentBranchOsmoTag = "debug"
/// Current Git branch repo/version for osmosis initialization. It is meant to be built locally.
// It is used when skipping upgrade by setting OSMOSIS_E2E_SKIP_UPGRADE to true).
// This image should be pre-built with `make docker-build-e2e-chain-init` either in CI or locally.
currentBranchInitRepository = "osmosis-e2e-chain-init"
currentBranchInitTag = "debug"
// Pre-upgrade osmosis repo/tag to pull.
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
Expand Down
27 changes: 0 additions & 27 deletions tests/e2e/initialization/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,6 @@ func (c *internalChain) createAndInitValidators(count int) error {
return nil
}

func (c *internalChain) createAndInitValidatorsWithMnemonics(count int, mnemonics []string) error {
for i := 0; i < count; i++ {
// create node
node := c.createValidator(i)

// generate genesis files
if err := node.init(); err != nil {
return err
}

c.validators = append(c.validators, node)

// create keys
if err := node.createKeyFromMnemonic("val", mnemonics[i]); err != nil {
return err
}
if err := node.createNodeKey(); err != nil {
return err
}
if err := node.createConsensusKey(); err != nil {
return err
}
}

return nil
}

func (c *internalChain) createValidator(index int) *internalValidator {
return &internalValidator{
chain: c,
Expand Down
21 changes: 8 additions & 13 deletions tests/e2e/initialization/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ import (
)

type internalValidator struct {
chain *internalChain
index int
moniker string
mnemonic string
keyInfo keyring.Info
privateKey cryptotypes.PrivKey
consensusKey privval.FilePVKey
consensusPrivKey cryptotypes.PrivKey
nodeKey p2p.NodeKey
chain *internalChain
index int
moniker string
mnemonic string
keyInfo keyring.Info
privateKey cryptotypes.PrivKey
consensusKey privval.FilePVKey
nodeKey p2p.NodeKey
}

func (v *internalValidator) instanceName() string {
Expand All @@ -58,10 +57,6 @@ func (v *internalValidator) getMoniker() string {
return v.moniker
}

func (v *internalValidator) getMnemonic() string {
return v.mnemonic
}

func (v *internalValidator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) {
description := stakingtypes.NewDescription(v.moniker, "", "", "", "")
commissionRates := stakingtypes.CommissionRates{
Expand Down
3 changes: 3 additions & 0 deletions x/gamm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtyp
}
}

// nolint: unused
func (k *Keeper) createSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
Expand All @@ -74,6 +75,7 @@ func (k *Keeper) createSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId
})
}

// nolint: unused
func (k *Keeper) createAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
Expand All @@ -86,6 +88,7 @@ func (k *Keeper) createAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress,
})
}

// nolint: unused
func (k *Keeper) createRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
Expand Down
4 changes: 0 additions & 4 deletions x/gamm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/osmosis-labs/osmosis/v7/x/gamm/client/cli"
"github.com/osmosis-labs/osmosis/v7/x/gamm/keeper"
Expand Down Expand Up @@ -87,9 +86,6 @@ type AppModule struct {
ak types.AccountKeeper
bk types.BankKeeper
keeper keeper.Keeper

accountKeeper stakingtypes.AccountKeeper
bankKeeper stakingtypes.BankKeeper
}

func (am AppModule) RegisterServices(cfg module.Configurator) {
Expand Down
6 changes: 0 additions & 6 deletions x/gamm/pool-models/stableswap/amm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var (
)

// solidly CFMM is xy(x^2 + y^2) = k
// nolint:deadcode
func cfmmConstant(xReserve, yReserve sdk.Dec) sdk.Dec {
xy := xReserve.Mul(yReserve)
x2 := xReserve.Mul(xReserve)
Expand All @@ -28,7 +27,6 @@ func cfmmConstant(xReserve, yReserve sdk.Dec) sdk.Dec {
// outside of x and y (e.g. u = wz), and v is the sum
// of their squares (e.g. v = w^2 + z^2).
// When u = 1 and v = 0, this is equivalent to solidly's CFMM
// nolint:deadcode
func cfmmConstantMulti(xReserve, yReserve, uReserve, vSumSquares sdk.Dec) sdk.Dec {
xyu := xReserve.Mul(yReserve.Mul(uReserve))
x2 := xReserve.Mul(xReserve)
Expand Down Expand Up @@ -161,7 +159,6 @@ func solveCfmm(xReserve, yReserve, yIn sdk.Dec) sdk.Dec {
// how many units `a` of x do we get out.
// So we solve the following expression for `a`
// xyz(x^2 + y^2 + w) = (x - a)(y + b)z((x - a)^2 + (y + b)^2 + w)
// nolint:deadcode
func solveCfmmMulti(xReserve, yReserve, wSumSquares, yIn sdk.Dec) sdk.Dec {
if !yReserve.Add(yIn).IsPositive() {
panic("invalid yReserve, yIn combo")
Expand Down Expand Up @@ -274,7 +271,6 @@ var (

// solveCFMMBinarySearch searches the correct dx using binary search over constant K.
// added for future extension
// nolint:deadcode
func solveCFMMBinarySearch(constantFunction func(sdk.Dec, sdk.Dec) sdk.Dec) func(sdk.Dec, sdk.Dec, sdk.Dec) sdk.Dec {
return func(xReserve, yReserve, yIn sdk.Dec) sdk.Dec {
k := constantFunction(xReserve, yReserve)
Expand All @@ -298,7 +294,6 @@ func solveCFMMBinarySearch(constantFunction func(sdk.Dec, sdk.Dec) sdk.Dec) func

// solveCFMMBinarySearch searches the correct dx using binary search over constant K.
// added for future extension
// nolint:deadcode
func solveCFMMBinarySearchMulti(constantFunction func(sdk.Dec, sdk.Dec, sdk.Dec, sdk.Dec) sdk.Dec) func(sdk.Dec, sdk.Dec, sdk.Dec, sdk.Dec, sdk.Dec) sdk.Dec {
return func(xReserve, yReserve, uReserve, wSumSquares, yIn sdk.Dec) sdk.Dec {
k := constantFunction(xReserve, yReserve, uReserve, wSumSquares)
Expand All @@ -320,7 +315,6 @@ func solveCFMMBinarySearchMulti(constantFunction func(sdk.Dec, sdk.Dec, sdk.Dec,
}
}

//nolint:unused
func spotPrice(baseReserve, quoteReserve sdk.Dec) sdk.Dec {
// y = baseAsset, x = quoteAsset
// Define f_{y -> x}(a) as the function that outputs the amount of tokens X you'd get by
Expand Down
4 changes: 0 additions & 4 deletions x/incentives/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (k Keeper) getCoinsFromGauges(gauges []types.Gauge) sdk.Coins {
return coins
}

func (k Keeper) getCoinsFromIterator(ctx sdk.Context, iterator db.Iterator) sdk.Coins {
return k.getCoinsFromGauges(k.getGaugesFromIterator(ctx, iterator))
}

// setGauge set the gauge inside store.
func (k Keeper) setGauge(ctx sdk.Context, gauge *types.Gauge) error {
store := ctx.KVStore(k.storeKey)
Expand Down
1 change: 1 addition & 0 deletions x/lockup/keeper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func syntheticLockTimeStoreKey(lockID uint64, synthDenom string, endTime time.Ti
}

// getLockRefs get lock IDs specified on the prefix and timestamp key.
// nolint: unused
func (k Keeper) getLockRefs(ctx sdk.Context, key []byte) []uint64 {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, key)
Expand Down
1 change: 1 addition & 0 deletions x/tokenfactory/keeper/bankactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro
return k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount))
}

// nolint: unused
func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr string, toAddr string) error {
// verify that denom is an x/tokenfactory denom
_, _, err := types.DeconstructDenom(amount.Denom)
Expand Down

0 comments on commit aca83eb

Please sign in to comment.