feat: refactor getDiffs for testability, boost reviewer coverage - #5
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a DiffSource interface and diffSource field to Reviewer, a NewWithDiffSource constructor for dependency injection, and modifies Run to use the injected diffSource when present, falling back to existing getDiffs otherwise. Adds corresponding test coverage. ChangesDiff Source Injection
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Reviewer
participant DiffSource
participant getDiffs
Caller->>Reviewer: Run(ctx)
alt diffSource is set
Reviewer->>DiffSource: GetDiffs(ctx)
DiffSource-->>Reviewer: diffs, title, description, error
else diffSource is nil
Reviewer->>getDiffs: getDiffs(ctx)
getDiffs-->>Reviewer: diffs, title, description, error
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/reviewer/reviewer.go (1)
19-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: consider a richer return type instead of positional strings.
GetDiffsreturns(diffs, title, desc, err)as four positional values, mirroring the existinggetDiffsmethod. This is consistent with existing code, but a small struct (e.g.DiffContext{Diffs, Title, Desc}) would reduce the risk of accidentally swappingtitle/descat call sites as more implementations are added.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/reviewer/reviewer.go` around lines 19 - 22, Replace the positional string returns in DiffSource.GetDiffs with a small context struct so callers don’t have to remember the order of title and desc. Update the DiffSource interface and the existing getDiffs/GetDiffs implementation in reviewer.go to return a single typed result like DiffContext containing Diffs, Title, and Desc, and then adjust any call sites to use the named fields instead of unpacking multiple values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/reviewer/reviewer.go`:
- Around line 19-22: Replace the positional string returns in
DiffSource.GetDiffs with a small context struct so callers don’t have to
remember the order of title and desc. Update the DiffSource interface and the
existing getDiffs/GetDiffs implementation in reviewer.go to return a single
typed result like DiffContext containing Diffs, Title, and Desc, and then adjust
any call sites to use the named fields instead of unpacking multiple values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 44f30b73-2958-4822-8fd4-db1bcc9b6531
📒 Files selected for processing (2)
internal/reviewer/reviewer.gointernal/reviewer/reviewer_test.go
a8b55e8 to
f96a446
Compare
Adds DiffSource interface for testability. New tests for Run(), filterBySeverity, buildNumberedDiff.
Summary by CodeRabbit