feat!: Scopes-Patterns matrix support, special chars in scopes support#17
Conversation
|
Warning Review limit reached
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 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 (15)
📝 WalkthroughWalkthroughThis 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. ChangesV3 Migration: Patterns Configuration Refactoring
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
Suggested labels
🚥 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.
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 winStale 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 oldconfig.json. After this v3 migration, this link is inconsistent (and likely broken ifconfig.jsonwas 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 winUse
glob.QuoteMetawhen building the zero-config default glob fromscope(to handle glob metacharacters).
gobwas/globprovidesglob.QuoteMetato escape glob metacharacters, so use it onscopebefore appending"/**"to avoid mismatches or compile-timepanics for valid configs wherescopecontains*,?,[,{, 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 valueReduce brittleness in
OutsiderFinderPattern(cfgPattern)(optional)
OutsiderFinderPattern(cfgPattern)works today becausePatternItemandOutsiderFinderPatternboth haveScopes []stringandFiles []stringin the same order; themapstructuretags onPatternItemdon’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
📒 Files selected for processing (15)
README.mdcmd/commands/init.gocmd/commands/run.gocmd/root.godocs/schema/config.v3.jsongo.modmain.gopkg/validator/config.gopkg/validator/config_test.gopkg/validator/git_test.gopkg/validator/outsider_finder.gopkg/validator/outsider_finder_test.gopkg/validator/scope_parser_test.gopkg/validator/validator.gopkg/validator/validator_test.go
052c730 to
23bed27
Compare
23bed27 to
24aae1c
Compare
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
Documentation
Chores