mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +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
|
||||
- decorder
|
||||
- dogsled
|
||||
- dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- errcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
- execinquery
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- forbidigo
|
||||
- forcetypeassert
|
||||
- ginkgolinter
|
||||
- gocheckcompilerdirectives
|
||||
- gochecksumtype
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- goheader
|
||||
@ -71,12 +76,12 @@ linters-settings:
|
||||
max-func-lines: 100
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: codec\.go
|
||||
- path: x/.*/types/message.*\.go
|
||||
linters:
|
||||
- nosnakecase
|
||||
- path: app\/simulation_test\.go
|
||||
- dupl
|
||||
- path: x/dao/client/cli/tx_reissue_rddl.*\.go
|
||||
linters:
|
||||
- nosnakecase
|
||||
- path: testutil\/rest\.go
|
||||
- dupl
|
||||
- path: testutil/nullify/nullify\.go
|
||||
linters:
|
||||
- nosnakecase
|
||||
- exhaustive
|
||||
|
@ -112,7 +112,10 @@ func initRootCmd(
|
||||
// Set config
|
||||
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(
|
||||
genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
|
||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
@ -13,12 +14,10 @@ import (
|
||||
func main() {
|
||||
rootCmd, _ := cmd.NewRootCmd()
|
||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||
switch e := err.(type) {
|
||||
case server.ErrorCode:
|
||||
var e *server.ErrorCode
|
||||
if errors.As(err, &e) {
|
||||
os.Exit(e.Code)
|
||||
|
||||
default:
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ func getLastPopBytes(height int64) []byte {
|
||||
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()
|
||||
distribution.FirstPop = lastReissuance
|
||||
distribution.LastPop = BlockHeight
|
||||
distribution.LastPop = blockHeight
|
||||
|
||||
distribution.DaoAddr = conf.DistributionAddrDAO
|
||||
distribution.InvestorAddr = conf.DistributionAddrInv
|
||||
@ -109,7 +109,7 @@ func (k Keeper) GetDistributionForReissuedTokens(ctx sdk.Context, blockHeight in
|
||||
(lastPoP < obj.BlockHeight && obj.BlockHeight <= blockHeight) {
|
||||
amount, err := getUint64FromTxString(ctx, obj.Rawtx)
|
||||
if err == nil {
|
||||
overallAmount = overallAmount + amount
|
||||
overallAmount += amount
|
||||
}
|
||||
} else {
|
||||
ctx.Logger().Info("%u %u %u", lastPoP, obj.BlockHeight, blockHeight)
|
||||
|
Loading…
x
Reference in New Issue
Block a user