Skip to content

feat: update cchk output with more explicit error messages#383

Merged
shenxianpeng merged 4 commits into
mainfrom
feature/update-output-and-contributing
Mar 19, 2026
Merged

feat: update cchk output with more explicit error messages#383
shenxianpeng merged 4 commits into
mainfrom
feature/update-output-and-contributing

Conversation

@shenxianpeng
Copy link
Copy Markdown
Member

@shenxianpeng shenxianpeng commented Mar 17, 2026

Summary by CodeRabbit

  • Documentation

    • Expanded contributor guide with architecture overview, development setup, test/validation workflow, configuration priorities, and contribution tips.
  • Improvements

    • Better commit message guidance with clearer examples and dynamic suggestion text for allowed types.
    • Simplified error output to avoid printing raw regex details.
  • Tests

    • Updated tests to match the revised error message behavior.

@shenxianpeng shenxianpeng requested a review from a team as a code owner March 17, 2026 22:30
@shenxianpeng shenxianpeng added the documentation Improvements or additions to documentation label Mar 17, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 17, 2026

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit bdaa3fb
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/69ba3d629a11aa0008cfb2ee
😎 Deploy Preview https://deploy-preview-383--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the enhancement New feature or request label Mar 17, 2026
@shenxianpeng shenxianpeng force-pushed the feature/update-output-and-contributing branch from b8977d2 to 1aa9808 Compare March 17, 2026 22:31
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Converts CONTRIBUTING.md into an extensive architecture and developer guide, changes commit validation messaging to generate dynamic suggestions and clarifies imperative-subject guidance, and simplifies error-output handling by removing regex display and updating its call sites and tests.

Changes

Cohort / File(s) Summary
Documentation
CONTRIBUTING.md
Replaces a short contributor note with a full architecture and development guide (architecture overview, pipeline flow, module responsibilities, validator hierarchy, config priority, development and testing workflow, pre-commit/debug guidance, and closing civility line).
Rule building & catalog
commit_check/rule_builder.py, commit_check/rules_catalog.py
rule_builder.py now generates a dynamic suggest string listing allowed commit types for conventional-commit rules; rules_catalog.py updates subject_imperative messages to show explicit examples of non-imperative vs imperative forms and clearer corrective suggestions.
Error output & tests
commit_check/util.py, tests/util_test.py
print_error_message signature changed to remove the regex parameter; it now conditionally prints the error text only when present. Call sites and tests updated to the new signature and removed assertions about regex output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • commit-check/commit-check#329: Edits to the subject_imperative rule in commit_check/rules_catalog.py (related messaging changes).
  • commit-check/commit-check#276: Changes touching error/failure printing and _print_failure callers in commit_check/util.py (overlaps on print_error_message behavior).

Poem

