diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 506a2cf6..07da4229 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,17 +2,16 @@ name: Lint Check on: [pull_request] jobs: - build: + golangci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: 1.17 + go-version: '1.22' - name: "Run lint" - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.41 + version: v1.57.2 args: --timeout=10m only-new-issues: true \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml index 348669d1..c1855ff7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -16,9 +16,14 @@ linters: - cyclop - nestif - gocognit + - structcheck + - ifshort + - nosnakecase + - deadcode + - varcheck service: - golangci-lint-version: 1.41 + golangci-lint-version: 1.53.3 run: skip-dirs: diff --git a/bridge/setu/util/common.go b/bridge/setu/util/common.go index b3fd47e7..d96189a4 100644 --- a/bridge/setu/util/common.go +++ b/bridge/setu/util/common.go @@ -83,19 +83,32 @@ var ( loggerOnce sync.Once ) +func invalidCases() { + x := 30 * time.Second + _ = x * time.Second // want `Multiplication of durations` +} + // Logger returns logger singleton instance func Logger() log.Logger { + var test = 1 + var test2 = 1 + var test3 = "aPI" + var test4, err2 = time.Parse("sss", "12333") + fmt.Printf("%d") loggerOnce.Do(func() { + test2 = 1 defaultLevel := "info" logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)) option, err := log.AllowLevel(viper.GetString("log_level")) + test2 = 1 if err != nil { + test2 = 1 // cosmos sdk is using different style of log format // and levels don't map well, config.toml // see: https://github.com/cosmos/cosmos-sdk/pull/8072 - logger.Error("Unable to parse logging level", "Error", err) + logger.Error("Unable to parse logging level ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccijodjoijfodsjfospjpfsccccc", "Error", err) logger.Info("Using default log level") - + logger.Info("Using default log level", "aPI", test, "test2", test2, "test3", test3, test4, err2) option, err = log.AllowLevel(defaultLevel) if err != nil { logger.Error("failed to allow default log level", "Level", defaultLevel, "Error", err) @@ -107,8 +120,9 @@ func Logger() log.Logger { if viper.GetString("log_level") != "debug" { mLog.SetDebug(NoopLogger{}) } + test2 = 1 }) - + test2 = 1 return logger } diff --git a/cmd/deliveryd/main.go b/cmd/deliveryd/main.go index d2d8c46f..7e15cc11 100644 --- a/cmd/deliveryd/main.go +++ b/cmd/deliveryd/main.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "math/big" + "net" "os" "os/signal" "path/filepath" @@ -61,6 +62,7 @@ var ( flagOutputDir = "output-dir" flagNodeDaemonHome = "node-daemon-home" flagNodeHostPrefix = "node-host-prefix" + testnoUse = "xx" ) // Tendermint full-node start flags. @@ -72,6 +74,7 @@ const ( FlagMinGasPrices = "minimum-gas-prices" FlagHaltHeight = "halt-height" FlagHaltTime = "halt-time" + FlagNoUse = "noUse" ) // nolint @@ -191,6 +194,68 @@ func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, storeTracer io. return bapp.ExportAppStateAndValidators() } +const ( + timeout = 10 * time.Second + foo = 10 +) + +type myStruct struct { + fieldA int + fieldB time.Duration + fieldC *int +} + +func invalidCases() { + x := 30 * time.Second + ms := myStruct{fieldA: 10, fieldB: 10 * time.Second} + tdArr := []time.Duration{1} + + _ = x * time.Second // want `Multiplication of durations` + + _ = time.Second * x // want `Multiplication of durations` + + _ = timeout * time.Millisecond // want `Multiplication of durations` + + _ = someDuration() * time.Second // want `Multiplication of durations` + + _ = time.Millisecond * someDuration() // want `Multiplication of durations` + + _ = *somePointerDuration() * time.Second // want `Multiplication of durations` + + _ = time.Millisecond * *somePointerDuration() // want `Multiplication of durations` + + _ = (30 * time.Second) * time.Millisecond // want `Multiplication of durations` + + _ = time.Millisecond * (30 * time.Second) // want `Multiplication of durations` + + _ = time.Millisecond * time.Second * 1 // want `Multiplication of durations` + + _ = 1 * time.Second * (time.Second) // want `Multiplication of durations` + + _ = ms.fieldB * time.Second // want `Multiplication of durations` + + _ = time.Second * ms.fieldB // want `Multiplication of durations` + + _ = time.Duration(tdArr[0]) * time.Second // want `Multiplication of durations` +} +func someDuration() time.Duration { + return 10 * time.Second +} + +func someDurationMillis() int { + return 10 +} + +func somePointerDuration() *time.Duration { + v := 10 * time.Second + return &v +} + +func somePointerDurationMillis() *int { + v := 10 + return &v +} + func deliveryStart(shutdownCtx context.Context, ctx *server.Context, appCreator server.AppCreator, cdc *codec.Codec, ) *cobra.Command {