fix: remove non-hex hexspeak patterns that can never match a SHA#849
Open
kitsuyui wants to merge 2 commits into
Open
fix: remove non-hex hexspeak patterns that can never match a SHA#849kitsuyui wants to merge 2 commits into
kitsuyui wants to merge 2 commits into
Conversation
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.
gh-counterPR gate
Repo dashboard
Reported by gh-counter |
🎉 Happy commit!
|
Code Metrics Report
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%)
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.
gh-build-size
Reported by gh-build-size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SHA commit hashes consist only of
[0-9a-f]. The hexspeak patternsdefecated(containst),0ffice(containsi), andbadcable(contains
l) include non-hex characters and can never match any commitSHA. They are dead patterns with two consequences:
commit_hits_hexspeakadvertises 8 patterns but only 5 can ever fire.expectedCommitHitsHexspeaksums the probability of all 8 patterns,inflating the expected-occurrence estimate and causing
maxExpectedOccurrencesto over-suppress valid hexspeak matches(
f00d,feed,cafe,c0ffee,deadbeef) in smaller repositories.Changes
src/rules.ts: Removedefecated,0ffice,badcablefrom thehexspeak regex. Also drop the now-unnecessary
iflag since theremaining 5 patterns consist solely of hex characters.
src/rarity.ts: Remove the same 3 patterns from theexpectedCommitHitsHexspeakprobability array.src/rules.spec.ts: Add a regression test asserting the hexspeakrule 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.