🐰
I hopped through docs to spread the news,
Types listed neatly in tidy queues,
Error whispers now, no regex shout,
Validators tidy, tests check out,
A little rabbit hop — hooray for review!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating error message output to be more explicit, which aligns with changes across rule_builder.py, rules_catalog.py, and util.py that refactor error messaging.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/update-output-and-contributing
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.67%. Comparing base (7a54cc9) to head (bdaa3fb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   94.65%   94.67%   +0.01%     
==========================================
  Files           9        9              
  Lines         805      807       +2     
==========================================
+ Hits          762      764       +2     
  Misses         43       43              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
commit_check/util.py (1)

258-259: Consider a fallback message when error is empty.

Right now, if error is blank, users lose the expected constraint context even though regex is available.

Proposed refinement
-    if error:
-        print(error)
+    if error:
+        print(error)
+    elif regex:
+        print(f"Expected constraint: {regex}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commit_check/util.py` around lines 258 - 259, The current print branch only
emits error when the variable error is truthy, so callers lose context if error
is empty; update the logic around the if error: print(error) block in
commit_check/util.py (the variables error and regex) to print a fallback message
when error is falsy—e.g., print a concise constraint hint that includes the
regex value or a default string like "constraint not met: expected pattern
{regex}"—so users always see either the specific error or the regex-based
constraint context.
CONTRIBUTING.md (1)

98-151: Add a manual validation checklist to contributor workflow.

Given this project’s validator breadth, a short manual test checklist in this section would reduce regressions.

Based on learnings: Test validation scenarios manually after changes including valid commits, invalid formats, complex commits, branch names, help/version, and configuration validation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTRIBUTING.md` around lines 98 - 151, Add a short manual validation
checklist to the contributor workflow in CONTRIBUTING.md under the
pre-commit/testing section: create a "Manual validation checklist" paragraph
after the "Test the pre-commit hook on GitHub" block that lists concrete manual
test scenarios to run (e.g., validate a valid commit message, test
invalid/edge-case commit formats, multi-line/complex commits, branch-name
checks, check help/version output for check-message and check-branch, and run
configuration validation), and include the exact commands shown (pre-commit
try-repo, commit-check -m, pytest/nox/lint commands) as examples so contributors
can reproduce each step easily.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@commit_check/rule_builder.py`:
- Around line 113-116: The suggestion text currently joins allowed_types into
types_str and yields "one of:" even when allowed_types is empty; update the
logic around types_str/suggest (the variables used at Lines where allowed_types
and suggest are set) to guard against an empty allow_commit_types list by
detecting if allowed_types is truthy and, if empty, set types_str to a fallback
like "none specified" or replace the whole suggest text with a generic "Use
<type>(<scope>): <description>" guidance (or explicitly state allowed types are
not configured) so the suggestion remains meaningful when allow_commit_types is
an empty list.

In `@commit_check/rules_catalog.py`:
- Around line 32-33: The imperative mood examples in the rule's error and
suggest strings conflict with the subject_capitalized policy: update the
messages in the rule (the error and suggest values shown) to use capitalized
imperative examples (e.g., "Fix", "Add") or explicitly state that the first verb
should be capitalized to match subject_capitalized; locate these strings in
rules_catalog.py where the rule is defined and make the wording consistent with
subject_capitalized.

In `@CONTRIBUTING.md`:
- Around line 23-40: The fenced code blocks in CONTRIBUTING.md that contain the
three ASCII diagrams (the block starting with "CLI args / Env vars / TOML file",
the block containing "commit_check/", and the block containing "BaseValidator
(ABC)") lack language identifiers and trigger MD040; update each opening
triple-backtick to include a language tag (use ```text) so the blocks become
```text ... ```, preserving the existing content and closing backticks
unchanged.
- Around line 63-64: The description for SubjectCapitalizationValidator is
inverted: update its text from "First letter must be lowercase" to the correct
rule "First letter must be uppercase" (or equivalent wording) so it matches the
validator's intent; verify the adjacent SubjectImperativeValidator entry remains
"Subject must start with imperative verb" and adjust wording for consistency if
needed.

---

Nitpick comments:
In `@commit_check/util.py`:
- Around line 258-259: The current print branch only emits error when the
variable error is truthy, so callers lose context if error is empty; update the
logic around the if error: print(error) block in commit_check/util.py (the
variables error and regex) to print a fallback message when error is falsy—e.g.,
print a concise constraint hint that includes the regex value or a default
string like "constraint not met: expected pattern {regex}"—so users always see
either the specific error or the regex-based constraint context.

In `@CONTRIBUTING.md`:
- Around line 98-151: Add a short manual validation checklist to the contributor
workflow in CONTRIBUTING.md under the pre-commit/testing section: create a
"Manual validation checklist" paragraph after the "Test the pre-commit hook on
GitHub" block that lists concrete manual test scenarios to run (e.g., validate a
valid commit message, test invalid/edge-case commit formats, multi-line/complex
commits, branch-name checks, check help/version output for check-message and
check-branch, and run configuration validation), and include the exact commands
shown (pre-commit try-repo, commit-check -m, pytest/nox/lint commands) as
examples so contributors can reproduce each step easily.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 336a2379-061a-4fd3-bc61-df3f4a0e574b

📥 Commits

Reviewing files that changed from the base of the PR and between 7a54cc9 and 1aa9808.

📒 Files selected for processing (5)
  • CONTRIBUTING.md
  • commit_check/rule_builder.py
  • commit_check/rules_catalog.py
  • commit_check/util.py
  • tests/util_test.py
💤 Files with no reviewable changes (1)
  • tests/util_test.py

Comment on lines +113 to +116
types_str = ", ".join(allowed_types)
suggest = (
f"Use <type>(<scope>): <description>, where <type> is one of: {types_str}"
)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard against empty allow_commit_types before building suggestion text.

If config provides an empty list, Line 115 renders one of: with no values, and commit guidance becomes unusable.

Proposed fix
         allowed_types = self._get_allowed_commit_types()
+        if not allowed_types:
+            allowed_types = DEFAULT_COMMIT_TYPES
         regex = self._build_conventional_commit_regex(allowed_types)

         types_str = ", ".join(allowed_types)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commit_check/rule_builder.py` around lines 113 - 116, The suggestion text
currently joins allowed_types into types_str and yields "one of:" even when
allowed_types is empty; update the logic around types_str/suggest (the variables
used at Lines where allowed_types and suggest are set) to guard against an empty
allow_commit_types list by detecting if allowed_types is truthy and, if empty,
set types_str to a fallback like "none specified" or replace the whole suggest
text with a generic "Use <type>(<scope>): <description>" guidance (or explicitly
state allowed types are not configured) so the suggestion remains meaningful
when allow_commit_types is an empty list.

Copy link
Copy Markdown
Member Author

@shenxianpeng shenxianpeng Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, apply the change @coderabbitai

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenxianpeng, sure! Here's the plan to apply the fix:

  • Add an empty-list guard in _build_conventional_commit_rule after calling _get_allowed_commit_types(), falling back to DEFAULT_COMMIT_TYPES (already imported).

🧠 Learnings used
Learnt from: CR
Repo: commit-check/commit-check PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-02T05:17:44.250Z
Learning: Applies to commit_check/rules_catalog.py : Validate conventional commits with format: type(scope): description, supporting types build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test

Learnt from: CR
Repo: commit-check/commit-check PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-02T05:17:44.250Z
Learning: Applies to commit_check/__init__.py : Store default validation types in commit_check/__init__.py (DEFAULT_COMMIT_TYPES, DEFAULT_BRANCH_TYPES, DEFAULT_BOOLEAN_RULES)

Learnt from: CR
Repo: commit-check/commit-check PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-02T05:17:44.250Z
Learning: Applies to commit_check/rules_catalog.py : Validate branch names with conventional patterns: bugfix/, feature/, release/, hotfix/, task/, chore/ prefixes, and special branches master, main, HEAD, PR-*

Learnt from: CR
Repo: commit-check/commit-check PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-02T05:17:44.250Z
Learning: Applies to commit_check/util.py : Use colorized ASCII art rejection message in output when validation fails

Failed to handle agent chat message. Please try again.

Comment thread commit_check/rules_catalog.py
Comment thread CONTRIBUTING.md
Comment thread CONTRIBUTING.md Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 170 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing feature/update-output-and-contributing (bdaa3fb) with main (5e3a210)2

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (7a54cc9) during the generation of this report, so 5e3a210 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@shenxianpeng shenxianpeng requested a review from Copilot March 17, 2026 22:36
@shenxianpeng shenxianpeng changed the title docs: update output and contributing feat: update output and contributing Mar 17, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tests/util_test.py (1)

323-331: Missing assertion for reason parameter in test.

The test passes dummy_reason to print_error_message but doesn't assert that it appears in stdout. Since reason is printed in the output (check failed ==> {reason}), adding this assertion would improve test coverage.

🧪 Suggested fix to add missing assertion
         def test_print_error_message(self, capfd, check_type, type_failed_msg):
             # Must print on stdout with given argument.
             dummy_reason = "failure reason"
             dummy_error = "dummy error"
             print_error_message(check_type, dummy_error, dummy_reason)
             stdout, _ = capfd.readouterr()
             assert check_type in stdout
             assert type_failed_msg in stdout
             assert dummy_error in stdout
+            assert dummy_reason in stdout
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/util_test.py` around lines 323 - 331, The test test_print_error_message
currently calls print_error_message(check_type, dummy_error, dummy_reason) but
never asserts that the reason appears in output; update the
test_print_error_message to assert that dummy_reason is present in stdout (e.g.,
assert dummy_reason in stdout) so the printed "check failed ==> {reason}" is
verified; locate this in the test function using the test_print_error_message
name and the dummy_reason variable.
commit_check/util.py (1)

35-41: Unused regex parameter in _print_failure.

The regex parameter is still accepted for backward compatibility with callers like engine.py (which passes constraint), but it's no longer used or passed downstream. Consider documenting this in the docstring, or if the callers can be updated, removing the parameter entirely to avoid confusion.

📝 Suggested documentation update
 def _print_failure(check: dict, regex: str, actual: str) -> None:
-    """Print a standardized failure message."""
+    """Print a standardized failure message.
+    
+    Note: The `regex` parameter is retained for API compatibility but is no longer displayed.
+    """
     if not print_error_header.has_been_called:
         print_error_header()
     print_error_message(check["check"], check.get("error", ""), actual)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commit_check/util.py` around lines 35 - 41, The `_print_failure` function
currently accepts an unused `regex` parameter; update the function to either
remove the `regex` parameter from `_print_failure` (and update callers like
`engine.py`) or, if you must keep it for backward compatibility, amend the
`_print_failure` docstring to explicitly state that `regex`/`constraint` is
accepted but ignored and kept only for compatibility; locate `_print_failure`
and adjust its signature or docstring accordingly and ensure calls to
`print_error_header`, `print_error_message`, and `print_suggestion` (and the
`print_error_header.has_been_called` check) remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@commit_check/util.py`:
- Around line 35-41: The `_print_failure` function currently accepts an unused
`regex` parameter; update the function to either remove the `regex` parameter
from `_print_failure` (and update callers like `engine.py`) or, if you must keep
it for backward compatibility, amend the `_print_failure` docstring to
explicitly state that `regex`/`constraint` is accepted but ignored and kept only
for compatibility; locate `_print_failure` and adjust its signature or docstring
accordingly and ensure calls to `print_error_header`, `print_error_message`, and
`print_suggestion` (and the `print_error_header.has_been_called` check) remain
unchanged.

In `@tests/util_test.py`:
- Around line 323-331: The test test_print_error_message currently calls
print_error_message(check_type, dummy_error, dummy_reason) but never asserts
that the reason appears in output; update the test_print_error_message to assert
that dummy_reason is present in stdout (e.g., assert dummy_reason in stdout) so
the printed "check failed ==> {reason}" is verified; locate this in the test
function using the test_print_error_message name and the dummy_reason variable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d67ada7-4847-474b-a8b7-1f2b075f93d5

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa9808 and 25b2b02.

📒 Files selected for processing (2)
  • commit_check/util.py
  • tests/util_test.py

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the contributor documentation with an architecture/development overview and refines CLI failure output to provide clearer, more actionable guidance (notably around commit message validation).

Changes:

  • Updated failure output formatting by simplifying print_error_message() output and adjusting related tests.
  • Improved commit validation guidance by enriching rule catalog messages and generating a dynamic “allowed types” suggestion for Conventional Commits.
  • Expanded CONTRIBUTING.md with architecture/module breakdown and a more complete local development workflow.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/util_test.py Updates test expectations to match the new print_error_message() signature/output.
commit_check/util.py Removes regex/constraint line from failure output and updates call sites accordingly.
commit_check/rules_catalog.py Refines imperative-mood error/suggestion text to include clearer examples.
commit_check/rule_builder.py Generates a dynamic Conventional Commit suggestion including configured allowed types.
CONTRIBUTING.md Adds architecture + dev workflow docs; introduces a capitalization-description inconsistency to fix.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread commit_check/util.py
if not print_error_header.has_been_called:
print_error_header()
print_error_message(check["check"], regex, check.get("error", ""), actual)
print_error_message(check["check"], check.get("error", ""), actual)
Comment thread CONTRIBUTING.md Outdated
Comment thread commit_check/rule_builder.py
@shenxianpeng shenxianpeng changed the title feat: update output and contributing feat: update cchkoutput and contributing Mar 18, 2026
@shenxianpeng shenxianpeng changed the title feat: update cchkoutput and contributing feat: update cchk output and contributing Mar 18, 2026
@shenxianpeng shenxianpeng changed the title feat: update cchk output and contributing feat: update cchk output with more explicit error messages Mar 18, 2026
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
CONTRIBUTING.md (1)

23-40: ⚠️ Potential issue | 🟡 Minor

Add language tags to fenced architecture/code-tree blocks.

Line 23, Line 44, and Line 59 still use unlabeled triple-backtick fences, which triggers MD040.

Proposed fix
-```
+```text
 CLI args / Env vars / TOML file
@@
-```
+```

-```
+```text
 commit_check/
@@
-```
+```

-```
+```text
 BaseValidator (ABC)
@@
-```
+```

Also applies to: 44-55, 59-72

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTRIBUTING.md` around lines 23 - 40, Several fenced code/diagram blocks in
CONTRIBUTING.md (the ASCII diagrams and the commit_check/ and BaseValidator
blocks) lack language labels, triggering MD040; add a language tag (use "text")
to each unlabeled triple-backtick fence around the diagrams and code-tree blocks
(the blocks containing "CLI args / Env vars / TOML file → ConfigMerger →
RuleBuilder → ValidationEngine → BaseValidator subclasses", the "commit_check/"
block, and the "BaseValidator (ABC)" block) so each opening fence becomes
```text and the closing fences remain ``` to satisfy the markdown linter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CONTRIBUTING.md`:
- Around line 49-50: Update the merge-order wording in CONTRIBUTING.md where the
ConfigMerger description reads "merges CLI → Env → TOML → Defaults" to correctly
state that merging happens from Defaults up to TOML → Env → CLI with CLI being
highest priority (i.e., priority is CLI highest), and explicitly enumerate the
TOML discovery order in the doc (add the sequence: --config argument, cchk.toml,
commit-check.toml, .github/cchk.toml, .github/commit-check.toml) to replace the
ambiguous text found near the RuleBuilder/ConfigMerger description and the later
TOML notes so both occurrences are consistent.

---

Duplicate comments:
In `@CONTRIBUTING.md`:
- Around line 23-40: Several fenced code/diagram blocks in CONTRIBUTING.md (the
ASCII diagrams and the commit_check/ and BaseValidator blocks) lack language
labels, triggering MD040; add a language tag (use "text") to each unlabeled
triple-backtick fence around the diagrams and code-tree blocks (the blocks
containing "CLI args / Env vars / TOML file → ConfigMerger → RuleBuilder →
ValidationEngine → BaseValidator subclasses", the "commit_check/" block, and the
"BaseValidator (ABC)" block) so each opening fence becomes ```text and the
closing fences remain ``` to satisfy the markdown linter.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b979d0d-ae9f-443f-a544-522f893cca2e

📥 Commits

Reviewing files that changed from the base of the PR and between 25b2b02 and bdaa3fb.

📒 Files selected for processing (1)
  • CONTRIBUTING.md

Comment thread CONTRIBUTING.md
Comment on lines +49 to +50
├── config_merger.py # ConfigMerger: merges CLI → Env → TOML → Defaults
├── rule_builder.py # RuleBuilder: creates ValidationRule objects from config + catalog
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Correct config merge-order wording and make TOML discovery order explicit.

Line 49 currently implies merge is performed from CLI down to defaults, but implementation merges in the opposite direction and only priority is CLI highest. Also, Line 80 should explicitly enumerate the TOML discovery order to avoid ambiguity.

Proposed wording update
-├── config_merger.py     # ConfigMerger: merges CLI → Env → TOML → Defaults
+├── config_merger.py     # ConfigMerger: merges Defaults → TOML → Env → CLI (effective priority: CLI > Env > TOML > Defaults)
@@
-| 3 | TOML config files | `cchk.toml`, `.github/cchk.toml`, etc. |
+| 3 | TOML config files | `--config` path, then `cchk.toml`, `commit-check.toml`, `.github/cchk.toml`, `.github/commit-check.toml` |

Based on learnings: "Define TOML configuration discovery order: --config argument, cchk.toml, commit-check.toml, .github/cchk.toml, .github/commit-check.toml".

Also applies to: 80-81

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTRIBUTING.md` around lines 49 - 50, Update the merge-order wording in
CONTRIBUTING.md where the ConfigMerger description reads "merges CLI → Env →
TOML → Defaults" to correctly state that merging happens from Defaults up to
TOML → Env → CLI with CLI being highest priority (i.e., priority is CLI
highest), and explicitly enumerate the TOML discovery order in the doc (add the
sequence: --config argument, cchk.toml, commit-check.toml, .github/cchk.toml,
.github/commit-check.toml) to replace the ambiguous text found near the
RuleBuilder/ConfigMerger description and the later TOML notes so both
occurrences are consistent.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines Commit Check’s user-facing output by removing raw regex details from failure messages, and updates guidance/docs to better explain correct commit formats and contribution workflows.

Changes:

  • Simplifies failure output by no longer printing the regex string and only printing the configured error message when present.
  • Makes Conventional Commit suggestions more explicit by dynamically listing the allowed commit types.
  • Expands CONTRIBUTING.md with architecture and local dev/test/lint/docs workflows.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
commit_check/util.py Updates failure printing to omit regex details and adjusts print_error_message signature/behavior.
tests/util_test.py Updates tests to match the new print_error_message signature and output.
commit_check/rules_catalog.py Improves imperative-mood rule wording and suggestion text.
commit_check/rule_builder.py Builds a dynamic suggestion for Conventional Commit failures including allowed types.
CONTRIBUTING.md Adds architecture overview and contributor workflow/setup documentation.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread commit_check/util.py
if not print_error_header.has_been_called:
print_error_header()
print_error_message(check["check"], regex, check.get("error", ""), actual)
print_error_message(check["check"], check.get("error", ""), actual)
Comment thread commit_check/util.py


def print_error_message(check_type: str, regex: str, error: str, reason: str):
def print_error_message(check_type: str, error: str, reason: str):
Comment on lines 110 to +116
allowed_types = self._get_allowed_commit_types()
regex = self._build_conventional_commit_regex(allowed_types)

types_str = ", ".join(allowed_types)
suggest = (
f"Use <type>(<scope>): <description>, where <type> is one of: {types_str}"
)
Comment thread CONTRIBUTING.md
@shenxianpeng shenxianpeng merged commit e45d40c into main Mar 19, 2026
40 checks passed
@shenxianpeng shenxianpeng deleted the feature/update-output-and-contributing branch March 19, 2026 05:57
@shenxianpeng shenxianpeng removed the documentation Improvements or additions to documentation label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants