Skip to content

fix: remove non-hex hexspeak patterns that can never match a SHA#849

Open
kitsuyui wants to merge 2 commits into
mainfrom
fix/audit-hexspeak-dead-patterns-001
Open

fix: remove non-hex hexspeak patterns that can never match a SHA#849
kitsuyui wants to merge 2 commits into
mainfrom
fix/audit-hexspeak-dead-patterns-001

Conversation

@kitsuyui

Copy link
Copy Markdown
Owner

SHA commit hashes consist only of [0-9a-f]. The hexspeak patterns
defecated (contains t), 0ffice (contains i), and badcable
(contains l) include non-hex characters and can never match any commit
SHA. They are dead patterns with two consequences:

  1. commit_hits_hexspeak advertises 8 patterns but only 5 can ever fire.
  2. expectedCommitHitsHexspeak sums the probability of all 8 patterns,
    inflating the expected-occurrence estimate and causing
    maxExpectedOccurrences to over-suppress valid hexspeak matches
    (f00d, feed, cafe, c0ffee, deadbeef) in smaller repositories.

Changes

  • src/rules.ts: Remove defecated, 0ffice, badcable from the
    hexspeak regex. Also drop the now-unnecessary i flag since the
    remaining 5 patterns consist solely of hex characters.
  • src/rarity.ts: Remove the same 3 patterns from the
    expectedCommitHitsHexspeak probability array.
  • src/rules.spec.ts: Add a regression test asserting the hexspeak
    rule does not match patterns with non-hex characters.

Verification

bun test src/rules.spec.ts src/rarity.spec.ts — 13 pass, 0 fail.
bun run lint — clean.

SHA hashes consist only of [0-9a-f]. The patterns 'defecated' (contains
't'), '0ffice' (contains 'i'), and 'badcable' (contains 'l') include
non-hex characters and can never match any commit SHA, making them dead
patterns that also inflate the expectedCommitHitsHexspeak probability.

Remove the three dead patterns from the regex and the probability
calculation. Add a regression test to document the hex-only constraint.
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

gh-counter

PR gate

Removed Added +/-
TODO/FIXME 0 0 0

Repo dashboard

main (8bad195) #849 (4490e1a) +/-
TODO/FIXME 0 0 0

Reported by gh-counter

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

🎉 Happy commit!

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Code Metrics Report

main (8bad195) #849 (4490e1a) +/-
Coverage 99.2% 99.2% 0.0%
Code to Test Ratio 1:1.3 1:1.3 +0.0
Test Execution Time 2s 1s -1s
Details
  |                     | main (8bad195) | #849 (4490e1a) | +/-  |
  |---------------------|----------------|----------------|------|
  | Coverage            |          99.2% |          99.2% | 0.0% |
  |   Files             |              5 |              5 |    0 |
  |   Lines             |            134 |            134 |    0 |
  |   Covered           |            133 |            133 |    0 |
+ | Code to Test Ratio  |          1:1.3 |          1:1.3 | +0.0 |
  |   Code              |            723 |            714 |   -9 |
+ |   Test              |            955 |            966 |  +11 |
+ | Test Execution Time |             2s |             1s |  -1s |

Code coverage of files in pull request scope (100.0% → 100.0%)

Files Coverage +/- Status
src/rarity.ts 100.0% 0.0% modified
src/rules.ts 100.0% 0.0% modified

Reported by octocov

The committed dist artifacts were out of sync with src/rules.ts; the
`git diff --exit-code -- dist` step in CI failed. Rebuild with tsdown.
@github-actions

Copy link
Copy Markdown

gh-build-size

Target main #849 +/-
Total action artifacts 23,300,810 B 23,300,626 B -184 B
Runtime bundle 1,153,725 B 1,153,666 B -59 B
Source maps 17,131,060 B 17,130,935 B -125 B

Reported by gh-build-size

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant