Skip to content

Commit

Permalink
Fix false positive (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
bunyk committed Oct 9, 2021
1 parent ec9cf88 commit c941235
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions durationcheck.go
Expand Up @@ -150,6 +150,9 @@ func isAcceptableNestedExpr(pass *analysis.Pass, n ast.Expr) bool {
case *ast.Ident:
return isAcceptableIdent(pass, e)
case *ast.CallExpr:
if isAcceptableCast(pass, e) {
return true
}
t := pass.TypesInfo.TypeOf(e)
return !isDuration(t)
case *ast.SelectorExpr:
Expand Down
2 changes: 2 additions & 0 deletions testdata/src/a/a.go
Expand Up @@ -74,6 +74,8 @@ func validCases() {
_ = time.Second * b.SomeInt

_ = time.Duration(intArr[0]) * time.Second

_ = time.Duration(y) * 24 * time.Hour
}

func invalidCases() {
Expand Down

0 comments on commit c941235

Please sign in to comment.