Skip to content

Commit 8d32966

Browse files
committed
fix: False positive when multiplying with int type struct field
1 parent 9c47715 commit 8d32966

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/ashanbrown/makezero v0.0.0-20201205152432-7b7cdbb3025a
1212
github.com/bkielbasa/cyclop v1.2.0
1313
github.com/bombsimon/wsl/v3 v3.1.0
14-
github.com/charithe/durationcheck v0.0.3
14+
github.com/charithe/durationcheck v0.0.4
1515
github.com/daixiang0/gci v0.2.8
1616
github.com/denis-tingajkin/go-header v0.4.2
1717
github.com/esimonov/ifshort v1.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testdata/durationcheck.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
//args: -Edurationcheck
22
package testdata
33

4-
import "time"
4+
import (
5+
"fmt"
6+
"time"
7+
)
58

6-
func waitFor(someDuration time.Duration) {
9+
type s struct {
10+
d int
11+
}
12+
13+
func durationcheckCase01() {
14+
ss := s{10}
15+
_ = time.Duration(ss.d) * time.Second
16+
}
17+
18+
func durationcheckCase02() {
19+
seconds := 10
20+
fmt.Print(time.Duration(seconds) * time.Second)
21+
}
22+
23+
func durationcheckCase03(someDuration time.Duration) {
24+
timeToWait := someDuration * time.Second // ERROR "Multiplication of durations: `someDuration \\* time.Second` "
25+
time.Sleep(timeToWait)
26+
}
27+
28+
func durationcheckCase04() {
29+
someDuration := 2 * time.Second
730
timeToWait := someDuration * time.Second // ERROR "Multiplication of durations: `someDuration \\* time.Second` "
831
time.Sleep(timeToWait)
932
}

0 commit comments

Comments
 (0)