Skip to content

feat!: Scopes-Patterns matrix support, special chars in scopes support#17

Merged
thumbrise merged 1 commit into
mainfrom
scopes-patterns-matrix
May 29, 2026
Merged

feat!: Scopes-Patterns matrix support, special chars in scopes support#17
thumbrise merged 1 commit into
mainfrom
scopes-patterns-matrix

Conversation

@thumbrise
Copy link
Copy Markdown
Owner

@thumbrise thumbrise commented May 29, 2026

Summary by CodeRabbit

  • Documentation

    • Updated configuration schema and examples to v3 format with restructured patterns configuration
    • Added JSON Schema documentation for the new v3 configuration format
  • Chores

    • Released version 3 with updated module dependencies across all components

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@thumbrise, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 13 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 92dec75b-b456-474b-a8c0-29559a71b5c0

📥 Commits

Reviewing files that changed from the base of the PR and between 052c730 and 24aae1c.

📒 Files selected for processing (15)
  • README.md
  • cmd/commands/init.go
  • cmd/commands/run.go
  • cmd/root.go
  • docs/schema/config.v3.json
  • go.mod
  • main.go
  • pkg/validator/config.go
  • pkg/validator/config_test.go
  • pkg/validator/git_test.go
  • pkg/validator/outsider_finder.go
  • pkg/validator/outsider_finder_test.go
  • pkg/validator/scope_parser_test.go
  • pkg/validator/validator.go
  • pkg/validator/validator_test.go
📝 Walkthrough

Walkthrough

This PR migrates commitlint-scope from v2 to v3 by restructuring the patterns configuration from a scope-keyed map to a list of pattern objects. The changes include new type definitions, a JSON schema, refactored outsider-finder logic, updated imports across the codebase, comprehensive test coverage, and user-facing documentation updates.

Changes

V3 Migration: Patterns Configuration Refactoring

Layer / File(s) Summary
Configuration schema definition and Go types
docs/schema/config.v3.json, pkg/validator/config.go
New config.v3.json JSON Schema and Go PatternItem struct establish the v3 contract: patterns are now a list of objects with scopes and files arrays instead of a scope-keyed map[string][]string.
Module version and import path migration
go.mod, main.go, cmd/root.go, cmd/commands/run.go, cmd/commands/init.go, pkg/validator/config_test.go, pkg/validator/git_test.go, pkg/validator/outsider_finder_test.go, pkg/validator/scope_parser_test.go, pkg/validator/validator_test.go
Module path incremented from /v2 to /v3 in go.mod, and all Go import paths updated across entry points, commands, and test files to reference the v3 module.
Outsider finder and validator wiring
pkg/validator/outsider_finder.go, pkg/validator/validator.go
NewDefaultOutsiderFinder signature changed to accept []OutsiderFinderPattern instead of map[string][]string, compiling globs per pattern and populating scope lookup maps; NewValidator adapted to convert Config.Patterns slice into the new pattern format before wiring.
Configuration and outsider finder tests
pkg/validator/config_test.go, pkg/validator/outsider_finder_test.go
Test fixtures and assertions updated to use the new PatternItem and OutsiderFinderPattern structures; test cases for patterns with default regex, custom scopeRegex, dot-scoped patterns, and multiple scopes sharing patterns all aligned with v3 format.
README and init command template updates
README.md, cmd/commands/init.go
README configuration example and init command's embedded default config template updated to demonstrate the new v3 patterns list format with scopes and files fields, and schema reference changed from config.json to config.v3.json.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The PR involves multiple related files across configuration types, validator logic, tests, and documentation, but follows a consistent refactoring pattern: replacing map-based patterns with a list-based structure. The changes are logically cohesive and repetitive in nature (similar transformations across test files), reducing per-file review complexity despite the breadth of the diff.

Possibly related PRs

  • thumbrise/commitlint-scope#5: Refactors the same pkg/validator/config.go/validator.go/outsider_finder.go contracts around configuration-driven outsider-finder initialization and scope parsing.
  • thumbrise/commitlint-scope#12: Modifies cmd/commands/init.go's embedded config template and patterns section structure.
  • thumbrise/commitlint-scope#7: Adds configuration JSON Schemas under docs/schema/ alongside the v3 schema introduced here.

Suggested labels

released

🐰 From v2 to v3, patterns dance anew,
No longer maps, but objects in view!
Each scope finds its files in structured array,
The validator hops through a brighter way.
thump-thump 📋✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: introducing a scopes-patterns matrix configuration format and supporting special characters in scopes, which are reflected across config schema updates, type changes, and version bump to v3.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 scopes-patterns-matrix

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.

@thumbrise thumbrise self-assigned this May 29, 2026
Copy link
Copy Markdown

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
README.md (1)

204-204: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Stale schema link — update to config.v3.json.

The example header at Line 98 was migrated to config.v3.json, but the "JSON schema" section still references the old config.json. After this v3 migration, this link is inconsistent (and likely broken if config.json was removed).

📝 Proposed fix
-https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.json
+https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.v3.json
🤖 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 `@README.md` at line 204, Update the stale schema link in the README: replace
the old URL
"https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.json"
referenced in the "JSON schema" section with the migrated "config.v3.json" URL
so the README points to the current schema (matches the example header that was
migrated to config.v3.json).
pkg/validator/outsider_finder.go (1)

