Repository navigation
Add read-only remove-debug-statement patches for JS/TS - #110
Conversation
Show a unified diff for standalone console.log, console.debug, console.info, and debugger statements, and let the user download a repo-relative .patch for git apply. Expression and braceless cases stay report-only. Codeflow still never writes source files. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6cb94eb46c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Cached analyses no longer keep source snippets or unified diffs from remove-debug-statement. The sole body of an unbraced for-await stays report-only, and calls through a shadowed or member console do too. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9192b47ac8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Build unified diffs from the original line bytes so git apply matches CRLF, LF, and mixed files. Treat TypeScript namespace, module, and enum bindings named console as shadowing. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5204930934
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A newline before a template, as, or satisfies continues the call, so those sites stay out of the patch. Identifier escapes are decoded before resolving console, and a with body or export-default name that binds console stays report-only. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f48d305ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A trailing comment or a next-line directive is left report-only so a downloaded patch does not delete or retarget it. Sloppy scopes that contain a direct eval, and files that call indirect eval or Function, stay report-only unless strict mode is clear. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54508d985d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A debug line with its own semicolon can still be the only separator between an unterminated expression and a continuation token. Those sites stay report-only unless the preceding code ends in a semicolon or a statement brace. Writes to console, its methods, global hosts, and aliases make every console call in the file report-only. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b9ea6b040
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Treat any destructure, alias, or host access that can capture console as report-only for the whole file. Build each site diff from one line split, and quote patch paths with git's C escapes so git apply accepts them. Co-authored-by: Braedon Saunders <braedonsaunders@users.noreply.github.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Refs #109
Codeflow stays read-only. This adds the first patch-only refactor suggestion,
remove-debug-statement, for JavaScript and TypeScript. A finding can show the proposed unified diff and download it as a.patch. Nothing in this change writes to the user's files: there is no File System Access write call and no write toggle. The user applies the patch themselves withgit applyfrom the repo root.Appliable
A site is included in the patch only when removing it cannot change program behaviour beyond dropping the debug side effect:
console.log(...),console.debug(...), orconsole.info(...)statement, including a multi-line call, when that statement is the only code on its lines and the callee is the globalconsole.debugger;statement on the same terms.if, loop (includingfor await), or arrow body.Paths in the diff are repo-relative (
a/src/app.js), sogit applyworks from the repo root. Context and deletion lines keep a trailing CR when the source line used CRLF, including files that mix CRLF and LF, so the patch applies to the original bytes. Each statement has its own patch (against the original file). A file patch and one combined patch remove every safe statement in that file or in the whole analysis, with hunk line numbers adjusted together.Report-only
These stay visible with a short reason and are left out of every patch:
return console.log(...), an argument, an assignment, a template substitution, a tagged template on the next line, or a TypeScriptas/satisfiescontinuation).if,else, loop,do,with, or arrow without braces, including the sole unbraced body offor await (...).consolebinding (parameter, import, declaration, catch, class name,export default function/classname, awithbody, or a TypeScriptnamespace,module, orenum, includingconst enumand a qualified name such asFoo.console). Identifier escapes (\uXXXXand\u{...}) are decoded, so\u0063onsoleis that same binding. A malformed identifier escape leaves the file report-only. A member call such aslogger.console.log(...)stays report-only.// @ts-ignore,// eslint-disable-next-line,// prettier-ignore, and any other trailing comment is not deleted. A next-line directive on the immediately previous line (@ts-ignore,@ts-expect-error,eslint-disable-next-line,prettier-ignore,biome-ignore,istanbul ignore next,c8 ignore next, and the same family) stays report-only, because deleting the statement would move it onto the following code. A directive comment on a line the patch would delete stays report-only too. A file-level directive that remains on its own line, such as// @ts-nocheck, does not block a later statement.console.*call in a sloppy scope that contains a directeval(...)call, including(eval)(...)and((eval))(...), because that call can create a function-scopedconsole. Nested functions in that scope stay report-only. The scope can still be patched when strict mode is established: an exact"use strict"prologue, a class body, animportorexportdeclaration, or a.mjs/.mtsfile. Indirect eval ((0, eval),eval?.(),window.eval,eval.call) andnew Function/Function(...)can replace the globalconsole, so the whole file stays report-only.git applysplits the working tree on LF, so those bytes cannot be patched safely.unsupported language).The existing Debug Statements security finding is unchanged: still one issue per file when
console.log/console.debug/console.infoappears more than three times, with the same severity and description. The JSON report adds apatchstring on that finding only when a safe file patch exists. No existing export field is renamed or removed.Recent analyses stored in IndexedDB keep the finding metadata (path, line, status, reason) but not source snippets or unified diffs. Patches are regenerated only while the live analysis still has file source.
Tests
npm test— 250 passed, 0 failed. The cases check that a simple file's patch applies withgit apply, that a CRLF fixture and a mixed CRLF/LF fixture passgit apply --checkand keep their original line endings, that risky files stay report-only (including unbracedfor await, shadowedconsolebindings, escaped identifiers, tagged templates on the next line, a TypeScriptnamespace console, trailing and directive comments, and direct or indirecteval), that cached analyses drop snippets and diffs, and that the existing debug-statement finding and export fields are unchanged.Security tab showing debug-statement diffs and download buttons
Manual test plan
index.html(or the deployed build of this branch) and analyze a local folder that contains a.jsor.tsfile like this:console.*anddebuggerstatements with a red unified-diff preview, and thatif (true) console.log('risky')is marked report-only ("inside a one-line if without braces") with no download button..patch, the file.patch, and "Download all .patch". From the repo root, rungit apply --checkon the combined patch, thengit apply. Confirm only the safe statements are gone and theifline is still there.git apply.severity,title,description,file,path,line, andcode, plus an addedpatchstring. Other findings should not gain apatchfield.To show artifacts inline, enable in settings.