Analysis

Static analysis reads the code without running it, which is exactly what a merge gate needs.

Generated code usually looks tidy, so the defects worth catching are structural: a credential in source, an unescaped string, a swallowed error. All of those are visible in the text, before anything executes.

Why a linter does not cover this

Linters enforce style and a narrow set of correctness rules. They are excellent at what they do and largely indifferent to whether a key is committed, an interpolation is escaped or a catch block is empty.

Security scanners cover some of that, but they assume a repository, a build and a pipeline. The moment where generated code is most dangerous is earlier: the snippet in an editor, the file pasted from a chat window.

Static analysis of the kind that helps here is a rule set applied to text, cheap enough to run at every point where code is copied.

What the analysis can see

Anything visible in the source is in scope, and that is a longer list than people expect.

  • Credentials: provider-shaped strings, private key blocks, connection strings, named assignments.
  • Dangerous constructs: eval, the Function constructor, document.write, innerHTML, shell execution, SQL concatenation.
  • Error handling: empty catch blocks and bare handlers that convert failure into a default.
  • Structure: unbalanced brackets, source that does not parse, duplicated line blocks, very long lines.
  • Hygiene: debug statements, TODO markers, plain-HTTP resources, loose equality.
  • Markup: images without alt text, missing lang, no viewport, links pointing at a bare hash.

What it cannot see, stated without hedging

No text-level analysis knows whether a method exists on your installed version, whether two modules are compatible, or whether an endpoint is idempotent.

It cannot tell you a null is possible, that a promise rejects, or that the authorisation check on the route above yours is missing. Those need types, tests and a reader who knows the system.

It also cannot tell you whether the design is right. A function can be free of every finding and still be the wrong abstraction.

What to block on, and what to warn about

Block on the categories where shipping is inexcusable: credentials, unsafe rendering of untrusted input, shell and SQL concatenation, source that does not parse.

Warn on residue, long lines, loose equality and missing alt text. Those are real and rarely urgent, and treating them as blockers trains people to override the gate.

Review the block list quarterly. A rule that fires on legitimate code is worse than a missing rule, because it undermines the ones that matter.

Where it sits in a pipeline

Three placements cover the lifecycle. At authoring, when a snippet is pasted, where the fix is free. At review, when the report attaches to the pull request. In CI, where repository-wide and historical scanning belongs.

Each placement needs a different tool. The first has to be instant and require no setup; the third has to see the whole repository and its history.

The mistake is assuming one placement covers the others. A pipeline scan does not stop the key from being typed; a paste-time check does not find what was committed last year.

Handling the results like an engineer

Triage by category, not by count. Four critical findings matter more than forty low ones, which is why severity weighting exists.

Disagree with a rule in writing. A pattern that fires on a test fixture is an exemption to record, and a pattern that fires on legitimate framework code is a rule to fix upstream.

For production-bound changes with real risk, hand the report to a named reviewer who reads for design and integration. The analysis removes the mechanical work from their hour, which is the most useful thing it can do.

What this covers

  • Secrets in text

    Provider formats, key blocks and named assignments, checked before commit.

  • Unsafe constructs

    eval, Function, innerHTML, document.write, shell and SQL concatenation.

  • Failure paths

    Empty catches and defaults that hide errors.

  • Parse and structure

    Unbalanced brackets, syntax errors, duplication, long lines.

  • Block list discipline

    Critical classes block; hygiene warnings never do.

Questions this page usually raises

Is this the same as a SAST tool?
It overlaps on unsafe constructs but differs in placement and scope. SAST assumes a repository and a build; this analysis runs on a pasted file, before the code exists anywhere.
Can static analysis find every bug?
No. It finds patterns, which is a different claim. Logic errors, integration mistakes and design problems need tests, types and human judgement.
Does it need to compile the code?
Ours does not. It parses JavaScript to catch syntax errors and applies pattern rules to any text, so partial files and other languages still produce useful findings.
How do false positives get handled?
Record exemptions with a reason and a reviewer. A rule that keeps firing on fixtures should be narrowed rather than ignored.
Does analysis of this kind upload my code?
Not in this console. The rules execute in your browser against the pasted source, which matters for proprietary code and pre-release work.

Static analysis for AI code

Run the checks, then decide who has to sign it.

The automated pass is free, needs no account and uploads nothing. Escalate to a named reviewer only where being wrong is expensive.