Repository navigation
Make the runtime boundary check count indirect Deno access - #15218
Merged
Merged
Conversation
The ratchet's \bDeno\. pattern misses Deno?.x, globalThis["Deno"] and a bare globalThis.Deno. PR 09's plan used (globalThis as any)["Deno"]?.errors in a unit test only to keep the tests count flat, and review caught it; a mechanical count closes that route for every later PR instead of relying on review. Measured on main: src +1 (colors.ts) and resources +2 (two generated editor bundles); no optional-chaining or bracket hit outside the exclusions.
The planned bracket alternative matched any `["Deno"]`, so an array element (`const names = ["Deno"]`) or another object's property (`obj["Deno"]`) would have raised a count with no Deno dependency added. The regex now requires a globalThis receiver (plain, optional `?.[`, or cast `(globalThis as any)`), and the negative test covers both cases. Checked with a scratch script: the positive fixture's counts are unchanged, the negatives count nothing, and the measured baseline impact on main is unaffected (no bracket hits before either).
Four spellings stay uncounted: a cast of more than one word, destructuring from globalThis, an alias of the bare namespace, and self./window. receivers. None appears in a counted scope on main. Counting an alias would mean counting a bare `Deno`, which also appears in prose comments the tool counts, and a deliberate dodge always finds a spelling a regex misses, so review is the check for those. Also records the expected "main is above the baseline" notice the PR check prints because it counts the base tree with the new regex.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Follow-up to #15153. The runtime boundary check counts
Denoaccess with the regex\bDeno\., so the same access spelled differently goes uncounted:Deno?.errors,globalThis["Deno"]?.errors, or a bareglobalThis.Denoassigned to a local binding.A unit test drafted for the upcoming
src/deno_ral/filesystem layer read(globalThis as any)["Deno"]?.errorsonly so that thetestscount stayed flat. Review caught it; the check could not.Plan: 02d-ratchet-counts-indirect-deno.md
Fix
The counting regex now also matches three spellings, keyed like direct access so that the
kRalDenoReplacementserrors (aDeno.*API thatsrc/deno_ralalready replaces) apply to them too:Deno?.errorskeys aserrors,Deno?.errors?.NotFoundaserrors.NotFound.globalThis, with any quote,globalThis?.[, or a cast receiver such as(globalThis as any). Requiring theglobalThisreceiver keeps["Deno"]in an array or on another object uncounted.globalThis.Denonot followed by an access.globalThis.Deno.cwd()was already counted and still counts once.typeof Deno, a"Deno"string,DenoKvandmyDeno.xstay uncounted. Two unit tests pin the counted and the uncounted spellings.Left uncounted on purpose: destructuring (
const { Deno: d } = globalThis), an alias (const d = Deno), a cast of more than one word ((globalThis as Record<string, unknown>)["Deno"]), andself.Deno. None appears in a counted scope today.Counting an alias means counting a bare
Deno, which also appears in the prose comments the check counts, and a deliberate workaround always finds a spelling a regex misses. The plans' review checklist covers these instead.Baseline
The stricter count finds three existing lines, each assigning
globalThis.Denoto a local binding, so the baseline rises with--accept-increase:src991 → 992:src/core/lib/external/colors.ts:28resources10 → 12: the generatedsrc/resources/editor/tools/vs-code.mjs:25954andsrc/resources/editor/tools/yaml/web-worker.js:25968The PR check counts the base branch with this PR's regex, so it reports two
main is above tools/runtime-boundary-baseline.json ... not caused by this PRnotices forsrcandresources. They are expected for this PR only: the baseline change here covers both, and the check exits 0 (replayed locally with--againstthe base commit).Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.