fix: match bare-function middleware values in gin/echo rule#44
Conversation
The go-gin-auth-middleware rule only matched factory-form middleware (`r.Use(AuthRequired())`) and missed bare function-value middleware (`r.Use(AuthRequired)`), which is a valid Go pattern since `gin.HandlerFunc` and `echo.MiddlewareFunc` are first-class values. Extends the `arguments:` clause with an alternation so either a call_expression or a bare identifier/selector_expression is accepted, with the existing auth-flavored regex applied to whichever form appears. Confidence stays `medium` — the regex is specific enough (`AuthRequired`, `JWTAuth`, `RequireAuth`, …) that accepting bare identifiers does not meaningfully widen FP risk. Adds positive tests for `r.Use(AuthRequired)` and `r.Use(m.RequireAuth)` plus a negative test for `r.Use(Logger)`. Closes #31
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesMiddleware Argument Pattern Expansion
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
The changes correctly extend the rule to match both factory-form middleware (r.Use(AuthRequired())) and bare function-value middleware (r.Use(AuthRequired)). The tree-sitter query alternation is properly structured, test coverage is appropriate, and documentation accurately reflects the new behavior. No blocking issues identified.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Summary
go-gin-auth-middlewareto match bare function-value middleware (r.Use(AuthRequired)) in addition to the factory form (r.Use(AuthRequired())).arguments:clause so either acall_expressionor a bareidentifier/selector_expressionis accepted; the existing auth-flavored regex applies to whichever form appears.medium— the fn-name regex (AuthRequired,JWTAuth,RequireAuth, …) is specific enough that accepting bare identifiers does not meaningfully widen FP risk.r.Use(AuthRequired)andr.Use(m.RequireAuth), plus a negative test forr.Use(Logger).Closes #31.
Test plan
cargo run -- rules test— 206 passed (was 203; three new cases added)cargo fmtcargo clippy -- -D warningscargo testSummary by CodeRabbit