Conversation
|
Warning Review limit reached
More reviews will be available in 44 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a ChangesValidator for outsider file detection
Sequence DiagramsequenceDiagram
participant Caller
participant Validator
participant Git
participant ScopeParser
participant OutsiderFinder
Caller->>Validator: Validate(ctx, from, to)
Validator->>Git: SHA(ctx, from, to)
Git-->>Validator: []string (commit SHAs)
loop For each commit SHA
Validator->>Git: Message(ctx, sha)
Git-->>Validator: string (commit message)
Validator->>ScopeParser: Parse(message)
ScopeParser-->>Validator: string, bool (scope, ok)
Validator->>Git: FilesChanged(ctx, sha)
Git-->>Validator: []string (changed files)
Validator->>OutsiderFinder: Find(scope, files)
OutsiderFinder-->>Validator: []string (outsiders)
Validator->>Validator: Build Violation
end
Validator-->>Caller: []Violation, error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@pkg/validator/validator_test.go`:
- Around line 90-97: Define a single string constant (e.g., handlerFile :=
"api/handler.go" or const handlerFile = "api/handler.go") and replace all
duplicate literal occurrences of "api/handler.go" in the test case data (the
TestableCommit instances used in the "TestableCommit with outsider file" test,
including the commits' files and outsiders slices) with that constant so the
goconst duplication linter is satisfied.
In `@pkg/validator/validator.go`:
- Around line 23-40: The NewValidator constructor currently allows nil for
logger and interface dependencies which leads to nil dereference when methods on
Validator call v.logger.Info or other injected interfaces; update NewValidator
to validate inputs (logger, git, outsiderFinder, scopeParser) and either return
an error or panic with clear messages when any required dependency is nil, or
provide sensible defaults (e.g., set logger to slog.New(...) or a no-op logger)
for logger specifically; ensure the Validator struct initialization in
NewValidator uses these validated/defaulted values so methods like
(Validator).Validate and any calls to v.logger.Info, v.git, v.outsiderFinder,
and v.scopeParser are safe.
- Around line 83-85: Guard the SHA slicing to avoid panic by checking the length
of the sha before using sha[:v.shaLength]; in the block that appends to
violations (the Violation struct assignment where SHA: sha[:v.shaLength]),
compute a safe length like n := v.shaLength; if len(sha) < n { n = len(sha) }
and then use sha[:n] (or otherwise clamp v.shaLength) so short/abbreviated SHAs
won’t cause a runtime panic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 391364f7-76c8-4bfd-8f04-f7f7cdea7eb1
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (8)
.editorconfig.golangci.yaml.mockery.ymlgo.modpkg/validator/mocks_test.gopkg/validator/types.gopkg/validator/validator.gopkg/validator/validator_test.go
|
🎉 This PR is included in version 0.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
Release Notes
New Features
Chores