60-71: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use glob.QuoteMeta when building the zero-config default glob from scope (to handle glob metacharacters).
gobwas/glob provides glob.QuoteMeta to escape glob metacharacters, so use it on scope before appending "/**" to avoid mismatches or compile-time panics for valid configs where scope contains *, ?, [, {, etc.

🛡️ Possible fix
-		defaultPattern := scope + "/**"
+		defaultPattern := glob.QuoteMeta(scope) + "/**"
🤖 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/outsider_finder.go` around lines 60 - 71, The defaultPattern
construction in outsider_finder.go uses scope directly which can contain glob
metacharacters; change it to escape scope with glob.QuoteMeta before appending
"/**" (i.e., build defaultPattern from glob.QuoteMeta(scope) + "/**"), then pass
that to glob.Compile; update any code paths that set globFilePatterns and
humanFilePatterns (the variables globFilePatterns, humanFilePatterns,
defaultPattern, scope and the call to glob.Compile) to use the escaped
defaultPattern so valid scopes containing *, ?, [, { etc. do not cause
compile-time errors or mismatches.
🧹 Nitpick comments (1)
pkg/validator/validator.go (1)

66-71: 💤 Low value

Reduce brittleness in OutsiderFinderPattern(cfgPattern) (optional)

OutsiderFinderPattern(cfgPattern) works today because PatternItem and OutsiderFinderPattern both have Scopes []string and Files []string in the same order; the mapstructure tags on PatternItem don’t affect explicit struct conversion. It’s still fragile: adding/renaming/reordering fields or changing their types will break compilation. An explicit field-by-field mapping would make the dependency intentional. Not blocking.

🤖 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/validator.go` around lines 66 - 71, The current direct
conversion OutsiderFinderPattern(cfgPattern) is brittle because it relies on
identical struct layouts between PatternItem and OutsiderFinderPattern; instead,
build ofPatterns by allocating each OutsiderFinderPattern and copying fields
explicitly (e.g., set Scopes, Files and any other fields from cfgPattern into a
new OutsiderFinderPattern) when iterating cfg.Patterns before calling
NewDefaultOutsiderFinder; update the loop that constructs ofPatterns to perform
field-by-field assignment to make the mapping explicit and robust to future
struct changes.
🤖 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.

Outside diff comments:
In `@pkg/validator/outsider_finder.go`:
- Around line 60-71: The defaultPattern construction in outsider_finder.go uses
scope directly which can contain glob metacharacters; change it to escape scope
with glob.QuoteMeta before appending "/**" (i.e., build defaultPattern from
glob.QuoteMeta(scope) + "/**"), then pass that to glob.Compile; update any code
paths that set globFilePatterns and humanFilePatterns (the variables
globFilePatterns, humanFilePatterns, defaultPattern, scope and the call to
glob.Compile) to use the escaped defaultPattern so valid scopes containing *, ?,
[, { etc. do not cause compile-time errors or mismatches.

In `@README.md`:
- Line 204: Update the stale schema link in the README: replace the old URL
"https://github.com/thumbrise/commitlint-scope/blob/main/docs/schema/config.json"
referenced in the "JSON schema" section with the migrated "config.v3.json" URL
so the README points to the current schema (matches the example header that was
migrated to config.v3.json).

---

Nitpick comments:
In `@pkg/validator/validator.go`:
- Around line 66-71: The current direct conversion
OutsiderFinderPattern(cfgPattern) is brittle because it relies on identical
struct layouts between PatternItem and OutsiderFinderPattern; instead, build
ofPatterns by allocating each OutsiderFinderPattern and copying fields
explicitly (e.g., set Scopes, Files and any other fields from cfgPattern into a
new OutsiderFinderPattern) when iterating cfg.Patterns before calling
NewDefaultOutsiderFinder; update the loop that constructs ofPatterns to perform
field-by-field assignment to make the mapping explicit and robust to future
struct changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 449b8f61-db27-4858-ba83-62e6c1852744

📥 Commits

Reviewing files that changed from the base of the PR and between 5fc677c and 052c730.

📒 Files selected for processing (15)
  • README.md
  • cmd/commands/init.go
  • cmd/commands/run.go
  • cmd/root.go
  • docs/schema/config.v3.json
  • go.mod
  • main.go
  • pkg/validator/config.go
  • pkg/validator/config_test.go
  • pkg/validator/git_test.go
  • pkg/validator/outsider_finder.go
  • pkg/validator/outsider_finder_test.go
  • pkg/validator/scope_parser_test.go
  • pkg/validator/validator.go
  • pkg/validator/validator_test.go

@thumbrise thumbrise force-pushed the scopes-patterns-matrix branch from 052c730 to 23bed27 Compare May 29, 2026 05:00
@thumbrise thumbrise force-pushed the scopes-patterns-matrix branch from 23bed27 to 24aae1c Compare May 29, 2026 05:01
@thumbrise thumbrise merged commit 7e8cba5 into main May 29, 2026
4 checks passed
@thumbrise thumbrise deleted the scopes-patterns-matrix branch May 29, 2026 05:03
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant