fix(signals): flag the .at(-1)/.at(0) idiom in boundary-test-generation - #6006
Conversation
ARRAY_INDEX_BOUNDS_PATTERN in boundary-test-generation.ts caught bracket-index boundary forms (arr[arr.length - 1], arr[-1]) and .length comparisons but not the modern Array.prototype.at() idiom (arr.at(-1), arr.at(0)) — the standard JS/TS way to express exactly the last-element/off-by-one access this detector exists to flag, so that access silently evaded the boundary-safe test-generation signal (JSONbored#1972). Add a `\.at\(\s*-?\d+\s*\)` alternative. Kept narrow per the module's stated "small and precise, false positives worse than missed positives" design: only a numeric literal argument (optionally negative) matches — a bare identifier like `.at(idx)` carries none of the specific -1/0 boundary signal and would reintroduce false-positive noise. Single-pattern additive change; no other pattern, BOUNDARY_PATTERNS, MAX_TOUCHES, or added-line scanning touched.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6006 +/- ##
=======================================
Coverage 95.15% 95.15%
=======================================
Files 589 589
Lines 46827 46827
Branches 14959 14959
=======================================
Hits 44560 44560
Misses 1511 1511
Partials 756 756
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-15 06:51:25 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 3 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
ARRAY_INDEX_BOUNDS_PATTERNinsrc/signals/boundary-test-generation.ts(the array/index-bounds detector for the #1972 boundary-safe test-generation signal) matched bracket-index forms (arr[arr.length - 1],arr[-1]) and.lengthcomparisons, but not the modernArray.prototype.at()idiom (arr.at(-1),arr.at(0)) — the standard JS/TS way to express exactly the last-element/off-by-one access this detector exists to flag. Verified:ARRAY_INDEX_BOUNDS_PATTERN.test("items.at(-1)")returnedfalse, so that access silently evaded the signal.Fix
Add a
\.at\(\s*-?\d+\s*\)alternative. Kept narrow per the module's own design principle ("deliberately SMALL and PRECISE — false positives are worse than a narrow true-positive set", #1972): only a numeric literal argument (optionally negative) matches. A bare identifier like.at(idx)carries none of the specific-1/0boundary signal and matching it would reintroduce false-positive noise. Single additive regex alternative — no other pattern,BOUNDARY_PATTERNS,MAX_TOUCHES, or added-line-only scanning touched.Tests
Extends
test/unit/boundary-test-generation.test.ts:array_index_boundsnow fires foritems.at(-1),items.at(0),rows.at(-2); a negative test confirms.at(idx)(non-literal) does not trigger. All existing bracket-index /.lengthtests pass unmodified. 100% line coverage on the touched module locally.Closes #5843