@@ -54,6 +54,7 @@ type entryType int
54
54
55
55
const (
56
56
EntryNone entryType = iota
57
+ EntryNormal // without ctx in
57
58
EntryWithCtx // has ctx in
58
59
EntryWithHttpHandler // is http handler
59
60
)
@@ -133,13 +134,13 @@ func (r *runner) run(pass *analysis.Pass) {
133
134
continue
134
135
}
135
136
136
- if entryType := r .checkIsEntry (f ); entryType == EntryNone {
137
+ if entryType := r .checkIsEntry (f ); entryType == EntryNormal {
137
138
// record the result of nomal function
138
139
checkingMap := make (map [string ]bool )
139
140
checkingMap [key ] = true
140
141
r .setFact (key , r .checkFuncWithoutCtx (f , checkingMap ), f .Name ())
141
142
continue
142
- } else {
143
+ } else if entryType == EntryWithCtx || entryType == EntryWithHttpHandler {
143
144
tmpFuncs = append (tmpFuncs , entryInfo {f : f , tp : entryType })
144
145
}
145
146
}
@@ -177,14 +178,14 @@ func (r *runner) getRequiedType(pssa *buildssa.SSA, path, name string) (obj *typ
177
178
}
178
179
179
180
func (r * runner ) collectHttpTyps (pssa * buildssa.SSA ) {
180
- objRes , pobjRes , ok := r .getRequiedType (pssa , httpPkg , httpRes )
181
+ objRes , _ , ok := r .getRequiedType (pssa , httpPkg , httpRes )
181
182
if ok {
182
- r .httpResTyps = append (r .httpResTyps , objRes , pobjRes )
183
+ r .httpResTyps = append (r .httpResTyps , objRes )
183
184
}
184
185
185
- objReq , pobjReq , ok := r .getRequiedType (pssa , httpPkg , httpReq )
186
+ _ , pobjReq , ok := r .getRequiedType (pssa , httpPkg , httpReq )
186
187
if ok {
187
- r .httpReqTyps = append (r .httpReqTyps , objReq , pobjReq , types . NewPointer ( pobjReq ) )
188
+ r .httpReqTyps = append (r .httpReqTyps , pobjReq )
188
189
}
189
190
}
190
191
@@ -221,7 +222,7 @@ func (r *runner) noImportedContextAndHttp(f *ssa.Function) (ret bool) {
221
222
222
223
func (r * runner ) checkIsEntry (f * ssa.Function ) entryType {
223
224
if r .noImportedContextAndHttp (f ) {
224
- return EntryNone
225
+ return EntryNormal
225
226
}
226
227
227
228
ctxIn , ctxOut := r .checkIsCtx (f )
@@ -238,7 +239,7 @@ func (r *runner) checkIsEntry(f *ssa.Function) entryType {
238
239
return EntryWithHttpHandler
239
240
}
240
241
241
- return EntryNone
242
+ return EntryNormal
242
243
}
243
244
244
245
func (r * runner ) checkIsCtx (f * ssa.Function ) (in , out bool ) {
@@ -540,7 +541,7 @@ func (r *runner) checkFuncWithoutCtx(f *ssa.Function, checkingMap map[string]boo
540
541
continue
541
542
}
542
543
543
- if entryType := r .checkIsEntry (ff ); entryType == EntryNone {
544
+ if entryType := r .checkIsEntry (ff ); entryType == EntryNormal {
544
545
// cannot get info from fact, skip
545
546
if ff .Blocks == nil {
546
547
continue
0 commit comments