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.

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:

ElementMeaning
\bWord boundary
`(ab
/iCase-insensitive matching

Fix Pattern

Identifies commits that fix issues. These affect:

  • msg.fix_keyword_count signal
  • msg.fix_ratio signal
  • Follow-up fix detection

Default Keywords

  • fix — General fixes
  • bug — Bug fixes
  • hotfix — Urgent fixes
  • patch — Patches
  • typo — Typo corrections
  • oops — 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 progress
  • tmp — Temporary
  • debug — Debug code
  • hack — 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:

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\";
}
"

Impact on Scoring

PatternSignal AffectedScoring Impact
Fixmsg.fix_keyword_count, msg.fix_ratioIndirect (context for other signals)
Fixfollowup.fix_commitsHigh fix density = score penalty
Revertmsg.revert_countAny revert = -15 points
WIPmsg.wip_count, WIP ratioWIP ratio ≥0.3 = -8 points