Keywords Configuration
Codemetry analyzes commit messages to detect patterns like fixes, reverts, and work-in-progress commits. You can customize these patterns to match your team’s conventions.
Default Patterns
'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops)\b/i', 'revert_pattern' => '/\b(revert)\b/i', 'wip_pattern' => '/\b(wip|tmp|debug|hack)\b/i',],Pattern Syntax
Patterns use PHP’s PCRE regex syntax:
| Element | Meaning |
|---|---|
\b | Word boundary |
| `(a | b |
/i | Case-insensitive matching |
Fix Pattern
Identifies commits that fix issues. These affect:
msg.fix_keyword_countsignalmsg.fix_ratiosignal- Follow-up fix detection
Default Keywords
fix— General fixesbug— Bug fixeshotfix— Urgent fixespatch— Patchestypo— Typo correctionsoops— Mistake corrections
Customization Examples
Add more keywords:
'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops|broken|resolve|repair)\b/i',Match Jira-style prefixes:
'fix_pattern' => '/\b(fix|bug|hotfix|patch|typo|oops)\b|^(FIX|BUG)-\d+/i',Match Conventional Commits:
'fix_pattern' => '/^fix(\(.+\))?:|^bugfix:|^hotfix:/i',Revert Pattern
Identifies commits that undo previous changes. Reverts trigger a significant score penalty (-15 points).
Default Keywords
revert— Standard git revert messages
Customization Examples
Include rollback terminology:
'revert_pattern' => '/\b(revert|rollback|undo)\b/i',Match “Revert:” prefix:
'revert_pattern' => '/^Revert:|\b(revert|rollback)\b/i',WIP Pattern
Identifies work-in-progress or temporary commits. High WIP ratios (≥0.3) trigger a score penalty (-8 points).
Default Keywords
wip— Work in progresstmp— Temporarydebug— Debug codehack— Quick hacks
Customization Examples
Include more WIP indicators:
'wip_pattern' => '/\b(wip|tmp|debug|hack|todo|fixme|xxx|temp|draft)\b/i',Match [WIP] prefix style:
'wip_pattern' => '/^\[WIP\]|\[DRAFT\]|\b(wip|tmp|debug|hack)\b/i',Team Convention Examples
Conventional Commits
'keywords' => [ 'fix_pattern' => '/^fix(\(.+\))?:/i', 'revert_pattern' => '/^revert(\(.+\))?:/i', 'wip_pattern' => '/^wip(\(.+\))?:|^chore\(wip\):/i',],Jira Integration
'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix)\b|(FIX|BUG|HOTFIX)-\d+/i', 'revert_pattern' => '/\b(revert)\b|REVERT-\d+/i', 'wip_pattern' => '/\b(wip|tmp)\b|\[WIP\]/i',],GitHub Issue References
'keywords' => [ 'fix_pattern' => '/\b(fix|bug|hotfix|closes|fixes)\b|#\d+/i', 'revert_pattern' => '/\b(revert)\b/i', 'wip_pattern' => '/\b(wip|tmp|debug|hack)\b/i',],Testing Your Patterns
Before deploying pattern changes, test them against your recent commits:
# List recent commit messagesgit log --oneline -50
# Test pattern matching manuallyphp -r "\$pattern = '/\b(fix|bug|hotfix)\b/i';\$messages = [ 'Fix login validation', 'Add new feature', 'bugfix: user registration', 'Update README',];foreach (\$messages as \$msg) { \$match = preg_match(\$pattern, \$msg) ? '✓' : '✗'; echo \"\$match \$msg\n\";}"Impact on Scoring
| Pattern | Signal Affected | Scoring Impact |
|---|---|---|
| Fix | msg.fix_keyword_count, msg.fix_ratio | Indirect (context for other signals) |
| Fix | followup.fix_commits | High fix density = score penalty |
| Revert | msg.revert_count | Any revert = -15 points |
| WIP | msg.wip_count, WIP ratio | WIP ratio ≥0.3 = -8 points |