feat: report checked value in JSON output for passing checks - #522
Conversation
validate_all_detailed now populates CheckOutcome.value on pass as well as fail, with the concrete value each validator checked (commit subject, branch name, author name/email, push refs). Structured consumers such as --format json, the Python API, and commit-check-action can therefore show what was validated even when every check passed.
📝 WalkthroughWalkthroughValidation results now retain the concrete value evaluated by each validator. Detailed and JSON outputs include these values for passing checks. Tests cover message, subject, author, and branch validation. ChangesValidation value reporting
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #522 +/- ##
==========================================
+ Coverage 97.40% 97.68% +0.28%
==========================================
Files 12 12
Lines 1231 1254 +23
==========================================
+ Hits 1199 1225 +26
+ Misses 32 29 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 `@commit_check/engine.py`:
- Line 652: Update ForcePushValidator.validate() so each successful local_ref ->
remote_ref result is accumulated rather than overwriting self._checked_value,
and serialize the complete collection according to the CheckOutcome.value
contract consumed by validate_all_detailed(). Add a regression test covering a
successful multi-reference push and asserting every validated reference is
preserved.
- Around line 703-704: Update the `ignore_authors` rule setup around
`CommitTypeValidator` so `_checked_value` is assigned the resolved commit author
before `_should_skip_commit_validation()` evaluates it, rather than the commit
message. Preserve the empty result for ignored authors and verify both ignored
and non-ignored author paths.
- Line 914: Update AiAttributionValidator.validate() to assign _checked_value on
every concrete validation path, including successful returns after reading the
commit body and when the policy is not forbid. Preserve the existing failure
assignment and ensure validate_all_detailed() receives the actual ai_attribution
value for passing results.
🪄 Autofix
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: d5c4c596-5bef-4f34-b6ea-d41350b8f40b
📒 Files selected for processing (3)
commit_check/engine.pytests/engine_test.pytests/main_test.py
- accumulate every validated ref pair in no_force_push instead of overwriting on multi-ref pushes - record the resolved commit author for the ignore_authors rule and keep the value empty when the author is ignored - record the scanned message for ai_attribution when forbid policy finds no signature; ignore policy remains a no-op without a value
Merging this PR will improve performance by ×3.4
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
The checked value now shares the branch name with the failure path instead of issuing a second git subprocess call, keeping the upstream fallback path at one branch-name lookup per run.
validate_all_detailed opts validators into value collection; text-mode validation stays free of the extra git subprocess calls (branch name lookup in the force-push upstream fallback, author resolution for ignore_authors), keeping the benchmarked pass paths unchanged.
|
## What Adds the v2.13.1 entry to the changelog: - **New feature**: `--format json` and `validate_all_detailed()` now report the checked value on passing checks (PR [commit-check/commit-check#522](commit-check/commit-check#522)) - Highlights table row for 2.13.1, linking to the "Output for scripts and CI" recipe



What
validate_all_detailed()now populatesCheckOutcome.valueon pass as well as fail, with the concrete value each validator actually checked.Why
Structured consumers (
--format json, the Python API, and commit-check-action) currently receivevalue: ""for every passing check. The action's success report wants to show what was validated (PR title, commit subject, branch name, author name/email) — that data is collected in the validators but thrown away on pass.Changes
BaseValidator._checked_value— set by each validator to the value it checkedmessage, signoff, body, commit-type checks), subject (subject_*), author name/email, branch name, merge-base target, push refs (no_force_push)validate_all_detailed()pass branch passesvalidator._checked_valuethroughCheckOutcome.valuedocstring updated_collect_value, set byvalidate_all_detailed); text-mode validation stays free of the extra lookups and keeps values emptyNo change to terminal output: the text path never printed values on pass, and it still doesn't.
Example
{ "rule_id": "CC001", "check": "message", "status": "pass", "value": "feat: add login page" }Value semantics
valueis the raw input the validator actually checked, identical on pass and fail (fail uses the same value recorded by_print_failure), except where noted:valueon passvalueon failmessage,require_signed_off_by,require_body,allow_*_commitssubject_*author_name/author_emailbranchmerge_baseno_force_pushlocal_ref -> remote_refper pushed ref (newline-separated when several) orbranch -> upstreamai_attributionNotes for consumers:
ai_attributionis the one check where pass/fail values have different shapes (message vs. tool list) by design.ignore_authors, no upstream configured for force push),valuestays"".Tests
_collect_valueoff skips the branch lookup)Summary by CodeRabbit