Skip to content

Commit c941235

Browse files
authored
Fix false positive (#21)
1 parent ec9cf88 commit c941235

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

durationcheck.go

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ func isAcceptableNestedExpr(pass *analysis.Pass, n ast.Expr) bool {
150150
case *ast.Ident:
151151
return isAcceptableIdent(pass, e)
152152
case *ast.CallExpr:
153+
if isAcceptableCast(pass, e) {
154+
return true
155+
}
153156
t := pass.TypesInfo.TypeOf(e)
154157
return !isDuration(t)
155158
case *ast.SelectorExpr:

testdata/src/a/a.go

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func validCases() {
7474
_ = time.Second * b.SomeInt
7575

7676
_ = time.Duration(intArr[0]) * time.Second
77+
78+
_ = time.Duration(y) * 24 * time.Hour
7779
}
7880

7981
func invalidCases() {

0 commit comments

Comments
 (0)