Skip to content

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.

'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',
],

Patterns use PHP’s PCRE regex syntax:

Element Meaning
\b Word boundary
`(a b
/i Case-insensitive matching

Identifies commits that fix issues. These affect:

  • msg.fix_keyword_count signal
  • msg.fix_ratio signal
  • Follow-up fix detection
  • fix — General fixes
  • bug — Bug fixes
  • hotfix — Urgent fixes
  • patch — Patches
  • typo — Typo corrections
  • oops — Mistake corrections

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',

Identifies commits that undo previous changes. Reverts trigger a significant score penalty (-15 points).

  • revert — Standard git revert messages

Include rollback terminology:

'revert_pattern' => '/\b(revert|rollback|undo)\b/i',

Match “Revert:” prefix:

'revert_pattern' => '/^Revert:|\b(revert|rollback)\b/i',

Identifies work-in-progress or temporary commits. High WIP ratios (≥0.3) trigger a score penalty (-8 points).

  • wip — Work in progress
  • tmp — Temporary
  • debug — Debug code
  • hack — Quick hacks

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',
'keywords' => [
'fix_pattern' => '/^fix(\(.+\))?:/i',
'revert_pattern' => '/^revert(\(.+\))?:/i',
'wip_pattern' => '/^wip(\(.+\))?:|^chore\(wip\):/i',
],
'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',
],
'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',
],

Before deploying pattern changes, test them against your recent commits:

Terminal window
# List recent commit messages
git log --oneline -50
# Test pattern matching manually
php -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\";
}
"
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