Commit 5037a31
committed
fix(rules): make TEMP-002's date sort a total comparator
`sort((a, b) => (a.iso < b.iso ? -1 : 1))` returns 1 for EQUAL keys, so
compare(a,b) and compare(b,a) are both 1 — a self-contradictory comparator.
Which of two same-day dates lands at sorted[0] then depends on V8's tie
handling for an invalid comparator, and that date supplies the finding's
excerpt and position. This was the only such comparator left in src/engine;
every other call site already uses a proper three-way or numeric compare.
No golden churn: no corpus fixture has two same-day dates in a document that
reaches this branch, which is why the latent non-determinism never surfaced.
A regression test runs the tied-date fixture 25 times and asserts one distinct
result.
Also corrects a stale count in a comment: the dark-patterns block in
src/engine/rules/index.ts said "— 9" while listing DARK_001..DARK_014. The
README figure was fixed earlier in this campaign; the comment beside the code
was not.1 parent 0482245 commit 5037a31
3 files changed
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
| |||
0 commit comments