Skip to content

Commit

Permalink
fix VerbosityZero check panic
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjunmyfm192085 committed Aug 31, 2022
1 parent f68289b commit f60c7b1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions logcheck/pkg/logcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,14 @@ func isVerbosityZero(expr ast.Expr) bool {
return false
}

if lit, ok := subCallExpr.Args[0].(*ast.BasicLit); ok && lit.Value == "0" {
return true
if lit, ok := subCallExpr.Args[0].(*ast.BasicLit); ok {
if lit.Value == "0" {
return true
}
return false
}

if id, ok := subCallExpr.Args[0].(*ast.Ident); ok && id.Obj.Kind == 2 {
if id, ok := subCallExpr.Args[0].(*ast.Ident); ok && id.Obj != nil && id.Obj.Kind == 2 {
v, ok := id.Obj.Decl.(*ast.ValueSpec)
if !ok || len(v.Values) != 1 {
return false
Expand Down

0 comments on commit f60c7b1

Please sign in to comment.