Skip to content

Commit

Permalink
Add deadcode linter (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Jul 1, 2022
1 parent 01dee57 commit c0573d1
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
# - bodyclose <- needs go 1.18 support
# - contextcheck <- needs go 1.18 support
# - cyclop
# - deadcode <- re-enable in another pr
- deadcode
- depguard
# - dogsled <- disabled because we would like to participate in the iditerod
# - dupl <- really just catches cli stub text
Expand Down
1 change: 1 addition & 0 deletions osmomath/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
var powPrecision, _ = sdk.NewDecFromStr("0.00000001")

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

var (
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ImageConfig struct {
RelayerTag string
}

//nolint:deadcode
const (
// Current Git branch osmosis repo/version. It is meant to be built locally.
// It is used when skipping upgrade by setting OSMOSIS_E2E_SKIP_UPGRADE to true).
Expand Down
1 change: 1 addition & 0 deletions x/gamm/pool-models/balancer/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/osmosis-labs/osmosis/v7/x/gamm/types"
)

//nolint:deadcode
const (
errMsgFormatSharesAmountNotPositive = "shares amount must be positive, was %d"
errMsgFormatTokenAmountNotPositive = "token amount must be positive, was %d"
Expand Down
5 changes: 5 additions & 0 deletions x/gamm/pool-models/stableswap/amm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 @@ -27,6 +28,7 @@ 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 @@ -159,6 +161,7 @@ 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 @@ -271,6 +274,7 @@ 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 @@ -294,6 +298,7 @@ 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 Down
4 changes: 0 additions & 4 deletions x/lockup/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ func (k Keeper) GetLockRefs(ctx sdk.Context, key []byte) []uint64 {
return k.getLockRefs(ctx, key)
}

func (k Keeper) SyntheticCoins(coins sdk.Coins, suffix string) sdk.Coins {
return syntheticCoins(coins, suffix)
}

func (k Keeper) GetCoinsFromLocks(locks []types.PeriodLock) sdk.Coins {
return k.getCoinsFromLocks(locks)
}
8 changes: 0 additions & 8 deletions x/lockup/keeper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ func syntheticLockRefKeys(lock types.PeriodLock, synthLock types.SyntheticLock)
return refKeys, nil
}

func syntheticCoins(coins sdk.Coins, suffix string) sdk.Coins {
syntheticCoins := sdk.Coins{}
for _, coin := range coins {
syntheticCoins = syntheticCoins.Add(sdk.NewCoin(coin.Denom+suffix, coin.Amount))
}
return syntheticCoins
}

func combineLocks(pl1 []types.PeriodLock, pl2 []types.PeriodLock) []types.PeriodLock {
return append(pl1, pl2...)
}
8 changes: 1 addition & 7 deletions x/mint/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ import (
// Simulation parameter constants.
const (
epochProvisionsKey = "genesis_epoch_provisions"
epochIdentifierKey = "epoch_identifier"
reductionFactorKey = "reduction_factor"
reductionPeriodInEpochsKey = "reduction_period_in_epochs"

stakingDistributionProportionKey = "staking_distribution_proportion"
poolIncentivesDistributionProportionKey = "pool_incentives_distribution_proportion"
developerRewardsDistributionProportionKey = "developer_rewards_distribution_proportion"
communityPoolDistributionProportionKey = "community_pool_distribution_proportion"
weightedDevRewardReceiversKey = "weighted_developer_rewards_receivers"
mintingRewardsDistributionStartEpochKey = "minting_rewards_distribution_start_epoch"
mintingRewardsDistributionStartEpochKey = "minting_rewards_distribution_start_epoch"

epochIdentifier = "day"
maxInt64 = int(^uint(0) >> 1)
Expand Down
10 changes: 0 additions & 10 deletions x/tokenfactory/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ type (
}
)

func permContains(perms []string, perm string) bool {
for _, v := range perms {
if v == perm {
return true
}
}

return false
}

// NewKeeper returns a new instance of the x/tokenfactory keeper
func NewKeeper(
cdc codec.Codec,
Expand Down
1 change: 0 additions & 1 deletion x/tokenfactory/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)

0 comments on commit c0573d1

Please sign in to comment.