Add JSON, color, verbose output modes, add text output for default UX, configure logger AddSource dynamically#6
Conversation
…ult UX, configure logger AddSource dynamically
|
Warning Review limit reached
More reviews will be available in 44 minutes and 26 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 (3)
📝 WalkthroughWalkthroughThis PR adds colored and JSON-formatted violation output to the CLI, consolidates logger configuration into the root command, updates config loading to provide default regex values, and refines logging levels. The color dependency is introduced to support terminal coloring of violation headers. ChangesCLI Output Features and Config Defaults
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 2
🧹 Nitpick comments (1)
pkg/validator/config_test.go (1)
16-22: ⚡ Quick winAdd an error-path case for
ErrConfigReadwrapping.Current table covers only happy paths. Add one malformed config case and assert
errors.Is(err, validator.ErrConfigRead)so the new sentinel contract is tested.Also applies to: 76-78
🤖 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/config_test.go` around lines 16 - 22, Add a negative test entry to the tests table in pkg/validator/config_test.go that supplies malformed YAML (so the parser fails) and in the test loop assert errors.Is(err, validator.ErrConfigRead) for that case; specifically, update the tests slice (the struct used to define cases) to include a case named like "malformed config" that sets yaml to invalid content and expect an error, then in the test runner for each case check that when err != nil you call errors.Is(err, validator.ErrConfigRead) (in addition to any other assertions) to verify the sentinel wrapping contract; ensure you reference the existing tests slice and the ErrConfigRead sentinel from the validator package so the new case integrates with the current test loop.
🤖 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 131-139: The jsonOutput function currently encodes each Violation
separately producing NDJSON; change it to emit a single JSON array by encoding
the entire violations slice at once (e.g., use the existing encoder to
Encode(violations) or marshal with json.MarshalIndent) and return any error;
update jsonOutput (and its use of encoder/violations) so the output is one
well-formed JSON document and ensure the function returns nil on success.
In `@pkg/validator/config_test.go`:
- Around line 67-70: The deferred and immediate os.Chdir calls ignore returned
errors; update the test setup in config_test.go to check and handle both errors
(the defer that restores origDir and the os.Chdir(dir) call) by capturing their
error returns and failing the test (e.g., using t.Fatalf or require.NoError) if
they fail; reference the defer os.Chdir(origDir) restoration and the
os.Chdir(dir) setup call so you add proper error checks and clear failure
messages.
---
Nitpick comments:
In `@pkg/validator/config_test.go`:
- Around line 16-22: Add a negative test entry to the tests table in
pkg/validator/config_test.go that supplies malformed YAML (so the parser fails)
and in the test loop assert errors.Is(err, validator.ErrConfigRead) for that
case; specifically, update the tests slice (the struct used to define cases) to
include a case named like "malformed config" that sets yaml to invalid content
and expect an error, then in the test runner for each case check that when err
!= nil you call errors.Is(err, validator.ErrConfigRead) (in addition to any
other assertions) to verify the sentinel wrapping contract; ensure you reference
the existing tests slice and the ErrConfigRead sentinel from the validator
package so the new case integrates with the current test loop.
🪄 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: aa3c4fa0-02dd-44a0-8832-733a11a6537d
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (9)
.gitignoreTaskfile.yamlcmd/root.gogo.modmain.gopkg/validator/config.gopkg/validator/config_test.gopkg/validator/scope_parser_test.gopkg/validator/validator.go
💤 Files with no reviewable changes (1)
- main.go
|
🎉 This PR is included in version 0.6.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
New Features
--no-colorflag to disable colored terminal output.--jsonflag for machine-readable JSON output format.buildtask for project compilation.Tests
Chores