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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add: invalid case
  • Loading branch information
bladehan1 committed May 7, 2024
commit 19cc1d0b5296dfab7ba92e15e38bbee6c6313df4
59 changes: 58 additions & 1 deletion cmd/deliveryd/main.go
Original file line number Diff line number Diff line change
@@ -191,9 +191,66 @@ func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, storeTracer io.
return bapp.ExportAppStateAndValidators()
}

func InvalidCases() {
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,
Loading