-
Notifications
You must be signed in to change notification settings - Fork 16
Fix for BatchReadOnlyTransaction check #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,15 +33,24 @@ func run(pass *analysis.Pass) (interface{}, error) { | |
| funcs := pass.ResultOf[buildssa.Analyzer].(*buildssa.SSA).SrcFuncs | ||
| cmaps := pass.ResultOf[commentmap.Analyzer].(comment.Maps) | ||
|
|
||
| txTyp := zaganeutils.TypeOf(pass, "*ReadOnlyTransaction") | ||
| if txTyp == nil { | ||
| txTypeRo := zaganeutils.TypeOf(pass, "*ReadOnlyTransaction") | ||
| if txTypeRo == nil { | ||
| // skip checking | ||
| return nil, nil | ||
| } | ||
|
|
||
| txTypeBatch := zaganeutils.TypeOf(pass, "*BatchReadOnlyTransaction") | ||
| if txTypeBatch == nil { | ||
| // skip checking | ||
| return nil, nil | ||
| } | ||
|
|
||
| var methods []*types.Func | ||
| for _, s := range strings.Split(closeMethods, ",") { | ||
| if m := analysisutil.MethodOf(txTyp, s); m != nil { | ||
| if m := analysisutil.MethodOf(txTypeRo, s); m != nil { | ||
| methods = append(methods, m) | ||
| } | ||
| if m := analysisutil.MethodOf(txTypeBatch, s); m != nil { | ||
| methods = append(methods, m) | ||
| } | ||
| } | ||
|
|
@@ -59,7 +68,7 @@ func run(pass *analysis.Pass) (interface{}, error) { | |
| // skip this | ||
| continue | ||
| } | ||
| instrs := analysisutil.NotCalledIn(f, txTyp, methods...) | ||
| instrs := analysisutil.NotCalledIn(f, txTypeRo, methods...) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the second argument of I think you should call
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I use this: The test says: it points to this test case: I have no idea to solve this test failure. 🤔 |
||
| for _, instr := range instrs { | ||
| pos := instr.Pos() | ||
| if pos == token.NoPos { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test case which does not call
Closemethod with a// wantcomment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f5is that the testcase.zagane/passes/unclosetx/testdata/src/a/a.go
Lines 54 to 57 in effcadc