Skip to content

Commit 3bec636

Browse files
committed
statusoptional: Embed nil check in checkStatusStruct
Return early from the method when statusType is nil, as we can't reliably expect all callers to check for passed arguments before calling the function. Hopefully fixes #90
1 parent 6df69a1 commit 3bec636

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

pkg/analysis/statusoptional/analyzer.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,14 @@ func (a *analyzer) run(pass *analysis.Pass) (any, error) {
8585
}
8686

8787
statusStructType := getStructFromField(pass, field)
88-
if statusStructType == nil {
89-
return
90-
}
91-
9288
a.checkStatusStruct(pass, statusStructType, markersAccess, jsonTags)
9389
})
9490

9591
return nil, nil //nolint:nilnil
9692
}
9793

9894
func (a *analyzer) checkStatusStruct(pass *analysis.Pass, statusType *ast.StructType, markersAccess markershelper.Markers, jsonTags extractjsontags.StructFieldTags) {
99-
if statusType.Fields == nil || statusType.Fields.List == nil {
95+
if statusType == nil || statusType.Fields == nil || statusType.Fields.List == nil {
10096
return
10197
}
10298

0 commit comments

Comments
 (0)