-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement support for github.com/jackc/pgx #25
Conversation
Thank you. I will take a look at this by the end of the weekend. |
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.
Thank you. This is overall great work, and look forward to merging it. 😸
I have one question about a variable rename and would like to see some of the new code DRYed out a bit. Happy to chat about strategies to eliminate the repeated code. This is my first linter too, I'm learning with each change as well.
pkg/analyzer/analyzer.go
Outdated
switch tt := targetType.(type) { | ||
case *types.Pointer: | ||
if types.Identical(instrType, tt) { | ||
if checkClosed(instr.Referrers(), targetTypes) { | ||
return actionHandled | ||
} | ||
} | ||
case *types.Named: | ||
if types.Identical(instrType, tt) { | ||
if checkClosed(instr.Referrers(), targetTypes) { | ||
return actionHandled | ||
} |
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.
Another example. There are a couple more areas. Don't worry about the Value
and Method
paths.
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.
Can you please elaborate on the Value
and Method
paths? They don't seem to be part of the code that you highlighted in your comment.
Thanks for the feedback Ryan! I'll have a look at your comments today. |
I have pushed some changes around the duplicate code. Thanks for pointing it out! All this type casting is making it a little bit difficult for me to fully understand what's going on sometimes. Hopefully I've responded to your other comments as well. Let me know what you think. I'd happily continue to work on the code until it reaches a mergeable state. |
I was thinking something like:
|
Thank you. :) Great job. |
These changes add support for
github.com/jackc/pgx
(includingpgxpool
).Two of the biggest changes with this implementation:
pgx
functions return interface types. Because of this we need to check forinstr.Call.Method
calls as wellinstr.Call.Value
.Named
types in addition toPointer
types.There was an issue with the tests in
pkg/analyzer
that would not allow the tests to run with external packages. From the documentation foranalysistest.Run
:The solution was to add a
go.mod
and vendor in thepkg/analyzer/testdata
directory. This leads to some packages being vendored twice unfortunately but I see no easy solution around this.This is the first time I write some linter/static code analyzer tool so any feedback is appreciated.
Thanks.
Closes #23.