Conversation
- Replace validator args to options struct - Move validator interfaces to validator.go - Add default implementations if options fields not set Need to implement OutsiderFinder, ScopeParser
📝 WalkthroughWalkthroughThe PR refactors the validator package's construction API by moving from positional arguments to an Options-based pattern, consolidates public types into ChangesValidator API and Git Implementation
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly Related PRs
🚥 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 docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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: 1
🧹 Nitpick comments (2)
pkg/validator/git.go (1)
52-60: 💤 Low valueFix grammatical error in comment.
The comment on line 53 contains a grammatical error: "no another way" should be "no other way".
✏️ Proposed fix
- //nolint:gosec // no another way + //nolint:gosec // no other way🤖 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 `@pkg/validator/git.go` around lines 52 - 60, Fix the grammatical error in the inline nolint comment in the gitCommand function: change the comment "//nolint:gosec // no another way" to use correct wording ("no other way") so it reads e.g. "//nolint:gosec // no other way" in the DefaultGit.gitCommand function to keep the nolint rationale grammatically correct.cmd/root.go (1)
68-68: 💤 Low valueConfirm intentional use of
ErrWriterfor JSON output.Writing structured JSON output to stderr (via
cmd.ErrWriter) is unconventional—typically stdout is used for data and stderr for errors. This affects CLI composability (piping violations to other tools). If violations should be machine-readable output, consider usingcmd.Writer(stdout) instead.🤖 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 `@cmd/root.go` at line 68, The JSON encoder is currently writing to cmd.ErrWriter (stderr) which is unconventional for machine-readable output; change the target of json.NewEncoder from cmd.ErrWriter to cmd.Writer so structured violations are emitted to stdout (or alternatively add a CLI flag to choose output stream). Locate the line creating the encoder (encoder := json.NewEncoder(cmd.ErrWriter)) and replace cmd.ErrWriter with cmd.Writer (or wire the new flag into the same spot and use the selected io.Writer) to restore normal CLI composability.
🤖 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 `@cmd/root.go`:
- Around line 51-57: The validator is being constructed with nil OutsiderFinder
and ScopeParser which causes NewValidator to panic; update the code that creates
vld (calling validator.NewValidator with validator.Options) to obtain and pass
real implementations for OutsiderFinder and ScopeParser from the dependency
container or factory instead of nil (e.g., use the container/getter you have in
cmd/root.go to retrieve the OutsiderFinder and ScopeParser instances) so
Options.OutsiderFinder and Options.ScopeParser are non-nil when calling
NewValidator; ensure the fields Git/Logger/SHALength remain set as before and
pass the retrieved instances into the Options struct.
---
Nitpick comments:
In `@cmd/root.go`:
- Line 68: The JSON encoder is currently writing to cmd.ErrWriter (stderr) which
is unconventional for machine-readable output; change the target of
json.NewEncoder from cmd.ErrWriter to cmd.Writer so structured violations are
emitted to stdout (or alternatively add a CLI flag to choose output stream).
Locate the line creating the encoder (encoder := json.NewEncoder(cmd.ErrWriter))
and replace cmd.ErrWriter with cmd.Writer (or wire the new flag into the same
spot and use the selected io.Writer) to restore normal CLI composability.
In `@pkg/validator/git.go`:
- Around line 52-60: Fix the grammatical error in the inline nolint comment in
the gitCommand function: change the comment "//nolint:gosec // no another way"
to use correct wording ("no other way") so it reads e.g. "//nolint:gosec // no
other way" in the DefaultGit.gitCommand function to keep the nolint rationale
grammatically correct.
🪄 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: a48a26eb-17c9-45ae-a5b0-5c16142f946e
📒 Files selected for processing (6)
cmd/root.gopkg/validator/git.gopkg/validator/git_test.gopkg/validator/types.gopkg/validator/validator.gopkg/validator/validator_test.go
💤 Files with no reviewable changes (1)
- pkg/validator/types.go
|
🎉 This PR is included in version 0.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
Release Notes
Refactor
Tests