Skip to content

Conversation

@hallabro
Copy link
Contributor

Fix issue #36 where the linter failed to detect missing Close() calls when methods like rows.Next() or rows.Err() were called on pgx.Rows.

The fix adds handling for invoke mode at the start of the *ssa.Call case.

I tested it out on a local project and it seems to properly detect missing calls to Close.

Let me know what you think.

Screenshot of iTerm2 - 2025-12-18 - 19 42 12

@hallabro hallabro force-pushed the fix-pgx-interface-method-detection branch 2 times, most recently from 15606dd to 8185844 Compare December 18, 2025 18:49
github.com/jackc/pgx/v5 v5.5.4
github.com/jmoiron/sqlx v1.3.5
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
golang.org/x/tools v0.40.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for Go 1.25 compatibility, and this in turns bumps Go to 1.24.0.

@hallabro hallabro force-pushed the fix-pgx-interface-method-detection branch from 8185844 to 52a8bc5 Compare December 18, 2025 18:53
Fix issue ryanrolds#36 where the linter failed to detect missing Close() calls
when methods like rows.Next() or rows.Err() were called on pgx.Rows.

The root cause was that interface method calls (SSA "invoke mode") were
not handled in getAction(). For interface calls, instr.Call.Method is
set and StaticCallee() returns nil, causing the code to incorrectly
return actionPassed instead of continuing to check for Close().

The fix adds handling for invoke mode at the start of the *ssa.Call
case: check if instr.Call.Method is set, verify the receiver is a
target type, and return actionClosed for Close() or actionNoOp for
other methods like Next(), Err(), and Scan().

Also updates golang.org/x/tools for Go 1.25 compatibility.
@hallabro hallabro force-pushed the fix-pgx-interface-method-detection branch from 52a8bc5 to c6d65a4 Compare December 18, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant