mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-07-07 05:02:30 +00:00
Improve linter setup (#185)
* [linter] Remove unused exclusions Linter `nosnakecase` was removed in 1e1138d0268a9896a1bd058e9b65b808eb20666e. * [linter] Add tool for code clone detection * [linter] Add `errorlint` Find code that will cause problems with the error wrapping scheme introduced in Go 1.13. * [linter] Add `exhaustive` Check exhaustiveness of enum switch statements. * [linter] Add `forcetypeassert` Finds type assertions which did forcely such as below: ``` func f() { var a interface{} _ = a.(int) // type assertion must be checked } ``` * [linter] Add `gocritic` Provides diagnostics that check for bugs, performance and style issues. Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
db5f4fb3fe
commit
5470fc668b
@ -11,19 +11,24 @@ linters:
|
|||||||
- contextcheck
|
- contextcheck
|
||||||
- decorder
|
- decorder
|
||||||
- dogsled
|
- dogsled
|
||||||
|
- dupl
|
||||||
- dupword
|
- dupword
|
||||||
- durationcheck
|
- durationcheck
|
||||||
- errcheck
|
- errcheck
|
||||||
- errchkjson
|
- errchkjson
|
||||||
- errname
|
- errname
|
||||||
|
- errorlint
|
||||||
- execinquery
|
- execinquery
|
||||||
|
- exhaustive
|
||||||
- exportloopref
|
- exportloopref
|
||||||
- forbidigo
|
- forbidigo
|
||||||
|
- forcetypeassert
|
||||||
- ginkgolinter
|
- ginkgolinter
|
||||||
- gocheckcompilerdirectives
|
- gocheckcompilerdirectives
|
||||||
- gochecksumtype
|
- gochecksumtype
|
||||||
- gocognit
|
- gocognit
|
||||||
- goconst
|
- goconst
|
||||||
|
- gocritic
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- gofmt
|
- gofmt
|
||||||
- goheader
|
- goheader
|
||||||
@ -71,12 +76,12 @@ linters-settings:
|
|||||||
max-func-lines: 100
|
max-func-lines: 100
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: codec\.go
|
- path: x/.*/types/message.*\.go
|
||||||
linters:
|
linters:
|
||||||
- nosnakecase
|
- dupl
|
||||||
- path: app\/simulation_test\.go
|
- path: x/dao/client/cli/tx_reissue_rddl.*\.go
|
||||||
linters:
|
linters:
|
||||||
- nosnakecase
|
- dupl
|
||||||
- path: testutil\/rest\.go
|
- path: testutil/nullify/nullify\.go
|
||||||
linters:
|
linters:
|
||||||
- nosnakecase
|
- exhaustive
|
||||||
|
@ -112,7 +112,10 @@ func initRootCmd(
|
|||||||
// Set config
|
// Set config
|
||||||
initSDKConfig()
|
initSDKConfig()
|
||||||
|
|
||||||
gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
|
gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
|
||||||
|
if !ok {
|
||||||
|
panic("forced type assertion failed for gentxModule")
|
||||||
|
}
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
|
genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
|
||||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator),
|
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
@ -13,12 +14,10 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
rootCmd, _ := cmd.NewRootCmd()
|
rootCmd, _ := cmd.NewRootCmd()
|
||||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||||
switch e := err.(type) {
|
var e *server.ErrorCode
|
||||||
case server.ErrorCode:
|
if errors.As(err, &e) {
|
||||||
os.Exit(e.Code)
|
os.Exit(e.Code)
|
||||||
|
}
|
||||||
default:
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -65,10 +65,10 @@ func getLastPopBytes(height int64) []byte {
|
|||||||
return big.NewInt(height + 1).Bytes()
|
return big.NewInt(height + 1).Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ComputeDistribution(lastReissuance int64, BlockHeight int64, amount uint64) (distribution types.DistributionOrder) {
|
func ComputeDistribution(lastReissuance int64, blockHeight int64, amount uint64) (distribution types.DistributionOrder) {
|
||||||
conf := config.GetConfig()
|
conf := config.GetConfig()
|
||||||
distribution.FirstPop = lastReissuance
|
distribution.FirstPop = lastReissuance
|
||||||
distribution.LastPop = BlockHeight
|
distribution.LastPop = blockHeight
|
||||||
|
|
||||||
distribution.DaoAddr = conf.DistributionAddrDAO
|
distribution.DaoAddr = conf.DistributionAddrDAO
|
||||||
distribution.InvestorAddr = conf.DistributionAddrInv
|
distribution.InvestorAddr = conf.DistributionAddrInv
|
||||||
@ -109,7 +109,7 @@ func (k Keeper) GetDistributionForReissuedTokens(ctx sdk.Context, blockHeight in
|
|||||||
(lastPoP < obj.BlockHeight && obj.BlockHeight <= blockHeight) {
|
(lastPoP < obj.BlockHeight && obj.BlockHeight <= blockHeight) {
|
||||||
amount, err := getUint64FromTxString(ctx, obj.Rawtx)
|
amount, err := getUint64FromTxString(ctx, obj.Rawtx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
overallAmount = overallAmount + amount
|
overallAmount += amount
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.Logger().Info("%u %u %u", lastPoP, obj.BlockHeight, blockHeight)
|
ctx.Logger().Info("%u %u %u", lastPoP, obj.BlockHeight, blockHeight)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user