Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint1 check #88

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions bridge/setu/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -107,8 +120,9 @@ func Logger() log.Logger {
if viper.GetString("log_level") != "debug" {
mLog.SetDebug(NoopLogger{})
}
test2 = 1
})

test2 = 1
return logger
}

Expand Down
65 changes: 65 additions & 0 deletions cmd/deliveryd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"fmt"
"io"
"math/big"
"net"

Check failure on line 10 in cmd/deliveryd/main.go

View workflow job for this annotation

GitHub Actions / build

imported and not used: "net"

Check failure on line 10 in cmd/deliveryd/main.go

View workflow job for this annotation

GitHub Actions / build

"net" imported but not used (typecheck)
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -61,6 +62,7 @@
flagOutputDir = "output-dir"
flagNodeDaemonHome = "node-daemon-home"
flagNodeHostPrefix = "node-host-prefix"
testnoUse = "xx"
)

// Tendermint full-node start flags.
Expand All @@ -72,6 +74,7 @@
FlagMinGasPrices = "minimum-gas-prices"
FlagHaltHeight = "halt-height"
FlagHaltTime = "halt-time"
FlagNoUse = "noUse"
)

// nolint
Expand Down Expand Up @@ -191,6 +194,68 @@
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 {
Expand Down
Loading