durationcheck: False positive when multiplying with int type struct field (#1744)
Some checks failed
Extra / Vulnerability scanner (push) Failing after 33s
CI / go-mod (push) Failing after 43s
CI / golangci-lint (push) Failing after 1m0s
CI / tests-on-windows (push) Has been skipped
CI / tests-on-macos (push) Has been skipped
CI / tests-on-unix (1.14) (push) Has been skipped
CI / tests-on-unix (1.15) (push) Has been skipped
CI / tests-on-unix (1.16) (push) Has been skipped
CI / check_generated (push) Has been skipped
Release a tag / release (push) Failing after 1m10s
Release a tag / docker-release (map[Dockerfile:build/Dockerfile.alpine]) (push) Has been skipped
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been skipped
Some checks failed
Extra / Vulnerability scanner (push) Failing after 33s
CI / go-mod (push) Failing after 43s
CI / golangci-lint (push) Failing after 1m0s
CI / tests-on-windows (push) Has been skipped
CI / tests-on-macos (push) Has been skipped
CI / tests-on-unix (1.14) (push) Has been skipped
CI / tests-on-unix (1.15) (push) Has been skipped
CI / tests-on-unix (1.16) (push) Has been skipped
CI / check_generated (push) Has been skipped
Release a tag / release (push) Failing after 1m10s
Release a tag / docker-release (map[Dockerfile:build/Dockerfile.alpine]) (push) Has been skipped
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been skipped
This commit is contained in:
parent
ea5f479087
commit
b39dbcd694
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
||||
github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a
|
||||
github.com/bkielbasa/cyclop v1.2.0
|
||||
github.com/bombsimon/wsl/v3 v3.1.0
|
||||
github.com/charithe/durationcheck v0.0.3
|
||||
github.com/charithe/durationcheck v0.0.4
|
||||
github.com/daixiang0/gci v0.2.8
|
||||
github.com/denis-tingajkin/go-header v0.4.2
|
||||
github.com/esimonov/ifshort v1.0.1
|
||||
|
4
go.sum
generated
4
go.sum
generated
@ -46,8 +46,8 @@ github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbz
|
||||
github.com/bombsimon/wsl/v3 v3.1.0 h1:E5SRssoBgtVFPcYWUOFJEcgaySgdtTNYzsSKDOY7ss8=
|
||||
github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/charithe/durationcheck v0.0.3 h1:W+9cu38epH7otBF96pdhbFw5vLilsl1oseMOiOgex5E=
|
||||
github.com/charithe/durationcheck v0.0.3/go.mod h1:0oCYOIgY8Om3hZxPedxKn0mzy0rneKTWJhRm+r6Gl20=
|
||||
github.com/charithe/durationcheck v0.0.4 h1:lD3ud3KJ2DaoL80EZ768cSBv3DS8Xr7nNgN+kgW1tts=
|
||||
github.com/charithe/durationcheck v0.0.4/go.mod h1:0oCYOIgY8Om3hZxPedxKn0mzy0rneKTWJhRm+r6Gl20=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
|
35
test/testdata/durationcheck.go
vendored
35
test/testdata/durationcheck.go
vendored
@ -1,9 +1,38 @@
|
||||
//args: -Edurationcheck
|
||||
package testdata
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func waitFor(someDuration time.Duration) {
|
||||
timeToWait := someDuration * time.Second // ERROR "Multiplication of durations: `someDuration \\* time.Second` "
|
||||
type durationCheckData struct {
|
||||
i int
|
||||
d time.Duration
|
||||
}
|
||||
|
||||
func durationcheckCase01() {
|
||||
dcd := durationCheckData{i: 10}
|
||||
_ = time.Duration(dcd.i) * time.Second
|
||||
}
|
||||
|
||||
func durationcheckCase02() {
|
||||
dcd := durationCheckData{d: 10 * time.Second}
|
||||
_ = dcd.d * time.Second // ERROR "Multiplication of durations: `dcd.d \\* time.Second`"
|
||||
}
|
||||
|
||||
func durationcheckCase03() {
|
||||
seconds := 10
|
||||
fmt.Print(time.Duration(seconds) * time.Second)
|
||||
}
|
||||
|
||||
func durationcheckCase04(someDuration time.Duration) {
|
||||
timeToWait := someDuration * time.Second // ERROR "Multiplication of durations: `someDuration \\* time.Second`"
|
||||
time.Sleep(timeToWait)
|
||||
}
|
||||
|
||||
func durationcheckCase05() {
|
||||
someDuration := 2 * time.Second
|
||||
timeToWait := someDuration * time.Second // ERROR "Multiplication of durations: `someDuration \\* time.Second`"
|
||||
time.Sleep(timeToWait)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user