feat: add imperative mode - #258
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughA new imperative mood check for commit messages was introduced. This includes a wordlist of imperative verbs, a new check function, CLI integration, configuration updates, documentation, and comprehensive tests. The check can be enabled via CLI or pre-commit configuration, and ensures commit messages use the imperative mood in their subject lines. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant CommitCheckMain
participant CommitCheckCommit
participant ImperativesSet
User->>CLI: Run commit-check --imperative -m <msg>
CLI->>CommitCheckMain: Parse arguments
CommitCheckMain->>CommitCheckCommit: check_imperative(checks, commit_msg_file)
CommitCheckCommit->>ImperativesSet: Load imperative verbs
CommitCheckCommit->>CommitCheckCommit: Analyze commit message subject
CommitCheckCommit->>CommitCheckMain: Return PASS/FAIL
CommitCheckMain->>CLI: Output result
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #258 +/- ##
===========================================
- Coverage 100.00% 99.13% -0.87%
===========================================
Files 7 8 +1
Lines 300 347 +47
===========================================
+ Hits 300 344 +44
- Misses 0 3 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #258 will degrade performances by 11.52%Comparing 🎉 Hooray!
|
| Benchmark | BASE |
HEAD |
Change | |
|---|---|---|---|---|
| 🆕 | test_check_imperative_different_check_type |
N/A | 964.3 µs | N/A |
| 🆕 | test_check_imperative_empty_checks |
N/A | 959.8 µs | N/A |
| 🆕 | test_check_imperative_fail_past_tense |
N/A | 2.6 ms | N/A |
| 🆕 | test_check_imperative_fail_present_continuous |
N/A | 2.6 ms | N/A |
| 🆕 | test_check_imperative_no_commits |
N/A | 787.2 µs | N/A |
| 🆕 | test_check_imperative_pass |
N/A | 1 ms | N/A |
| 🆕 | test_check_imperative_skip_merge_commit |
N/A | 1 ms | N/A |
| 🆕 | test_is_imperative_invalid_cases |
N/A | 186.6 µs | N/A |
| 🆕 | test_is_imperative_valid_cases |
N/A | 145.3 µs | N/A |
| 🆕 | test_main[argv0-1-0-0-0-0-0] |
N/A | 5.7 ms | N/A |
test_main[argv0-1-0-0-0-0] |
5.1 ms | N/A | N/A | |
| 🆕 | test_main[argv1-0-1-0-0-0-0] |
N/A | 5.7 ms | N/A |
test_main[argv1-0-1-0-0-0] |
5.1 ms | N/A | N/A | |
| 🆕 | test_main[argv10-1-1-1-0-0-0] |
N/A | 6.3 ms | N/A |
test_main[argv10-1-1-2-0-0] |
5.7 ms | N/A | N/A | |
| 🆕 | test_main[argv11-1-1-2-0-0-0] |
N/A | 6.3 ms | N/A |
test_main[argv11-1-1-2-1-1] |
6.3 ms | N/A | N/A | |
test_main[argv12-0-0-0-0-0] |
4.4 ms | N/A | N/A | |
| 🆕 | test_main[argv12-1-1-2-1-1-0] |
N/A | 6.9 ms | N/A |
| 🆕 | test_main[argv13-1-0-0-0-0-1] |
N/A | 6 ms | N/A |
| ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
|
* feat: report a skipped check as skipped, not as passed A rule that never ran was reported as a pass. commit-check-action#258 is the visible cost: every check on it rendered as a green tick and the summary announced "All 5 checks passed", when in fact nothing had been validated -- the author is dependabot[bot], which the org config lists in ignore_authors. A bypassed policy was indistinguishable from an enforced one, in the JSON, in the Python API, and in anything rendering them. Measured on that exact case before the change: every rule came back "status": "pass" with "value": "", the empty value being the only trace that a skip had happened, and an incidental one at that. Adds ValidationResult.SKIP and returns it from the guards that already decide this -- _should_skip_commit_validation, _should_skip_branch_ validation, and the ignored-author branch of _validate_author. Those helpers are named for skipping; they were simply reporting it as PASS. validate_all_detailed maps SKIP to "skip" and forces the value empty, since a rule that did not run examined nothing. Overall status is "skip" only when every check skipped; one real verdict still yields "pass" or "fail". Only "fail" is an error, so the exit code is unchanged for existing callers and code branching on status == "fail" keeps working. The overall-status rule was duplicated between the CLI's --format json and the Python API, which is how the CLI kept printing "pass" for a fully skipped run after the API had been fixed. It now lives once, in engine.overall_status(), used by both. That also fixes a latent bug in the CLI's exit code: `0 if overall == "pass" else 1` would have turned a skipped run into a failure. Verified end to end in a repository shaped like #258 -- same repo, same config, only the author differing: dependabot[bot] -> overall "skip", every check "skip", exit 0 a human -> overall "pass", values reported, exit 0 a human, bad msg -> exit 1 The twelve existing tests that asserted PASS on these paths are all named for skipping (ignored_author, skips_validation, skip_conditions); they now assert SKIP. Four new API tests pin the behaviour, including a control that only the author differs so the skip test cannot pass by the rules having quietly stopped running for everyone. Reverting the skip reporting turns the first of them red. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U9zFxq8V4qxG4aMzJhGBFn * fix: preserve skip when the API merges checks from several runs Review caught a third and fourth copy of the reduce-to-overall rule that the first commit missed. validate_author(name=..., email=...) merges two separate runs, and validate_all() merges up to three; each combined its checks with a private `"fail" if any(...) else "pass"`, so a call in which every nested check skipped still reported "pass" -- the exact defect the skip status exists to prevent, surviving in the two entry points most likely to be called by automation. overall_status() now takes plain status strings rather than CheckOutcome objects, which is what lets every caller share it: the CLI, _build_result, and both combined paths, which hold already-serialised dicts. Four copies of this rule is how it drifted in the first place, so there is now one. Both new tests fail if the per-path rule is restored. Also covers the two skip branches codecov flagged, in BodyValidator and in CommitTypeValidator's non-ignore_authors path. Each comes with a control that changes only the author, so neither can pass by the rule having quietly stopped running for everyone. No line added by this PR is left uncovered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U9zFxq8V4qxG4aMzJhGBFn --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>



closes #256
Summary by CodeRabbit