loadwise 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +543 -628
  2. package/bin/loadwise.js +5 -1
  3. package/lib/accessibility/frontend-detect.js +2 -1
  4. package/lib/accessibility/rule-ids.js +12 -9
  5. package/lib/accessibility/template-attributes.js +4 -2
  6. package/{editor/accessibility-examples.cjs → lib/editor/accessibility-examples.js} +20 -21
  7. package/lib/editor/actions.js +117 -0
  8. package/{editor/apply-fix.cjs → lib/editor/apply-fix.js} +1 -6
  9. package/{editor/control-flow-comparison.cjs → lib/editor/control-flow-comparison.js} +1 -3
  10. package/lib/editor/diagnostics.js +365 -0
  11. package/lib/editor/dismissals.js +111 -0
  12. package/lib/editor/editor-document.js +99 -0
  13. package/{editor/finding-comparison.cjs → lib/editor/finding-comparison.js} +4 -7
  14. package/lib/editor/fix-edits.js +200 -0
  15. package/lib/editor/language-server.js +437 -0
  16. package/{editor/maintainability-examples.cjs → lib/editor/maintainability-examples.js} +1 -3
  17. package/{editor/perf-site-comparison.cjs → lib/editor/perf-site-comparison.js} +1 -3
  18. package/lib/editor/perf-watch.js +78 -0
  19. package/{editor/performance-examples.cjs → lib/editor/performance-examples.js} +129 -128
  20. package/{editor/reliability-examples.cjs → lib/editor/reliability-examples.js} +100 -41
  21. package/lib/editor/scan-session.js +334 -0
  22. package/{editor/security-examples.cjs → lib/editor/security-examples.js} +28 -32
  23. package/lib/editor/server-commands.js +232 -0
  24. package/{editor/source-example.cjs → lib/editor/source-example.js} +3 -5
  25. package/{editor/standalone-performance-examples.cjs → lib/editor/standalone-performance-examples.js} +349 -333
  26. package/lib/editor/types/dismissal.js +1 -0
  27. package/lib/editor/types/fix-example.js +1 -0
  28. package/lib/editor/types/source-document.js +1 -0
  29. package/lib/editor/workspace-files.js +78 -0
  30. package/lib/editor/workspace-paths.js +22 -0
  31. package/lib/maintainability/analyze-source.js +2 -0
  32. package/lib/maintainability/apply-fix.js +1 -1
  33. package/lib/maintainability/cli.js +1 -1
  34. package/lib/maintainability/examples.js +58 -41
  35. package/lib/maintainability/rule-ids.js +29 -14
  36. package/lib/maintainability/scan-changed.js +3 -0
  37. package/lib/maintainability/scan.js +13 -9
  38. package/lib/maintainability/tsconfig-strict.js +69 -0
  39. package/lib/maintainability/type-safety-hygiene.js +204 -0
  40. package/lib/performance/analyze.js +2 -0
  41. package/lib/performance/cli-arguments.js +0 -2
  42. package/lib/performance/cli-policy.js +17 -9
  43. package/lib/performance/cli-scan.js +10 -8
  44. package/lib/performance/cli.js +4 -23
  45. package/lib/performance/editor-signal.js +1 -1
  46. package/lib/performance/finding-text.js +3 -3
  47. package/lib/performance/fix-cli.js +1 -1
  48. package/lib/performance/frontend-perf.js +7 -0
  49. package/lib/performance/frontend-render-perf.js +200 -0
  50. package/lib/performance/llm-max-tokens.js +56 -0
  51. package/lib/performance/native.js +46 -26
  52. package/lib/performance/polyglot.js +22 -1
  53. package/lib/performance/pooling.js +38 -23
  54. package/lib/performance/projects.js +42 -21
  55. package/lib/performance/rule-ids.js +236 -222
  56. package/lib/performance/site-fixes/database.js +3 -1
  57. package/lib/performance/site-fixes/integrity.js +15 -1
  58. package/lib/performance/source-inputs.js +18 -6
  59. package/lib/performance/unscanned-javascript.js +66 -19
  60. package/lib/reliability/analyze.js +12 -0
  61. package/lib/reliability/child-process.js +106 -0
  62. package/lib/reliability/error-values.js +177 -0
  63. package/lib/reliability/pool-timeout.js +79 -0
  64. package/lib/reliability/react-bugs.js +602 -0
  65. package/lib/reliability/resource-leaks.js +3 -6
  66. package/lib/reliability/rule-ids.js +169 -127
  67. package/lib/reliability/switch-exhaustive.js +284 -0
  68. package/lib/reliability/uncaught-exception.js +223 -0
  69. package/lib/security/auth-crypto/rule-ids.js +3 -2
  70. package/lib/security/cli.js +6 -5
  71. package/lib/security/deps/rule-ids.js +1 -0
  72. package/lib/security/examples/auth-crypto.cjs +5 -4
  73. package/lib/security/examples/deps.cjs +1 -0
  74. package/lib/security/examples/exposure.cjs +55 -42
  75. package/lib/security/examples/files.cjs +1 -0
  76. package/lib/security/examples/injection.cjs +1 -0
  77. package/lib/security/examples/moved.cjs +5 -4
  78. package/lib/security/examples/request-forgery.cjs +1 -0
  79. package/lib/security/exposure/client-env.js +113 -0
  80. package/lib/security/exposure/frontend-security.js +12 -10
  81. package/lib/security/exposure/index.js +14 -3
  82. package/lib/security/exposure/jsx-url.js +267 -0
  83. package/lib/security/exposure/next-image-config.js +34 -0
  84. package/lib/security/exposure/package-manifest.js +45 -0
  85. package/lib/security/exposure/react-version.js +45 -0
  86. package/lib/security/exposure/rule-ids.js +16 -12
  87. package/lib/security/files/index.js +1 -1
  88. package/lib/security/files/rule-ids.js +1 -0
  89. package/lib/security/injection/code.js +24 -10
  90. package/lib/security/injection/command.js +81 -28
  91. package/lib/security/injection/nosql.js +109 -22
  92. package/lib/security/injection/redos.js +152 -308
  93. package/lib/security/injection/regex-pattern.js +290 -0
  94. package/lib/security/injection/regex.js +30 -11
  95. package/lib/security/injection/rule-ids.js +2 -1
  96. package/lib/security/injection/shared.js +19 -1
  97. package/lib/security/injection/sql.js +83 -2
  98. package/lib/security/request-forgery/rule-ids.js +1 -0
  99. package/lib/security/rule-descriptions.js +36 -32
  100. package/lib/security/rule-ids.js +74 -67
  101. package/lib/security/taint/filename-guard.js +3 -1
  102. package/lib/security/taint/guards.js +84 -10
  103. package/lib/security/taint/index.js +124 -13
  104. package/lib/security/taint/propagate.js +10 -7
  105. package/lib/security/taint/sanitizers.js +7 -3
  106. package/lib/security/taint/sources.js +6 -3
  107. package/lib/security/taint/summaries.js +13 -1
  108. package/lib/security/taint/url-parts.js +14 -5
  109. package/lib/shared/agent-session.js +2 -2
  110. package/lib/shared/check.js +16 -6
  111. package/lib/shared/explain.js +5 -5
  112. package/lib/shared/fix-convergence.js +1 -1
  113. package/lib/shared/formats/finding-location.js +6 -2
  114. package/lib/shared/formats/sarif.js +3 -3
  115. package/lib/shared/heap-limit.js +20 -3
  116. package/lib/shared/pillars.js +7 -7
  117. package/lib/shared/rule-docs.js +12 -0
  118. package/lib/shared/scan-cache.js +0 -1
  119. package/lib/shared/workspaces.js +31 -9
  120. package/package.json +12 -19
  121. package/plugin/.claude-plugin/plugin.json +1 -1
  122. package/schema/loadwise.config.schema.json +44 -0
  123. package/editor/README.md +0 -47
  124. package/examples/redis-keys.otlp.json +0 -22
  125. package/lib/maintainability/notify-editor.js +0 -1
  126. package/lib/performance/editor-report.js +0 -191
  127. package/lib/performance/editor-setup.js +0 -189
  128. package/lib/performance/editor-watch-supervisor.js +0 -104
  129. package/lib/performance/editor-watch.js +0 -193
  130. package/lib/performance/notify-editor.js +0 -1
  131. package/lib/performance/recursive-watch.js +0 -181
  132. /package/lib/{performance/types/editor-report.js → editor/types/comparison.js} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Loadwise
2
2
 
3
- [![npm](https://img.shields.io/npm/v/loadwise)](https://www.npmjs.com/package/loadwise) [![check](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml/badge.svg)](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml) [![license](https://img.shields.io/npm/l/loadwise)](LICENSE)
3
+ [![npm](https://img.shields.io/npm/v/loadwise)](https://www.npmjs.com/package/loadwise) [![check](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml/badge.svg)](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/IbrahimHafez1/loadwise/badge)](https://scorecard.dev/viewer/?uri=github.com/IbrahimHafez1/loadwise) [![license](https://img.shields.io/npm/l/loadwise?cacheSeconds=3600)](LICENSE)
4
4
 
5
5
  Loadwise checks a backend project before it ships. One CLI runs five checkers:
6
6
 
@@ -38,7 +38,7 @@ By default `loadwise check` reports actionable findings across Performance, Reli
38
38
 
39
39
  **With an AI coding agent**, say **“Run Loadwise”** in your project chat. The agent can run the installed CLI directly. It should check the findings against the code, explain what it would fix or leave alone and why, and let you choose before making edits. [Active-agent workflow and optional MCP setup](#using-loadwise-with-an-active-coding-agent)
40
40
 
41
- **Working manually**, run `npx loadwise check` to see recommendations or `npx loadwise fix --yes` to apply eligible fixes. In VS Code or Cursor, editor diagnostics show findings on hover. [Editor setup](#editor)
41
+ **Working manually**, run `npx loadwise check` to see recommendations or `npx loadwise fix --yes` to apply eligible fixes. In any editor with a language server client, `loadwise lsp` shows findings as diagnostics with hovers and fixes. [Editor setup](#editor-language-server)
42
42
 
43
43
  ### Try a finding and a fix
44
44
 
@@ -142,7 +142,7 @@ To apply automatic fixes across your project, run `npx loadwise fix --yes` from
142
142
  - `--fail-on contract|all` sets the exit threshold. By default, performance, reliability, security and accessibility fail on displayed findings, and a full maintainability scan fails on contract violations. Changed-line maintainability scans fail on any displayed finding. Configured rule levels can change these defaults.
143
143
  - `--write-baseline [file]` records the current findings and `--baseline [file]` reports only findings not recorded. The default file is `loadwise-baseline.json` in the checked directory, with one section per checker; `loadwise perf`, `loadwise rel`, `loadwise maint`, `loadwise sec` and `loadwise a11y` take the same flags and read or write only their own section. Entries match on rule, file and flagged code (the finding id), never the line number, with a count per entry so N recorded copies allow N findings. Text output ends with `N baseline findings hidden.` and `--json` adds `baselineHidden`. A full comparison reports the number of unmatched entries in `baselineStale`. A partial comparison, such as a changed-line or single-file scan, reports `null` because unscanned findings may still exist. Refresh the baseline using its original scope and settings. Not combinable with `--fix`, and `--write-baseline` not with `--staged` or `--changed-since`. `loadwise rel migrations` keeps its own per-file baseline.
144
144
 
145
- The performance, reliability, security and accessibility checkers use the directory's `tsconfig.json` or `jsconfig.json`; without one, `check` looks for workspace packages (`package.json` `workspaces`, `pnpm-workspace.yaml` or `lerna.json`) and checks each one's config in one report, grouped per package; `--workspace <name|path>` (repeatable) limits every checker to some packages. For a standalone package with a `package.json` and JavaScript sources only, `check` and `fix` infer source files using the project inventory without writing a config. A mixed JavaScript/TypeScript project still needs a source config. For a JavaScript file without a project config, use `npx loadwise perf path/to/file.js` and `npx loadwise sec path/to/file.js`. For Python, Go, Java, C# or Rust performance checks, run `npx loadwise perf polyglot src` explicitly, and `npx loadwise rel polyglot src` for the reliability patterns. The security checker can still scan Dockerfiles, Compose files and tracked environment files. When performance and reliability are selected together, they share a type-check unless a baseline is being written. Source scans are read-only. When fixes are available, text reports include a `Fix all:` command, such as `npx loadwise perf -p tsconfig.json --fix --only <ids>`, that applies its fixes.
145
+ The performance, reliability, security and accessibility checkers use the directory's `tsconfig.json` or `jsconfig.json`; without one, `check` looks for workspace packages (`package.json` `workspaces`, `pnpm-workspace.yaml` or `lerna.json`) and checks each one's config in one report, grouped per package (a package without a config is checked with the standalone defaults below); `--workspace <name|path>` (repeatable) limits every checker to some packages. For a package with a `package.json` and no config, `check` and `fix` infer its JavaScript and TypeScript source files from the project inventory without writing a config, and check them with ES2022 and NodeNext defaults. A package whose TypeScript sits under a sub-folder's own `tsconfig.json` still needs a config at its root, since those defaults would miss that config's settings. For a JavaScript file without a project config, use `npx loadwise perf path/to/file.js` and `npx loadwise sec path/to/file.js`. For Python, Go, Java, C# or Rust performance checks, run `npx loadwise perf polyglot src` explicitly, and `npx loadwise rel polyglot src` for the reliability patterns. The security checker can still scan Dockerfiles, Compose files and tracked environment files. When performance and reliability are selected together, they share a type-check unless a baseline is being written. Source scans are read-only. When fixes are available, text reports include a `Fix all:` command, such as `npx loadwise perf -p tsconfig.json --fix --only <ids>`, that applies its fixes.
146
146
 
147
147
  Exit codes: **0** passed, **1** a checker met its exit threshold, **2** invalid input or configuration in any checker, or a scan that skipped a file (see below).
148
148
 
@@ -265,7 +265,7 @@ If you ran a terminal command yourself and want to share it later, use `npx load
265
265
 
266
266
  ### Using Loadwise without AI
267
267
 
268
- Run `npx loadwise check` to see findings or `npx loadwise fix --yes` to scan and apply automatic fixes. With editor diagnostics enabled, hover over a finding to see its recommendation. Findings that require judgment remain available for manual review. [Editor setup](#editor)
268
+ Run `npx loadwise check` to see findings or `npx loadwise fix --yes` to scan and apply automatic fixes. With the language server running in your editor, hover over a finding to see its recommendation. Findings that require judgment remain available for manual review. [Editor setup](#editor-language-server)
269
269
 
270
270
  ### Claude Code plugin
271
271
 
@@ -290,26 +290,132 @@ npx loadwise agent init --hook off # removes only this block
290
290
 
291
291
  The hook runs `loadwise check --staged` from the project folder, so every tool that commits through git sees findings from the selected checkers on the staged lines. It writes a marked block into the hooks folder (honouring `core.hooksPath`) or into `.husky/pre-commit` when `.husky/` exists, appends to a hook you already have, and rerunning it replaces only its own block, including blocks written by earlier releases. With lefthook it edits nothing and prints the command to add. `git commit --no-verify` skips the hook.
292
292
 
293
- ## Editor
293
+ ## Editor (language server)
294
294
 
295
- Set up the editor task once from the project root.
295
+ `loadwise lsp` is a language server for any editor with a Language Server Protocol client. It shows findings from all five checkers (performance, reliability, maintainability, security and accessibility) as diagnostics, with hovers, fixes, dismissals and code lenses. It needs Node.js 22+ and this package in the project (`npm install --save-dev loadwise`) or on the PATH. Every editor starts it the same way:
296
296
 
297
297
  ```sh
298
- npx loadwise perf editor init
298
+ npx loadwise lsp --stdio
299
299
  ```
300
300
 
301
- Commit the generated `.vscode/tasks.json`. Open the trusted folder in VS Code or Cursor and allow automatic tasks once; the watcher then starts on every folder open (reopen the folder if it was already open during setup). **Tasks: Manage Automatic Tasks** controls the workspace's choice. Findings from the performance, reliability, maintainability and accessibility checkers appear in **View > Problems**. This works across supported source languages, including mixed-language projects, and needs Node.js 22+ on PATH and this package under `node_modules`.
301
+ On Windows, use `npx.cmd` where the editor does not resolve `npx` itself. Choose the file types each editor attaches it to; the snippets below cover JavaScript, TypeScript and Python, and the checkers also read Go, Java, C#, Rust, HTML, Vue and Svelte.
302
302
 
303
- Saving a file or completing a source scan from the project terminal refreshes the running watcher. The editor uses its configured project and rules even when the terminal command uses different flags, and a running watcher picks up package reinstalls. The default scan uses a root `tsconfig.json` or `jsconfig.json`, or explicit JS/TS files discovered by the watcher; append `-p` and a relative path to the task's arguments (it runs `perf editor watch [-p tsconfig.json]`) to use another config.
303
+ **Neovim 0.11+** (`init.lua`):
304
304
 
305
- Hover over an underline to read the finding. The first line shows a source-based rewrite, an illustrative example or a review action. The hover retains the original finding and, where applicable, the code comparison.
305
+ ```lua
306
+ vim.lsp.config('loadwise', {
307
+ cmd = { 'npx', 'loadwise', 'lsp', '--stdio' },
308
+ filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'python' },
309
+ root_markers = { 'loadwise.config.json', 'tsconfig.json', 'jsconfig.json', 'package.json', '.git' },
310
+ init_options = { loadwise = { severity = 'default' } },
311
+ })
312
+ vim.lsp.enable('loadwise')
313
+ ```
314
+
315
+ With an older Neovim and nvim-lspconfig, register the same settings as a custom server:
316
+
317
+ ```lua
318
+ require('lspconfig.configs').loadwise = {
319
+ default_config = {
320
+ cmd = { 'npx', 'loadwise', 'lsp', '--stdio' },
321
+ filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'python' },
322
+ root_dir = require('lspconfig.util').root_pattern('loadwise.config.json', 'tsconfig.json', 'package.json', '.git'),
323
+ },
324
+ }
325
+ require('lspconfig').loadwise.setup({})
326
+ ```
327
+
328
+ **Helix** (`languages.toml`), added beside each language's own server:
329
+
330
+ ```toml
331
+ [language-server.loadwise]
332
+ command = "npx"
333
+ args = ["loadwise", "lsp", "--stdio"]
334
+
335
+ [[language]]
336
+ name = "typescript"
337
+ language-servers = ["typescript-language-server", "loadwise"]
338
+
339
+ [[language]]
340
+ name = "python"
341
+ language-servers = ["pylsp", "loadwise"]
342
+ ```
343
+
344
+ **Zed** (`settings.json`). Zed starts only language servers that an extension registers; with one that registers `loadwise`, these settings choose the command and the languages it runs for:
345
+
346
+ ```json
347
+ {
348
+ "lsp": {
349
+ "loadwise": {
350
+ "binary": { "path": "npx", "arguments": ["loadwise", "lsp", "--stdio"] },
351
+ "initialization_options": { "loadwise": { "severity": "default" } }
352
+ }
353
+ },
354
+ "languages": {
355
+ "TypeScript": { "language_servers": ["...", "loadwise"] },
356
+ "Python": { "language_servers": ["...", "loadwise"] }
357
+ }
358
+ }
359
+ ```
360
+
361
+ **Sublime Text** with the LSP package (**Preferences > Package Settings > LSP > Settings**):
362
+
363
+ ```json
364
+ {
365
+ "clients": {
366
+ "loadwise": {
367
+ "enabled": true,
368
+ "command": ["npx", "loadwise", "lsp", "--stdio"],
369
+ "selector": "source.js | source.jsx | source.ts | source.tsx | source.python",
370
+ "initializationOptions": { "loadwise": { "severity": "default" } }
371
+ }
372
+ }
373
+ }
374
+ ```
375
+
376
+ **Emacs** with eglot. Eglot runs one server per buffer, so for these modes Loadwise takes the place of another server:
377
+
378
+ ```elisp
379
+ (with-eval-after-load 'eglot
380
+ (add-to-list 'eglot-server-programs
381
+ '((js-mode js-ts-mode typescript-ts-mode tsx-ts-mode python-mode python-ts-mode)
382
+ . ("npx" "loadwise" "lsp" "--stdio"))))
383
+ ```
384
+
385
+ **VS Code and VSCodium**: install a generic Language Server Protocol client extension from Open VSX and set its server command to `npx loadwise lsp --stdio`. To apply eligible fixes on save, add `"editor.codeActionsOnSave": { "source.fixAll.loadwise": "explicit" }` to your settings.
306
386
 
307
- The [editor extension](editor/README.md) is not published yet; a language server for every editor is planned. Built from source (`python editor/package-vsix.py`), it adds syntax-highlighted hover examples, related-location links and fix actions in VS Code or Cursor:
387
+ ### What you see
308
388
 
309
- - Each fixable line shows **Apply fix** and **Dismiss** CodeLens buttons, the hover has the same two links, and the Quick Fix menu offers the same actions.
310
- - The shortcuts are the same on every OS: **Ctrl+Alt+.** applies the fix on the cursor line, **Ctrl+Alt+Shift+.** applies all fixes in the file, and **Ctrl+Alt+,** dismisses the finding on the cursor line.
311
- - **Loadwise: Apply all fixes in this file** (also on save as `source.fixAll.loadwise`) applies every fix in one undoable edit.
312
- - A finding, or a rule in one file, can be dismissed and restored with **Show dismissed findings**. `loadwise.severity` shows all findings at one level.
389
+ - Each finding is a diagnostic with its checker as the source (`loadwise perf`, `loadwise maint`, `loadwise sec`) and its rule as the code, linked to the rule's documentation. Related locations, such as the other imports of a dependency cycle, are listed with it. Rule levels from `loadwise.config.json` decide the severity: by default declared contract violations are errors and other findings warnings. Live-database findings, which name a table rather than a file, appear on the first line of `package.json`.
390
+ - Hover over a finding to read the recommendation on the first line (a source-based rewrite, an illustrative example or a review action), then the original finding and the before and after code, highlighted for the file's language.
391
+ - The code actions on a flagged line are **Apply fix: <rule>** when the checker has a rewrite, **Dismiss this finding** and **Dismiss <rule> in this file**, and **Apply all Loadwise fixes in this file** when there are several. Fixes that span several files, or create a migration file, apply all-or-nothing. A fix never overwrites an existing file, and it refuses code that changed since the scan, comparing against the editor's unsaved text. The `source.fixAll.loadwise` action applies every eligible fix in the file as one undoable edit and leaves fixes that need individual review for **Apply fix**.
392
+ - Code lenses put **Apply fix** and **Dismiss** above each fixable line, and **Apply all** on the first line of a file with several fixes.
393
+ - A dismissed finding stays hidden until its flagged line changes; a rule dismissed for a file stays hidden in that file. Dismissals are saved in `.loadwise/dismissed.json` at the workspace folder root, never in your code, and you can commit the file to share them.
394
+
395
+ ### What gets scanned
396
+
397
+ Each workspace folder is scanned when the server starts and again after every change: a save in the editor, or a change by git, another editor or a code generator to a source file, `schema.prisma`, a SQL migration, `package.json`, `tsconfig*.json`, `jsconfig*.json`, `loadwise.config.json` or `.loadwise/dismissed.json`. Rapid changes are grouped, and a completed source scan in the project terminal refreshes the editor too. Performance, reliability and accessibility come from the incremental `loadwise perf --watch` process, which re-analyzes only changed files, restarts when a config file or package changes, and falls back to full rescans if it stops. Maintainability and security rerun on each change, and the polyglot rules run when the folder has Python, Go, Java, C# or Rust files. The default project is a root `tsconfig.json` or `jsconfig.json`; in a monorepo, open individual packages as workspace folders or set `project`. Progress appears while a scan runs, and scan counts and errors go to the editor's language server log.
398
+
399
+ ### Commands and settings
400
+
401
+ | Command | Action |
402
+ | --------------------------- | ---------------------------------------------------------- |
403
+ | `loadwise.scan` | Rescan every workspace folder now |
404
+ | `loadwise.applyFix` | Apply one fix (from a code action or code lens) |
405
+ | `loadwise.applyAllFixes` | Apply every eligible fix in a file (its URI as argument) |
406
+ | `loadwise.dismiss` | Dismiss a finding or a rule in a file |
407
+ | `loadwise.showDismissed` | List dismissed findings, with Restore and Restore all |
408
+ | `loadwise.restoreDismissed` | Restore the given dismissal, or every one without argument |
409
+
410
+ Settings go in the client's `initializationOptions` or its `loadwise` configuration section (per workspace folder when the editor supports it):
411
+
412
+ | Setting | Default | Effect |
413
+ | ---------- | ----------- | ----------------------------------------------------------------------------- |
414
+ | `enabled` | `true` | Show diagnostics for the folder |
415
+ | `project` | `""` | TypeScript or JavaScript project config, relative to the folder |
416
+ | `cli` | `""` | Absolute path to another `bin/loadwise.js`, such as a development build |
417
+ | `severity` | `"default"` | `error`, `warning`, `information` or `hint` shows every finding at that level |
418
+ | `codeLens` | `true` | Show the Apply fix and Dismiss code lenses |
313
419
 
314
420
  # Performance checker
315
421
 
@@ -367,59 +473,79 @@ The default `--fail-on all` applies to the displayed findings. For a complete ad
367
473
 
368
474
  ## Source checks
369
475
 
370
- Run in the directory containing `tsconfig.json` or `jsconfig.json`, pass `-p path/to/config.json`, or give explicit JS/TS files. A project check scans the config's input files and follows project references. Declaration files supply types. A standalone file check uses ES2022 and NodeNext compiler defaults. Use a project config for aliases, custom libraries and JS projects with `allowJs`. When a config leaves JavaScript files in its folder out because `allowJs` is off, a note names them.
371
-
372
- | JS/TS rule | Trigger and review |
373
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
374
- | <a id="pg-query-in-loop"></a><a id="prisma-query-in-loop"></a>`pg-query-in-loop`, `prisma-query-in-loop` | Per-item queries. Consider a parameterized set query, relation load or bulk write if ordering and transaction behavior permit it. Prisma can already batch compatible `findUnique` calls. |
375
- | <a id="pg-count-materialization"></a><a id="prisma-count-materialization"></a>`pg-count-materialization`, `prisma-count-materialization` | Counting an immediately loaded result. Use a database count with equivalent predicates and handle its return type. |
376
- | <a id="pg-first-materialization"></a><a id="prisma-first-materialization"></a>`pg-first-materialization`, `prisma-first-materialization` | Reading only index zero from an unbounded result. Preserve ordering and empty-result behavior when limiting the query. |
377
- | <a id="pg-filter-materialization"></a><a id="prisma-filter-materialization"></a>`pg-filter-materialization`, `prisma-filter-materialization` | Applying a literal equality filter in JS after loading an unbounded result. Check database collation and null semantics before moving the predicate. |
378
- | <a id="pg-top-k-materialization"></a><a id="prisma-top-k-materialization"></a>`pg-top-k-materialization`, `prisma-top-k-materialization` | Sorting an unbounded result with a numeric comparator to keep the top rows. Use database ordering and a limit with a stable tie-breaker. |
379
- | <a id="rebuild-lookup-in-loop"></a><a id="array-repeated-membership"></a><a id="array-repeated-find"></a>`array-repeated-membership`, `array-repeated-find`, `rebuild-lookup-in-loop` | Repeated linear lookups or rebuilt indexes. Reuse a Set or Map if inputs are stable and enough lookups justify construction. Preserve first-match semantics with duplicate keys. |
380
- | <a id="reduce-copy-accumulator"></a><a id="loop-copy-accumulator"></a><a id="filter-for-existence"></a>`reduce-copy-accumulator`, `loop-copy-accumulator`, `filter-for-existence` | Copying a growing result or allocating a filtered array for a boolean test. Consider a private accumulator or a short-circuiting predicate. |
381
- | <a id="pg-unreleased-checkout"></a><a id="pool-created-per-request-or-item"></a>`pool-created-per-request-or-item`, `pg-unreleased-checkout` | A recognized pg, Prisma, MongoDB or Redis client/pool is created on a repeated path, or a chained pg checkout loses the client reference. Scope reuse to the right credentials and release checked-out clients. |
382
- | <a id="node-sync-crypto-in-async"></a><a id="node-sync-process-in-async"></a><a id="node-sync-fs-in-async"></a><a id="node-sync-compression-in-async"></a>`node-sync-fs-in-async`, `node-sync-compression-in-async`, `node-sync-crypto-in-async`, `node-sync-process-in-async` | A recognized synchronous API blocks an async function. Examples include `readFileSync`, `gzipSync`, `scryptSync` and `execFileSync`. |
383
- | <a id="redis-command-in-loop"></a>`redis-command-in-loop` | A per-key Redis or Valkey command on a repeated path. Use a multi-key command or a bounded pipeline if cluster slots, ordering and error handling permit it. SCAN cursor loops are skipped. |
384
- | <a id="password-hash-sync-in-async"></a>`password-hash-sync-in-async` | `hashSync`, `compareSync` or `genSaltSync` from bcrypt or bcryptjs in an async function blocks the event loop for the whole hash. Use the promise form. |
385
- | <a id="serial-awaits-in-literal"></a>`serial-awaits-in-literal` | An array or object awaits multiple values in order. The `Promise.all` edit requires review for shared resources, concurrency limits and failure ordering. |
386
- | <a id="queue-add-in-loop"></a>`queue-add-in-loop` | `queue.add` on a recognized job queue runs once per item, one Redis round trip each. Collect the jobs and call `addBulk`, unless a later job needs the earlier job's result or id. |
387
- | <a id="redis-keys-command"></a>`redis-keys-command` | `keys()` on a recognized ioredis or node-redis client blocks Redis while it scans the keyspace. Iterate with `SCAN` (`scanStream` or `scanIterator`) after reviewing duplicate keys, iteration order and concurrent writes. |
388
- | <a id="service-query-in-loop"></a>`service-query-in-loop` | A call in a loop reaches several database operations through a project function, so the loop pays round trips for every item. Add a batch variant. Test, seed, benchmark and script sources get a softer note. |
389
- | <a id="password-hash-pure-js"></a>`password-hash-pure-js` | `bcryptjs` hashes in pure JavaScript and costs tens to hundreds of milliseconds of main-thread CPU per call. Use native `bcrypt`, `@node-rs/bcrypt` or `argon2`. Reported once per file; test files are skipped. |
390
- | <a id="external-call-in-transaction"></a>`external-call-in-transaction` | An external call is awaited inside a database transaction callback, holding the connection and locks until it returns. Move it before the transaction or after commit; side effects cannot roll back. |
391
- | <a id="unbounded-list-query"></a>`unbounded-list-query` | A Prisma, TypeORM, Drizzle or pg list query has no `take` or `limit` and its rows are returned from a request handler. Unique-key lookups are skipped; one-hop service findings require contextual mode. A page size taken straight from request input with no upper cap is reported too. |
392
- | <a id="unbounded-module-cache"></a>`unbounded-module-cache` | A module-level or singleton-service `Map`, `Set` or object is filled by dynamic key inside functions and never deleted from, cleared or size-checked. The key space may still be small. |
393
- | <a id="whole-payload-in-memory"></a>`whole-payload-in-memory` | A handler reads a request-chosen path with `fs.readFile`, or a download or stream is buffered whole only to be written out. Stream it with `pipeline`. The `Response` check needs fetch types. |
394
- | <a id="list-query-overfetch"></a>`list-query-overfetch` | A Prisma `findMany` or TypeORM `find` without `select` loads `Json`, `Bytes` or text columns, or relations two levels deep. Column checks need a parseable schema; pages up to 100 rows skip them. |
395
- | <a id="orm-deep-offset"></a>`orm-deep-offset` | A Prisma `skip`, TypeORM, Sequelize, Mongoose, Drizzle or Knex offset, or a pg `OFFSET $n`, takes request input with no upper bound, or is a literal above 10000. The database reads and discards every skipped row; use keyset (cursor) pagination. One-hop service calls and schemas whose limit cannot be read are contextual. |
396
- | <a id="list-count-per-request"></a>`list-count-per-request` | A request handler that pages rows also runs a full count (`count`, `findAndCount`, `countDocuments`, `select count(...)`) and returns the total. Cached and first-page-only counts are skipped; counts filtered by an id column, and counts with the same `where` as a list limited to one page (`take`/`limit`), are contextual. A serial count then page is `count-then-page-serial` instead. |
397
- | <a id="notification-send-in-loop"></a>`notification-send-in-loop` | A firebase-admin, SendGrid, Expo, OneSignal or SNS send runs once per loop item where the provider has a batch API. nodemailer, web-push, Twilio and SES sends are contextual because their batch shape depends on the content. Providers are recognised from their types. |
398
- | <a id="session-memory-store"></a>`session-memory-store` | `express-session` or `@fastify/session` is set up without a `store`, so sessions live in process memory: they leak, are lost on restart and are not shared across instances. Pass a shared store such as connect-redis or connect-pg-simple. |
399
- | <a id="orm-cartesian-include"></a>`orm-cartesian-include` | One TypeORM or Sequelize query joins two or more collection relations (`leftJoinAndSelect`, `relations`, `include`), so the rows multiply as the product of their sizes. Load the second collection in its own query (`relationLoadStrategy: 'query'`, Sequelize `separate: true`). |
400
- | <a id="json-roundtrip-clone"></a>`json-roundtrip-clone` | A value is deep-copied with `JSON.parse(JSON.stringify(...))` in a request handler or loop. Use `structuredClone`, or copy only the fields you change. |
401
- | <a id="mongoose-hydrate-for-to-object"></a>`mongoose-hydrate-for-to-object` | A Mongoose `find`, `findOne` or `findById` result is only null-checked and converted with `.toObject()` or `.toJSON()`. Append `.lean()` to skip hydration. Skipped when a schema customizes `toObject` or `toJSON`. |
402
- | <a id="express-missing-compression"></a>`express-missing-compression` | An Express app calls `listen` and no project file imports `compression`. Reported as contextual: a reverse proxy may already compress responses. Test files are skipped. |
403
- | <a id="heavy-media-in-request-handler"></a>`heavy-media-in-request-handler` | `sharp` image processing, Puppeteer `page.pdf()` or `html-pdf` rendering runs inside a request handler. Move it to a job queue or worker thread. Contextual, because offloading changes the API. |
404
- | <a id="react-missing-cleanup"></a>`react-missing-cleanup` | An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount. |
405
- | <a id="react-index-as-key"></a>`react-index-as-key` | A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered. |
406
- | <a id="react-fetch-in-effect-no-abort"></a>`react-fetch-in-effect-no-abort` | A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results. |
407
- | <a id="react-inline-object-in-jsx-prop"></a>`react-inline-object-in-jsx-prop` | An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo. |
408
- | <a id="angular-subscribe-without-cleanup"></a>`angular-subscribe-without-cleanup` | An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction. |
409
- | <a id="angular-default-change-detection"></a>`angular-default-change-detection` | An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event. |
410
- | <a id="vue-watch-missing-cleanup"></a>`vue-watch-missing-cleanup` | onMounted registers a global listener, timer or observer with no unmount cleanup. |
411
- | <a id="vue-v-for-missing-key"></a>`vue-v-for-missing-key` | A list rendered with h() has no key prop, forcing inefficient patching. |
412
- | <a id="dom-layout-thrashing"></a>`dom-layout-thrashing` | A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration. |
413
- | <a id="dom-listener-without-cleanup"></a>`dom-listener-without-cleanup` | A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed. |
414
- | <a id="dom-unthrottled-scroll-resize"></a>`dom-unthrottled-scroll-resize` | A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread. |
415
- | <a id="frontend-barrel-heavy-import"></a>`frontend-barrel-heavy-import` | A client module imports the whole of lodash or moment instead of subpaths or a lighter library. |
416
- | <a id="sql-select-star-in-query"></a>`sql-select-star-in-query` | A raw SQL query selects every column with SELECT * instead of the columns it needs. |
417
- | <a id="sequential-http-in-loop"></a>`sequential-http-in-loop` | Independent HTTP requests are awaited one at a time inside a loop. |
418
- | <a id="mongoose-missing-lean"></a>`mongoose-missing-lean` | A Mongoose `.find()`, `.findOne()`, or `.findById()` read query is returned or JSON-serialized without `.lean()`. |
419
- | <a id="graphql-n-plus-one-resolver"></a>`graphql-n-plus-one-resolver` | A GraphQL field resolver executes a database or HTTP query per parent item without `DataLoader` `.load()` batching. |
420
- | <a id="react-context-value-recreated"></a>`react-context-value-recreated` | An inline object or array literal in `<*.Provider value={...}>` creates a new reference on every render without `useMemo`. |
421
- | <a id="node-event-listener-leak"></a>`node-event-listener-leak` | `.on()`, `.addListener()`, or `.addEventListener()` is registered in a request handler, loop, or lifecycle hook without cleanup. |
422
- | <a id="json-stringify-in-loop"></a>`json-stringify-in-loop` | `JSON.stringify()` is called inside a `for`, `while`, `do`, `.forEach`, `.map`, or `.reduce` loop. |
476
+ Run in the directory containing `tsconfig.json` or `jsconfig.json`, pass `-p path/to/config.json`, or give explicit JS/TS files. A project check scans the config's input files and follows project references. Declaration files supply types. A standalone file check uses ES2022 and NodeNext compiler defaults. Use a project config for aliases, custom libraries and JS projects with `allowJs`. When the config Loadwise finds leaves JavaScript files in its folder out because `allowJs` is off, Loadwise still checks them with those standalone defaults and a note names them; set `allowJs` or add a `jsconfig.json` to check them with the project's settings. A config passed with `-p` is checked exactly as it lists its files, and the note names the JavaScript it leaves out.
477
+
478
+ <!-- loadwise:rules:start checker=performance group=source-checks -->
479
+
480
+ | Rule | Impact | What it flags |
481
+ | --------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
482
+ | <a id="angular-default-change-detection"></a>[`angular-default-change-detection`](docs/rules/angular-default-change-detection.md) | low | An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event. |
483
+ | <a id="angular-ngfor-missing-trackby"></a>[`angular-ngfor-missing-trackby`](docs/rules/angular-ngfor-missing-trackby.md) | low | An *ngFor has no trackBy, so a list replaced with new objects recreates the DOM of every item. |
484
+ | <a id="angular-subscribe-without-cleanup"></a>[`angular-subscribe-without-cleanup`](docs/rules/angular-subscribe-without-cleanup.md) | medium | An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction. |
485
+ | <a id="array-repeated-find"></a>[`array-repeated-find`](docs/rules/array-repeated-find.md) | medium | An array is searched with find or findIndex repeatedly where a Map lookup would do. |
486
+ | <a id="array-repeated-membership"></a>[`array-repeated-membership`](docs/rules/array-repeated-membership.md) | medium | An array is tested with includes or indexOf repeatedly where a Set would do. |
487
+ | <a id="dom-layout-thrashing"></a>[`dom-layout-thrashing`](docs/rules/dom-layout-thrashing.md) | medium | A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration. |
488
+ | <a id="dom-listener-without-cleanup"></a>[`dom-listener-without-cleanup`](docs/rules/dom-listener-without-cleanup.md) | low | A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed. |
489
+ | <a id="dom-unthrottled-scroll-resize"></a>[`dom-unthrottled-scroll-resize`](docs/rules/dom-unthrottled-scroll-resize.md) | low | A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread. |
490
+ | <a id="express-missing-compression"></a>[`express-missing-compression`](docs/rules/express-missing-compression.md) | low | An Express server registers no response compression middleware. |
491
+ | <a id="external-call-in-transaction"></a>[`external-call-in-transaction`](docs/rules/external-call-in-transaction.md) | high | An external call is awaited inside a database transaction, holding its connection and locks. |
492
+ | <a id="filter-for-existence"></a>[`filter-for-existence`](docs/rules/filter-for-existence.md) | low | filter(...).length is used only to test whether any element matches. |
493
+ | <a id="frontend-barrel-heavy-import"></a>[`frontend-barrel-heavy-import`](docs/rules/frontend-barrel-heavy-import.md) | low | A client module imports the whole of lodash or moment instead of subpaths or a lighter library. |
494
+ | <a id="graphql-n-plus-one-resolver"></a>[`graphql-n-plus-one-resolver`](docs/rules/graphql-n-plus-one-resolver.md) | high | A GraphQL field resolver executes a database or HTTP query per parent item without DataLoader batching. |
495
+ | <a id="heavy-media-in-request-handler"></a>[`heavy-media-in-request-handler`](docs/rules/heavy-media-in-request-handler.md) | medium | Heavy image (sharp) or PDF rendering runs directly inside an HTTP request handler. |
496
+ | <a id="json-roundtrip-clone"></a>[`json-roundtrip-clone`](docs/rules/json-roundtrip-clone.md) | low | A value is deep-cloned with JSON.parse(JSON.stringify(...)) on a request path. |
497
+ | <a id="json-stringify-in-loop"></a>[`json-stringify-in-loop`](docs/rules/json-stringify-in-loop.md) | medium | JSON.stringify runs inside a loop instead of serializing once or streaming. |
498
+ | <a id="list-count-per-request"></a>[`list-count-per-request`](docs/rules/list-count-per-request.md) | medium | A list endpoint runs a full count query on every request. |
499
+ | <a id="list-query-overfetch"></a>[`list-query-overfetch`](docs/rules/list-query-overfetch.md) | medium | A list query loads large columns or nested relations without a narrow projection. |
500
+ | <a id="llm-call-without-max-tokens"></a>[`llm-call-without-max-tokens`](docs/rules/llm-call-without-max-tokens.md) | medium | An OpenAI chat or responses call sets no output token limit. |
501
+ | <a id="loop-copy-accumulator"></a>[`loop-copy-accumulator`](docs/rules/loop-copy-accumulator.md) | medium | A loop copies its growing result on every iteration. |
502
+ | <a id="mongoose-hydrate-for-to-object"></a>[`mongoose-hydrate-for-to-object`](docs/rules/mongoose-hydrate-for-to-object.md) | medium | A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON(). |
503
+ | <a id="mongoose-missing-lean"></a>[`mongoose-missing-lean`](docs/rules/mongoose-missing-lean.md) | medium | A Mongoose read query is returned or serialized without .lean(), paying full Document hydration overhead. |
504
+ | <a id="node-event-listener-leak"></a>[`node-event-listener-leak`](docs/rules/node-event-listener-leak.md) | high | An event listener is registered inside a repeated or per-request context without matching cleanup. |
505
+ | <a id="node-sync-compression-in-async"></a>[`node-sync-compression-in-async`](docs/rules/node-sync-compression-in-async.md) | medium | A synchronous zlib call blocks the event loop inside an async function. |
506
+ | <a id="node-sync-crypto-in-async"></a>[`node-sync-crypto-in-async`](docs/rules/node-sync-crypto-in-async.md) | high | A synchronous crypto call blocks the event loop inside an async function. |
507
+ | <a id="node-sync-fs-in-async"></a>[`node-sync-fs-in-async`](docs/rules/node-sync-fs-in-async.md) | medium | A synchronous fs call blocks the event loop inside an async function. |
508
+ | <a id="node-sync-process-in-async"></a>[`node-sync-process-in-async`](docs/rules/node-sync-process-in-async.md) | high | A synchronous child_process call blocks the event loop inside an async function. |
509
+ | <a id="notification-send-in-loop"></a>[`notification-send-in-loop`](docs/rules/notification-send-in-loop.md) | high | A push, email or Firebase message is sent once per loop iteration instead of in one batch. |
510
+ | <a id="orm-cartesian-include"></a>[`orm-cartesian-include`](docs/rules/orm-cartesian-include.md) | high | One query joins two or more one-to-many relations, so the returned rows multiply. |
511
+ | <a id="orm-deep-offset"></a>[`orm-deep-offset`](docs/rules/orm-deep-offset.md) | high | A list query pages with a large or unbounded offset, so the database reads and discards every skipped row. |
512
+ | <a id="password-hash-pure-js"></a>[`password-hash-pure-js`](docs/rules/password-hash-pure-js.md) | medium | bcryptjs hashes passwords in pure JavaScript on the main thread. |
513
+ | <a id="password-hash-sync-in-async"></a>[`password-hash-sync-in-async`](docs/rules/password-hash-sync-in-async.md) | high | A synchronous bcrypt call blocks the event loop inside an async function. |
514
+ | <a id="pg-count-materialization"></a>[`pg-count-materialization`](docs/rules/pg-count-materialization.md) | medium | A pg query loads rows only to count them. |
515
+ | <a id="pg-filter-materialization"></a>[`pg-filter-materialization`](docs/rules/pg-filter-materialization.md) | medium | A pg query loads an unbounded result that JavaScript then filters by equality. |
516
+ | <a id="pg-first-materialization"></a>[`pg-first-materialization`](docs/rules/pg-first-materialization.md) | medium | A pg query loads an unbounded result to read only its first row. |
517
+ | <a id="pg-query-in-loop"></a>[`pg-query-in-loop`](docs/rules/pg-query-in-loop.md) | high | A pg query runs once per loop iteration. |
518
+ | <a id="pg-top-k-materialization"></a>[`pg-top-k-materialization`](docs/rules/pg-top-k-materialization.md) | medium | A pg query loads an unbounded result that JavaScript sorts to keep the top rows. |
519
+ | <a id="pg-unreleased-checkout"></a>[`pg-unreleased-checkout`](docs/rules/pg-unreleased-checkout.md) | critical | A chained pool checkout loses the client, so it is never released. |
520
+ | <a id="pool-created-per-request-or-item"></a>[`pool-created-per-request-or-item`](docs/rules/pool-created-per-request-or-item.md) | critical | A database, Redis, S3, OpenAI, Anthropic or Stripe client or pool is created on a per-request or per-item path. |
521
+ | <a id="prisma-count-materialization"></a>[`prisma-count-materialization`](docs/rules/prisma-count-materialization.md) | medium | A Prisma query loads rows only to count them. |
522
+ | <a id="prisma-filter-materialization"></a>[`prisma-filter-materialization`](docs/rules/prisma-filter-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript then filters by equality. |
523
+ | <a id="prisma-first-materialization"></a>[`prisma-first-materialization`](docs/rules/prisma-first-materialization.md) | medium | A Prisma query loads an unbounded result to read only its first row. |
524
+ | <a id="prisma-query-in-loop"></a>[`prisma-query-in-loop`](docs/rules/prisma-query-in-loop.md) | high | A Prisma query runs once per loop iteration. |
525
+ | <a id="prisma-top-k-materialization"></a>[`prisma-top-k-materialization`](docs/rules/prisma-top-k-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript sorts to keep the top rows. |
526
+ | <a id="queue-add-in-loop"></a>[`queue-add-in-loop`](docs/rules/queue-add-in-loop.md) | high | A job queue add runs once per item instead of one addBulk. |
527
+ | <a id="react-component-defined-in-component"></a>[`react-component-defined-in-component`](docs/rules/react-component-defined-in-component.md) | medium | A component is declared inside another component and rendered as an element, so it remounts on every render and loses its state and DOM. |
528
+ | <a id="react-context-value-recreated"></a>[`react-context-value-recreated`](docs/rules/react-context-value-recreated.md) | low | An inline object or array literal in Context.Provider value creates a new reference on every render. |
529
+ | <a id="react-fetch-in-effect-no-abort"></a>[`react-fetch-in-effect-no-abort`](docs/rules/react-fetch-in-effect-no-abort.md) | low | A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results. |
530
+ | <a id="react-index-as-key"></a>[`react-index-as-key`](docs/rules/react-index-as-key.md) | low | A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered. |
531
+ | <a id="react-inline-object-in-jsx-prop"></a>[`react-inline-object-in-jsx-prop`](docs/rules/react-inline-object-in-jsx-prop.md) | low | An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo. |
532
+ | <a id="react-missing-cleanup"></a>[`react-missing-cleanup`](docs/rules/react-missing-cleanup.md) | medium | An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount. |
533
+ | <a id="rebuild-lookup-in-loop"></a>[`rebuild-lookup-in-loop`](docs/rules/rebuild-lookup-in-loop.md) | high | A Set or Map is rebuilt from the same data on every loop iteration. |
534
+ | <a id="redis-command-in-loop"></a>[`redis-command-in-loop`](docs/rules/redis-command-in-loop.md) | high | A per-key Redis command runs once per loop iteration. |
535
+ | <a id="redis-keys-command"></a>[`redis-keys-command`](docs/rules/redis-keys-command.md) | high | A Redis KEYS call blocks the server while it scans the keyspace. |
536
+ | <a id="reduce-copy-accumulator"></a>[`reduce-copy-accumulator`](docs/rules/reduce-copy-accumulator.md) | medium | A reduce callback copies its growing accumulator on every step. |
537
+ | <a id="sequential-http-in-loop"></a>[`sequential-http-in-loop`](docs/rules/sequential-http-in-loop.md) | high | Independent HTTP requests are awaited one at a time inside a loop. |
538
+ | <a id="serial-awaits-in-literal"></a>[`serial-awaits-in-literal`](docs/rules/serial-awaits-in-literal.md) | medium | An array or object literal awaits two or more independent values one after another. |
539
+ | <a id="service-query-in-loop"></a>[`service-query-in-loop`](docs/rules/service-query-in-loop.md) | high | A loop calls a project function that runs several database operations per item. |
540
+ | <a id="session-memory-store"></a>[`session-memory-store`](docs/rules/session-memory-store.md) | high | An express-session middleware has no store, so sessions live in process memory. |
541
+ | <a id="sql-select-star-in-query"></a>[`sql-select-star-in-query`](docs/rules/sql-select-star-in-query.md) | low | A raw SQL query selects every column with SELECT * instead of the columns it needs. |
542
+ | <a id="unbounded-list-query"></a>[`unbounded-list-query`](docs/rules/unbounded-list-query.md) | high | A request handler returns query results without an apparent row limit. |
543
+ | <a id="unbounded-module-cache"></a>[`unbounded-module-cache`](docs/rules/unbounded-module-cache.md) | medium | A long-lived cache accepts dynamic keys without an apparent bound or eviction. |
544
+ | <a id="vue-v-for-missing-key"></a>[`vue-v-for-missing-key`](docs/rules/vue-v-for-missing-key.md) | low | A list rendered with h() has no key prop, forcing inefficient patching. |
545
+ | <a id="vue-watch-missing-cleanup"></a>[`vue-watch-missing-cleanup`](docs/rules/vue-watch-missing-cleanup.md) | medium | onMounted registers a global listener, timer or observer with no unmount cleanup. |
546
+ | <a id="whole-payload-in-memory"></a>[`whole-payload-in-memory`](docs/rules/whole-payload-in-memory.md) | medium | An operation loads an entire file, stream, or response into memory. |
547
+
548
+ <!-- loadwise:rules:end -->
423
549
 
424
550
  Source diagnostics include a one-based line and column. Repeat `--ignore RULE` to omit specific JS/TS rules from a run. Keep your project's own type check in CI.
425
551
 
@@ -452,14 +578,22 @@ The JS/TS checker resolves declarations from installed drivers and generated cli
452
578
  | Knex and Kysely | Consumed Knex builders and Kysely SELECT execution methods inside repeated work. Simple single-table queries materialized only to read their length. |
453
579
  | node-postgres | Per-item queries, client-side result processing, pool handoff and transaction commands issued through a pool. |
454
580
 
455
- <a id="drizzle-query-in-loop"></a><a id="orm-query-in-loop"></a><a id="typeorm-transaction-in-loop"></a><a id="orm-count-materialization"></a><a id="typeorm-existence-materialization"></a><a id="typeorm-wide-projection"></a>`orm-query-in-loop`, `drizzle-query-in-loop` and `orm-count-materialization` preserve the distinction between building a lazy statement and executing it. Counts with pagination, grouping, joins, hooks or scopes need particular care. TypeORM checks also identify entity reads used only for existence (`typeorm-existence-materialization`), unused wide columns in a direct DTO projection (`typeorm-wide-projection`), and a loop calling a local private helper that starts a transaction (`typeorm-transaction-in-loop`). Before changing a projection or an existence check, verify entity-load side effects. For per-row transactions, check rollback, ordering and error reporting before batching. The adapters recognize specific typed APIs. Custom methods with the same name, raw queries and wrappers often have different semantics.
581
+ <!-- loadwise:rules:start checker=performance group=orm-and-query-integrity-checks -->
456
582
 
457
- | Integrity rule | What to review |
458
- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
459
- | <a id="prisma-distinct-in-memory"></a>`prisma-distinct-in-memory` | `findMany({ distinct })` reads every matching row and de-duplicates in Prisma's query engine, not with SQL `DISTINCT`. Use `groupBy` or a raw `SELECT DISTINCT`. Quiet when the `nativeDistinct` preview feature is enabled. |
460
- | <a id="prisma-relation-count-in-list"></a>`prisma-relation-count-in-list` | A paged `findMany` selects `_count` of a relation, which Prisma computes over the whole related table. Fetch the page, then `groupBy` for the page ids and merge the counts. |
461
- | <a id="typeorm-load-then-save"></a>`typeorm-load-then-save` | A repository entity is loaded only to change a few fields and then `save()`d, costing a SELECT, an UPDATE and a transaction. Use `update()` or `increment()`; entity listeners and subscribers for update will not run. |
462
- | <a id="guard-query-per-request"></a>`guard-query-per-request` | A guard or similar per-request hook runs a database query before every handler. Cache the lookup with a short TTL and explicit invalidation, or carry the claims in the token. |
583
+ | Rule | Impact | What it flags |
584
+ | ------------------------------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------- |
585
+ | <a id="drizzle-query-in-loop"></a>[`drizzle-query-in-loop`](docs/rules/drizzle-query-in-loop.md) | high | A Drizzle statement executes once per loop iteration. |
586
+ | <a id="guard-query-per-request"></a>[`guard-query-per-request`](docs/rules/guard-query-per-request.md) | medium | A guard or per-request hook runs a database query before every handler. |
587
+ | <a id="orm-count-materialization"></a>[`orm-count-materialization`](docs/rules/orm-count-materialization.md) | medium | A TypeORM, Sequelize, Mongoose, Knex or Kysely query loads rows only to count them. |
588
+ | <a id="orm-query-in-loop"></a>[`orm-query-in-loop`](docs/rules/orm-query-in-loop.md) | high | A TypeORM, Sequelize, Mongoose, Knex or Kysely operation runs once per loop iteration. |
589
+ | <a id="prisma-distinct-in-memory"></a>[`prisma-distinct-in-memory`](docs/rules/prisma-distinct-in-memory.md) | medium | Prisma findMany with distinct reads every matching row and de-duplicates in memory. |
590
+ | <a id="prisma-relation-count-in-list"></a>[`prisma-relation-count-in-list`](docs/rules/prisma-relation-count-in-list.md) | medium | A paged Prisma findMany selects a relation _count computed over the whole related table. |
591
+ | <a id="typeorm-existence-materialization"></a>[`typeorm-existence-materialization`](docs/rules/typeorm-existence-materialization.md) | medium | A TypeORM entity is loaded only to check whether it exists. |
592
+ | <a id="typeorm-load-then-save"></a>[`typeorm-load-then-save`](docs/rules/typeorm-load-then-save.md) | high | A TypeORM entity is loaded only to change a few fields and save it back. |
593
+ | <a id="typeorm-transaction-in-loop"></a>[`typeorm-transaction-in-loop`](docs/rules/typeorm-transaction-in-loop.md) | high | A loop calls a helper that starts one TypeORM transaction per item. |
594
+ | <a id="typeorm-wide-projection"></a>[`typeorm-wide-projection`](docs/rules/typeorm-wide-projection.md) | low | A TypeORM DTO projection loads wide columns it never uses. |
595
+
596
+ <!-- loadwise:rules:end -->
463
597
 
464
598
  For Prisma, building an array of lazy queries alone is quiet. A sequential `await` inside a loop can trigger the rule. Same-tick `findUnique` callbacks can use Prisma's own batching, so these are left to runtime traces. [Prisma Client reference](https://www.prisma.io/docs/orm/reference/prisma-client-reference#prismapromise-behavior) · [Prisma transactions](https://www.prisma.io/docs/orm/prisma-client/queries/transactions) · [node-postgres transactions](https://node-postgres.com/features/transactions) · [Drizzle conditional filters](https://orm.drizzle.team/docs/guides/conditional-filters-in-query)
465
599
 
@@ -469,17 +603,21 @@ Put the policy in the `performance` section of `loadwise.config.json` beside the
469
603
 
470
604
  ### Async work and sorting
471
605
 
472
- | Rule | When it reports |
473
- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
474
- | <a id="promise-combinator-serial-await"></a>`promise-combinator-serial-await` | A built-in `Promise.all` or `Promise.allSettled` receives an array of two or more already-awaited calls with known promise types. Starting them together changes which calls run after a failure. With `allSettled`, it also changes how rejections are returned. |
475
- | <a id="known-reads-awaited-serially"></a>`known-reads-awaited-serially` | Two adjacent awaited reads come from a project-configured `parallelReads` group and the second call is independent of the first result in a supported straight-line shape. |
476
- | <a id="numeric-sort-for-extreme"></a>`numeric-sort-for-extreme` | A numeric comparison sort on a private copy, or a nonmutating numeric sort, is used only to retrieve its first or last value. A single-pass extreme can use constant extra space. Preserve empty input, NaN, sparse inputs and signed-zero semantics when applicable. |
477
- | <a id="count-then-page-serial"></a>`count-then-page-serial` | A `count()` and a page query with the same filter run one after the other (TypeORM query builder or repository, Prisma). Use `getManyAndCount()` or `findAndCount()`, or start both Prisma calls together with `Promise.all` outside an interactive transaction. |
478
- | <a id="typeorm-unused-count"></a>`typeorm-unused-count` | A typed TypeORM `findAndCount()`, `findAndCountBy()` or `getManyAndCount()` call returns rows and a count but the awaited destructuring only keeps the rows. Use `find()`, `findBy()` or `getMany()` with the same filters and paging when the count is unnecessary. |
479
- | <a id="prisma-count-for-existence"></a>`prisma-count-for-existence` | An awaited numeric Prisma `count()` with no options or only `where` is used solely as a zero-or-nonzero test. Read one row with the same filter and a small projection when only existence matters. |
480
- | <a id="await-before-early-exit"></a>`await-before-early-exit` | An awaited ORM or HTTP read is followed directly by an `if` that returns or throws without using the result, so a request the guard rejects still pays the round trip. Writes, `OrThrow` reads and POSTs are left alone. The fix moves the guard above the await only when it has no calls and reads only parameters and earlier constants. |
481
- | <a id="drizzle-last-insert-id"></a>`drizzle-last-insert-id` | A MySQL insert is followed by a separate query for the last generated ID. Review using the insert result directly, especially when the database handle uses a connection pool. |
482
- | <a id="repeated-workbook-decode"></a>`repeated-workbook-decode` | Sibling awaits pass the same input to ExcelJS workbook decoding directly or through same-file private methods or functions. Share a parsed workbook when its readers can safely use the same state. |
606
+ <!-- loadwise:rules:start checker=performance group=async-work-and-sorting -->
607
+
608
+ | Rule | Impact | What it flags |
609
+ | ------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------- |
610
+ | <a id="await-before-early-exit"></a>[`await-before-early-exit`](docs/rules/await-before-early-exit.md) | medium | An awaited read runs before a guard that returns or throws without using its result. |
611
+ | <a id="count-then-page-serial"></a>[`count-then-page-serial`](docs/rules/count-then-page-serial.md) | low | A count and a page query with the same filter run one after the other. |
612
+ | <a id="drizzle-last-insert-id"></a>[`drizzle-last-insert-id`](docs/rules/drizzle-last-insert-id.md) | medium | A MySQL insert is followed by an extra query for its generated ID. |
613
+ | <a id="known-reads-awaited-serially"></a>[`known-reads-awaited-serially`](docs/rules/known-reads-awaited-serially.md) | medium | Two independent reads from a configured parallelReads group are awaited one after the other. |
614
+ | <a id="numeric-sort-for-extreme"></a>[`numeric-sort-for-extreme`](docs/rules/numeric-sort-for-extreme.md) | low | A numeric sort is used only to read the smallest or largest value. |
615
+ | <a id="prisma-count-for-existence"></a>[`prisma-count-for-existence`](docs/rules/prisma-count-for-existence.md) | medium | A Prisma query counts all matches only to check whether any row exists. |
616
+ | <a id="promise-combinator-serial-await"></a>[`promise-combinator-serial-await`](docs/rules/promise-combinator-serial-await.md) | medium | Promise.all receives calls that were already awaited one by one. |
617
+ | <a id="repeated-workbook-decode"></a>[`repeated-workbook-decode`](docs/rules/repeated-workbook-decode.md) | medium | A workflow decodes the same input with ExcelJS more than once. |
618
+ | <a id="typeorm-unused-count"></a>[`typeorm-unused-count`](docs/rules/typeorm-unused-count.md) | medium | A TypeORM count-and-list query discards its total in immediate tuple destructuring. |
619
+
620
+ <!-- loadwise:rules:end -->
483
621
 
484
622
  The example policy declares that `fetchUser` and `fetchPosts` from `@app/reads` may start together. Only group operations whose ordering, shared connections, rate limits and failure effects your project has reviewed. With that declaration, the checker can flag the pair below. Ordinary adjacent calls such as `saveSettings()` followed by `reloadSettings()` carry no such contract.
485
623
 
@@ -504,7 +642,7 @@ npx loadwise perf -p tsconfig.json --fix # asks y/n/a/q for each fix; ne
504
642
  npx loadwise perf -p tsconfig.json --fix --yes # applies eligible fixes without asking
505
643
  ```
506
644
 
507
- `--fix` answers are **y**es, **n**o, **a**ll remaining and **q**uit. Without a terminal it requires `--yes`. `--fix` cannot be combined with `--watch`, or with `--json` except with `--only`, and `--yes` is valid only with `--fix`. A fix applies only where the original lines still exist, so code that changed since the scan is refused and a change already in the file is reported as already applied. A fix never overwrites an existing file. Like `loadwise fix`, it adds a why-comment above each fixed statement and formats the changed lines with the project's Prettier; `--no-comments` and `--no-format` turn these off. Review the diff and run your tests afterwards. Rewrites that narrow a whole-table Drizzle update to rows with differing values require individual review because the change can affect locking, triggers and affected-row counts. Upload size limits also require individual review. The 10 MiB example can reject valid uploads, so check the endpoint's file requirements and any existing gateway or Multer limits before applying it.
645
+ `--fix` answers are **y**es, **n**o, **a**ll remaining and **q**uit. Without a terminal it requires `--yes`. `--fix` cannot be combined with `--watch`, or with `--json` except with `--only`, and `--yes` is valid only with `--fix`. A fix applies only where the original lines still exist, so code that changed since the scan is refused and a change already in the file is reported as already applied. A fix never overwrites an existing file. Like `loadwise fix`, it adds a why-comment above each fixed statement and formats the changed lines with the project's Prettier; `--no-comments` and `--no-format` turn these off. Review the diff and run your tests afterwards. Rewrites that narrow a whole-table Drizzle update to rows with differing values require individual review because the change can affect locking, triggers and affected-row counts. Upload size limits also require individual review. So does the Mongoose `.lean()` rewrite, because a lean result skips schema defaults, getters and virtuals. The 10 MiB example can reject valid uploads, so check the endpoint's file requirements and any existing gateway or Multer limits before applying it.
508
646
 
509
647
  ## Apply fixes by id
510
648
 
@@ -530,14 +668,18 @@ Both flags report only findings on changed lines, each with its id, the exact `-
530
668
 
531
669
  The source checker reads the project's ORM schema (Prisma, Drizzle, TypeORM, Sequelize, Mongoose) and compares declared indexes with the queries it finds.
532
670
 
533
- | Rule | What it flags |
534
- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
535
- | <a id="index-missing-filter"></a>`index-missing-filter` | A query filters on a column that no index leads with. |
536
- | <a id="index-missing-order"></a>`index-missing-order` | A query orders by columns no index can serve in that order. |
537
- | <a id="index-missing-foreign-key"></a>`index-missing-foreign-key` | A foreign key column has no index. |
538
- | <a id="index-unusable-pattern"></a>`index-unusable-pattern` | A predicate such as a leading-wildcard `LIKE` cannot use an ordinary index. |
539
- | <a id="index-unusable-expression"></a>`index-unusable-expression` | A function or expression on an indexed column prevents the index from being used. |
540
- | <a id="index-redundant-prefix"></a>`index-redundant-prefix` | An index repeats the leading columns of a longer index on the same table (or duplicates it), adding write and memory cost while serving no read the longer one cannot; drop the shorter one (for Sequelize, remove it from the model too, since `sync({ alter: true })` recreates it). An index inherited from a base entity is reported once, at the base class. |
671
+ <!-- loadwise:rules:start checker=performance group=schema-aware-index-checks -->
672
+
673
+ | Rule | Impact | What it flags |
674
+ | ------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
675
+ | <a id="index-missing-filter"></a>[`index-missing-filter`](docs/rules/index-missing-filter.md) | high | A query filters on a column that no index leads with. |
676
+ | <a id="index-missing-foreign-key"></a>[`index-missing-foreign-key`](docs/rules/index-missing-foreign-key.md) | high | A foreign key column in the schema has no index. |
677
+ | <a id="index-missing-order"></a>[`index-missing-order`](docs/rules/index-missing-order.md) | medium | A query orders by columns that no index serves in that order. |
678
+ | <a id="index-redundant-prefix"></a>[`index-redundant-prefix`](docs/rules/index-redundant-prefix.md) | low | An index repeats the leading columns of a longer index on the same table, adding write cost for no read benefit. |
679
+ | <a id="index-unusable-expression"></a>[`index-unusable-expression`](docs/rules/index-unusable-expression.md) | high | A function or expression on an indexed column keeps the index from being used. |
680
+ | <a id="index-unusable-pattern"></a>[`index-unusable-pattern`](docs/rules/index-unusable-pattern.md) | high | A predicate such as a leading-wildcard LIKE cannot use an ordinary index. |
681
+
682
+ <!-- loadwise:rules:end -->
541
683
 
542
684
  Each suggested index carries one explicit name, used both in the ORM snippet (`@@index([a, b], map: "<name>")`, `@Index('<name>', ['a', 'b'])`, `{ name: '<name>', fields: [...] }`, `index('<name>')`, `schema.index({ a: 1 }, { name: '<name>' })`) and in the `CREATE INDEX CONCURRENTLY` statement for a live database, so building it by hand and then generating a migration does not create a duplicate. A fix that adds an index to a Prisma, TypeORM or Drizzle model says to generate a migration for it.
543
685
 
@@ -549,25 +691,29 @@ Pass `--schema snapshot.json` (written by `db --schema-snapshot`) to refine them
549
691
 
550
692
  Performance and maintainability scans retry files when the bundled parser rejects a Java marker annotation before varargs or a C# 14 conditional member assignment (`=`) in a simple identifier chain. The retry uses a position-preserving copy in memory and still fails if the parser reports a syntax error.
551
693
 
552
- | Rule | Example in a loop |
553
- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
554
- | <a id="python-copy-growing-list"></a>`python-copy-growing-list` | A list initialized to `[]` is repeatedly assigned `items = items + [value]` in a simple loop. |
555
- | <a id="python-sync-requests-in-async"></a>`python-sync-requests-in-async` | A `requests.get`, `post`, `put`, `patch`, `delete` or `request` call inside an `async def` function blocks the event loop. |
556
- | <a id="python-blocking-sleep-in-async"></a>`python-blocking-sleep-in-async` | `time.sleep(...)` inside an `async def` function, in a module that imports `time`. |
557
- | <a id="python-fixed-regex-in-loop"></a>`python-fixed-regex-in-loop` | `re.compile("pattern")` with a string literal, in a module that imports `re`. |
558
- | <a id="go-fixed-regexp-in-loop"></a>`go-fixed-regexp-in-loop` | `regexp.Compile("pattern")` or `regexp.MustCompile("pattern")` |
559
- | <a id="java-fixed-regex-in-loop"></a>`java-fixed-regex-in-loop` | `Pattern.compile("pattern")` |
560
- | <a id="csharp-fixed-regex-in-loop"></a>`csharp-fixed-regex-in-loop` | `new Regex("pattern")` |
561
- | <a id="rust-fixed-regex-in-loop"></a>`rust-fixed-regex-in-loop` | `Regex::new("pattern")` |
562
- | <a id="python-n-plus-one-orm-loop"></a>`python-n-plus-one-orm-loop` | An ORM query executes inside a Python `for` loop instead of eager loading or batching. |
563
- | <a id="python-unbounded-comprehension"></a>`python-unbounded-comprehension` | A Python list comprehension materializes an unbounded collection in memory. |
564
- | <a id="go-sql-query-in-loop"></a>`go-sql-query-in-loop` | A Go `sql.DB` or ORM query executes inside a `for` loop instead of batching. |
565
- | <a id="go-string-concat-in-loop"></a>`go-string-concat-in-loop` | Repeated `+=` string concatenation inside a Go `for` loop instead of `strings.Builder`. |
566
- | <a id="java-string-concat-in-loop"></a>`java-string-concat-in-loop` | Repeated `+=` string concatenation inside a Java loop instead of `StringBuilder`. |
567
- | <a id="java-jdbc-query-in-loop"></a>`java-jdbc-query-in-loop` | A JDBC query executes inside a Java loop instead of batching. |
568
- | <a id="csharp-string-concat-in-loop"></a>`csharp-string-concat-in-loop` | Repeated `+=` string concatenation inside a C# loop instead of `StringBuilder`. |
569
- | <a id="rust-clone-in-loop"></a>`rust-clone-in-loop` | Calling `.clone()` inside a Rust loop adds avoidable heap allocations. |
570
- | <a id="rust-format-in-loop"></a>`rust-format-in-loop` | Calling `format!` inside a Rust loop allocates a new `String` on every iteration. |
694
+ <!-- loadwise:rules:start checker=performance group=polyglot-source-checks -->
695
+
696
+ | Rule | Impact | What it flags |
697
+ | --------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
698
+ | <a id="csharp-fixed-regex-in-loop"></a>[`csharp-fixed-regex-in-loop`](docs/rules/csharp-fixed-regex-in-loop.md) | medium | A C# Regex with a fixed pattern is constructed inside a loop. |
699
+ | <a id="csharp-string-concat-in-loop"></a>[`csharp-string-concat-in-loop`](docs/rules/csharp-string-concat-in-loop.md) | medium | String concatenation in a C# loop allocates repeatedly; use StringBuilder. |
700
+ | <a id="go-fixed-regexp-in-loop"></a>[`go-fixed-regexp-in-loop`](docs/rules/go-fixed-regexp-in-loop.md) | medium | A Go regexp with a fixed pattern is compiled inside a loop. |
701
+ | <a id="go-sql-query-in-loop"></a>[`go-sql-query-in-loop`](docs/rules/go-sql-query-in-loop.md) | high | A Go database query executes inside a loop instead of batching. |
702
+ | <a id="go-string-concat-in-loop"></a>[`go-string-concat-in-loop`](docs/rules/go-string-concat-in-loop.md) | medium | String concatenation in a Go loop allocates repeatedly; use strings.Builder. |
703
+ | <a id="java-fixed-regex-in-loop"></a>[`java-fixed-regex-in-loop`](docs/rules/java-fixed-regex-in-loop.md) | medium | A Java Pattern with a fixed pattern is compiled inside a loop. |
704
+ | <a id="java-jdbc-query-in-loop"></a>[`java-jdbc-query-in-loop`](docs/rules/java-jdbc-query-in-loop.md) | high | A JDBC query executes inside a Java loop instead of batching. |
705
+ | <a id="java-string-concat-in-loop"></a>[`java-string-concat-in-loop`](docs/rules/java-string-concat-in-loop.md) | medium | String concatenation in a Java loop allocates repeatedly; use StringBuilder. |
706
+ | <a id="python-blocking-sleep-in-async"></a>[`python-blocking-sleep-in-async`](docs/rules/python-blocking-sleep-in-async.md) | high | A blocking time.sleep call runs inside a Python async def function. |
707
+ | <a id="python-copy-growing-list"></a>[`python-copy-growing-list`](docs/rules/python-copy-growing-list.md) | medium | A Python loop rebuilds a growing list with items = items + [value]. |
708
+ | <a id="python-fixed-regex-in-loop"></a>[`python-fixed-regex-in-loop`](docs/rules/python-fixed-regex-in-loop.md) | low | A Python loop compiles a fixed pattern with re.compile on every iteration. |
709
+ | <a id="python-n-plus-one-orm-loop"></a>[`python-n-plus-one-orm-loop`](docs/rules/python-n-plus-one-orm-loop.md) | high | An ORM query executes inside a Python loop instead of using eager loading or batching. |
710
+ | <a id="python-sync-requests-in-async"></a>[`python-sync-requests-in-async`](docs/rules/python-sync-requests-in-async.md) | high | A blocking requests HTTP call runs inside a Python async def function. |
711
+ | <a id="python-unbounded-comprehension"></a>[`python-unbounded-comprehension`](docs/rules/python-unbounded-comprehension.md) | medium | A Python list comprehension materializes an unbounded collection in memory. |
712
+ | <a id="rust-clone-in-loop"></a>[`rust-clone-in-loop`](docs/rules/rust-clone-in-loop.md) | low | Cloning values inside a Rust loop adds avoidable heap allocations. |
713
+ | <a id="rust-fixed-regex-in-loop"></a>[`rust-fixed-regex-in-loop`](docs/rules/rust-fixed-regex-in-loop.md) | medium | A Rust Regex with a fixed pattern is compiled inside a loop. |
714
+ | <a id="rust-format-in-loop"></a>[`rust-format-in-loop`](docs/rules/rust-format-in-loop.md) | low | Calling format! inside a Rust loop allocates a new String on every iteration. |
715
+
716
+ <!-- loadwise:rules:end -->
571
717
 
572
718
  ## Trace checks in other languages and databases
573
719
 
@@ -575,12 +721,16 @@ Supply a local **OTLP/JSON trace export** with `resourceSpans → scopeSpans →
575
721
 
576
722
  Try `npx loadwise perf traces node_modules/loadwise/examples/repeated-db.otlp.json`. The example reports five similar MongoDB operations under one parent. The trace rules use current and legacy database attributes and deduplicate span IDs.
577
723
 
578
- | Rule | Evidence and interpretation |
579
- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
580
- | <a id="repeated-db-span"></a>`repeated-db-span` | Five similar sibling DB calls by default, grouped by resource, trace, parent and recorded database target. SQL statements, query summaries, operation/collection pairs and recognized DynamoDB `GetItem` events can provide signatures. Namespace-only MongoDB or DynamoDB groups call for inspection of the actual predicates. |
581
- | <a id="redis-keys-scan"></a>`redis-keys-scan` | One Redis or Valkey `KEYS` command can scan the keyspace. For incremental iteration, account for duplicates and keys changing between `SCAN` calls. |
582
- | <a id="redis-repeated-read"></a>`redis-repeated-read` | Repeated sibling `GET` or `HGET` calls. Consider compatible multi-key reads or bounded pipelining with appropriate cluster slots, ordering and error handling. Recognized pipeline children are excluded. |
583
- | <a id="duplicate-key-read"></a>`duplicate-key-read` | Two or more reads with the same observable lookup, database target and recorded scalar context under one parent. The comparison accepts application-defined context keys. Supported evidence includes a concrete Redis `GET` key or a narrow SQL equality lookup with its bound parameter. Masked targets, ambiguous context, observed writes, transactions or failed calls suppress the suggestion where identity or freshness is uncertain. |
724
+ <!-- loadwise:rules:start checker=performance group=trace-checks-in-other-languages-and-databases -->
725
+
726
+ | Rule | Impact | What it flags |
727
+ | ------------------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------------- |
728
+ | <a id="duplicate-key-read"></a>[`duplicate-key-read`](docs/rules/duplicate-key-read.md) | medium | A trace repeats the same key or row read under one parent span. |
729
+ | <a id="redis-keys-scan"></a>[`redis-keys-scan`](docs/rules/redis-keys-scan.md) | high | A trace shows a Redis KEYS command scanning the keyspace. |
730
+ | <a id="redis-repeated-read"></a>[`redis-repeated-read`](docs/rules/redis-repeated-read.md) | medium | A trace shows repeated sibling Redis GET or HGET calls. |
731
+ | <a id="repeated-db-span"></a>[`repeated-db-span`](docs/rules/repeated-db-span.md) | high | A trace shows many similar sibling database calls under one parent. |
732
+
733
+ <!-- loadwise:rules:end -->
584
734
 
585
735
  Matching keys in two reads are a reason to consider **request-local** reuse when authorization, freshness and ordering allow it. Keep existing telemetry redaction. A redacted key can still support a batching finding. Reports contain span IDs and counts and omit raw SQL, parameters and keys. Check `scannedSpans` and `eligibleDbSpans` when interpreting a clean result. Sampling, missing parents, different literal values and coarse summaries affect grouping. [OpenTelemetry database spans](https://opentelemetry.io/docs/specs/semconv/db/database-spans/) · [OTLP JSON encoding](https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding)
586
736
 
@@ -588,11 +738,18 @@ Matching keys in two reads are a reason to consider **request-local** reuse when
588
738
 
589
739
  Feed the CLI a JSON file from PostgreSQL `EXPLAIN (ANALYZE, FORMAT JSON)` or MongoDB `explain("executionStats")`. For example, run `npx loadwise perf plan node_modules/loadwise/examples/postgres-plan.json`. The checker reads the file locally. PostgreSQL's `ANALYZE` option executes the statement when you collect the plan. [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html) · [MongoDB explain results](https://www.mongodb.com/docs/manual/reference/explain-results/)
590
740
 
591
- | Observed work | Threshold and review |
592
- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
593
- | <a id="pg-sequential-scan"></a><a id="mongo-collection-scan"></a>`pg-sequential-scan`, `mongo-collection-scan` | At least 1,000 examined and at least 100 examined per returned record, treating zero returns as one for this ratio. Review selectivity and available indexes. PostgreSQL totals use the reported per-loop averages. |
594
- | <a id="pg-disk-sort"></a><a id="mongo-disk-sort"></a>`pg-disk-sort`, `mongo-disk-sort` | At least 1,024 KiB of disk use by a PostgreSQL sort participant, including a reported incremental-sort group peak, or at least 1 MiB of spill or eight spills on a MongoDB sort. Check whether earlier filtering or an index can reduce sorting work. |
595
- | <a id="pg-deep-offset"></a><a id="mongo-deep-skip"></a>`pg-deep-offset`, `mongo-deep-skip` | At least ten times as many entries walked as returned and at least 10,000 skipped per execution. For sequential pages, keyset pagination needs a stable ordering with a unique tie-breaker. |
741
+ <!-- loadwise:rules:start checker=performance group=executed-query-plans -->
742
+
743
+ | Rule | Impact | What it flags |
744
+ | ------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------- |
745
+ | <a id="mongo-collection-scan"></a>[`mongo-collection-scan`](docs/rules/mongo-collection-scan.md) | high | A MongoDB plan scans many documents for each one it returns. |
746
+ | <a id="mongo-deep-skip"></a>[`mongo-deep-skip`](docs/rules/mongo-deep-skip.md) | high | A MongoDB query skips past many documents to return a page. |
747
+ | <a id="mongo-disk-sort"></a>[`mongo-disk-sort`](docs/rules/mongo-disk-sort.md) | medium | A MongoDB sort spilled to disk. |
748
+ | <a id="pg-deep-offset"></a>[`pg-deep-offset`](docs/rules/pg-deep-offset.md) | high | A PostgreSQL plan walks past many rows with OFFSET to return a page. |
749
+ | <a id="pg-disk-sort"></a>[`pg-disk-sort`](docs/rules/pg-disk-sort.md) | medium | A PostgreSQL sort spilled to disk. |
750
+ | <a id="pg-sequential-scan"></a>[`pg-sequential-scan`](docs/rules/pg-sequential-scan.md) | high | A PostgreSQL plan scans many rows for each one it returns. |
751
+
752
+ <!-- loadwise:rules:end -->
596
753
 
597
754
  Results include the stage path and observed counts. PostgreSQL and MongoDB planner estimates alone return exit 2. MongoDB coverage includes classic executed query stages and selected slot-based scan/filter and skip shapes. Unsupported layouts return an input error where a scan cannot be attributed.
598
755
 
@@ -617,7 +774,21 @@ npx loadwise perf --schema snapshot.json
617
774
  | `--measure --i-understand-this-locks-tables` | PostgreSQL staging only. Time each suggested index for `--queries` by building it in a rolled-back transaction. |
618
775
  | `--runs N` | `EXPLAIN ANALYZE` runs per side for `--measure` (default 5). |
619
776
 
620
- <a id="db-unindexed-foreign-key"></a><a id="db-seq-scan-heavy-table"></a><a id="db-slow-query-plan"></a><a id="db-missing-index"></a><a id="mongo-collection-scan-observed"></a><a id="db-unused-index"></a><a id="db-duplicate-index"></a>Rules: `db-unindexed-foreign-key`, `db-unused-index`, `db-duplicate-index`, `db-seq-scan-heavy-table`, `db-slow-query-plan`, `db-missing-index` and, for MongoDB, `mongo-collection-scan-observed`. `--include-contextual`, `--ignore RULE` and `--json` work as in the other commands.
777
+ Rules: `db-unindexed-foreign-key`, `db-unused-index`, `db-duplicate-index`, `db-seq-scan-heavy-table`, `db-slow-query-plan`, `db-missing-index` and, for MongoDB, `mongo-collection-scan-observed`. `--include-contextual`, `--ignore RULE` and `--json` work as in the other commands.
778
+
779
+ <!-- loadwise:rules:start checker=performance group=database-inspection-optional -->
780
+
781
+ | Rule | Impact | What it flags |
782
+ | --------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
783
+ | <a id="db-duplicate-index"></a>[`db-duplicate-index`](docs/rules/db-duplicate-index.md) | low | A database index is covered by another index on the same table. |
784
+ | <a id="db-missing-index"></a>[`db-missing-index`](docs/rules/db-missing-index.md) | high | A query plan scans a table that a suggested index would let it seek. |
785
+ | <a id="db-seq-scan-heavy-table"></a>[`db-seq-scan-heavy-table`](docs/rules/db-seq-scan-heavy-table.md) | high | A large table is read by many sequential scans on the live database. |
786
+ | <a id="db-slow-query-plan"></a>[`db-slow-query-plan`](docs/rules/db-slow-query-plan.md) | high | One of the slowest statements reads a table with a full table scan. |
787
+ | <a id="db-unindexed-foreign-key"></a>[`db-unindexed-foreign-key`](docs/rules/db-unindexed-foreign-key.md) | high | A foreign key on the live database has no index that leads with its columns. |
788
+ | <a id="db-unused-index"></a>[`db-unused-index`](docs/rules/db-unused-index.md) | low | A database index has not been scanned since statistics were last reset. |
789
+ | <a id="mongo-collection-scan-observed"></a>[`mongo-collection-scan-observed`](docs/rules/mongo-collection-scan-observed.md) | high | Profiled MongoDB operations scanned a whole collection. |
790
+
791
+ <!-- loadwise:rules:end -->
621
792
 
622
793
  **Safety guarantees.** Statements go through a read-only gateway: sessions and transactions are read-only, with a 5 s statement timeout on PostgreSQL, and only SELECT, INSERT, UPDATE and DELETE can be explained. `EXPLAIN ANALYZE` runs only for a plain SELECT (a `WITH` that modifies data is refused). MongoDB uses a command allowlist. Error text is redacted: the connection URL, host, user, password and resolved IP addresses are replaced with `[redacted]`. Usage counters come from the node that answered, so an index unused here may still be used on a replica.
623
794
 
@@ -640,130 +811,6 @@ Every finding carries an impact level. `--min-impact <low|medium|high|critical>`
640
811
  - `medium`: a measurable but local cost, or significant maintainability debt.
641
812
  - `low`: a micro-optimization or a readability issue.
642
813
 
643
- | Rule | Impact |
644
- | ----------------------------------- | -------- |
645
- | `pg-unreleased-checkout` | critical |
646
- | `pool-created-per-request-or-item` | critical |
647
- | `db-missing-index` | high |
648
- | `db-seq-scan-heavy-table` | high |
649
- | `db-slow-query-plan` | high |
650
- | `db-unindexed-foreign-key` | high |
651
- | `drizzle-query-in-loop` | high |
652
- | `external-call-in-transaction` | high |
653
- | `unbounded-list-query` | high |
654
- | `unbounded-module-cache` | medium |
655
- | `whole-payload-in-memory` | medium |
656
- | `list-query-overfetch` | medium |
657
- | `orm-deep-offset` | high |
658
- | `list-count-per-request` | medium |
659
- | `notification-send-in-loop` | high |
660
- | `session-memory-store` | high |
661
- | `orm-cartesian-include` | high |
662
- | `json-roundtrip-clone` | low |
663
- | `mongoose-hydrate-for-to-object` | medium |
664
- | `express-missing-compression` | low |
665
- | `heavy-media-in-request-handler` | medium |
666
- | `react-index-as-key` | low |
667
- | `react-fetch-in-effect-no-abort` | low |
668
- | `react-inline-object-in-jsx-prop` | low |
669
- | `angular-default-change-detection` | low |
670
- | `vue-v-for-missing-key` | low |
671
- | `dom-listener-without-cleanup` | low |
672
- | `dom-unthrottled-scroll-resize` | low |
673
- | `frontend-barrel-heavy-import` | low |
674
- | `sql-select-star-in-query` | low |
675
- | `react-missing-cleanup` | medium |
676
- | `angular-subscribe-without-cleanup` | medium |
677
- | `vue-watch-missing-cleanup` | medium |
678
- | `dom-layout-thrashing` | medium |
679
- | `mongoose-missing-lean` | medium |
680
- | `graphql-n-plus-one-resolver` | high |
681
- | `react-context-value-recreated` | low |
682
- | `node-event-listener-leak` | high |
683
- | `json-stringify-in-loop` | medium |
684
- | `sequential-http-in-loop` | high |
685
- | `index-redundant-prefix` | low |
686
- | `drizzle-last-insert-id` | medium |
687
- | `repeated-workbook-decode` | medium |
688
- | `index-missing-filter` | high |
689
- | `index-missing-foreign-key` | high |
690
- | `index-unusable-expression` | high |
691
- | `index-unusable-pattern` | high |
692
- | `mongo-collection-scan` | high |
693
- | `mongo-collection-scan-observed` | high |
694
- | `mongo-deep-skip` | high |
695
- | `node-sync-crypto-in-async` | high |
696
- | `node-sync-process-in-async` | high |
697
- | `orm-query-in-loop` | high |
698
- | `password-hash-sync-in-async` | high |
699
- | `pg-deep-offset` | high |
700
- | `pg-query-in-loop` | high |
701
- | `pg-sequential-scan` | high |
702
- | `prisma-query-in-loop` | high |
703
- | `queue-add-in-loop` | high |
704
- | `rebuild-lookup-in-loop` | high |
705
- | `redis-command-in-loop` | high |
706
- | `redis-keys-command` | high |
707
- | `redis-keys-scan` | high |
708
- | `repeated-db-span` | high |
709
- | `service-query-in-loop` | high |
710
- | `typeorm-load-then-save` | high |
711
- | `typeorm-transaction-in-loop` | high |
712
- | `array-repeated-find` | medium |
713
- | `array-repeated-membership` | medium |
714
- | `await-before-early-exit` | medium |
715
- | `csharp-fixed-regex-in-loop` | medium |
716
- | `duplicate-key-read` | medium |
717
- | `go-fixed-regexp-in-loop` | medium |
718
- | `guard-query-per-request` | medium |
719
- | `index-missing-order` | medium |
720
- | `java-fixed-regex-in-loop` | medium |
721
- | `known-reads-awaited-serially` | medium |
722
- | `loop-copy-accumulator` | medium |
723
- | `mongo-disk-sort` | medium |
724
- | `node-sync-compression-in-async` | medium |
725
- | `node-sync-fs-in-async` | medium |
726
- | `orm-count-materialization` | medium |
727
- | `password-hash-pure-js` | medium |
728
- | `pg-count-materialization` | medium |
729
- | `pg-disk-sort` | medium |
730
- | `pg-filter-materialization` | medium |
731
- | `pg-first-materialization` | medium |
732
- | `pg-top-k-materialization` | medium |
733
- | `prisma-count-materialization` | medium |
734
- | `prisma-distinct-in-memory` | medium |
735
- | `prisma-filter-materialization` | medium |
736
- | `prisma-first-materialization` | medium |
737
- | `prisma-relation-count-in-list` | medium |
738
- | `prisma-top-k-materialization` | medium |
739
- | `promise-combinator-serial-await` | medium |
740
- | `python-copy-growing-list` | medium |
741
- | `python-sync-requests-in-async` | high |
742
- | `python-blocking-sleep-in-async` | high |
743
- | `python-fixed-regex-in-loop` | low |
744
- | `python-n-plus-one-orm-loop` | high |
745
- | `python-unbounded-comprehension` | medium |
746
- | `go-sql-query-in-loop` | high |
747
- | `go-string-concat-in-loop` | medium |
748
- | `java-string-concat-in-loop` | medium |
749
- | `java-jdbc-query-in-loop` | high |
750
- | `csharp-string-concat-in-loop` | medium |
751
- | `rust-clone-in-loop` | low |
752
- | `rust-format-in-loop` | low |
753
- | `redis-repeated-read` | medium |
754
- | `reduce-copy-accumulator` | medium |
755
- | `rust-fixed-regex-in-loop` | medium |
756
- | `serial-awaits-in-literal` | medium |
757
- | `typeorm-existence-materialization` | medium |
758
- | `count-then-page-serial` | low |
759
- | `typeorm-unused-count` | medium |
760
- | `prisma-count-for-existence` | medium |
761
- | `db-duplicate-index` | low |
762
- | `db-unused-index` | low |
763
- | `filter-for-existence` | low |
764
- | `numeric-sort-for-extreme` | low |
765
- | `typeorm-wide-projection` | low |
766
-
767
814
  ## Verification and benchmarks
768
815
 
769
816
  Integration checks used PostgreSQL 18.0 and MongoDB 8.2.3. Each engine examined 20,000 records for one match before an index was added. The corresponding indexed read passed. In both databases a deep page walked 15,010 entries to return ten, and the equivalent keyset query passed. Both engines also produced a disk-sort finding. MongoDB's live test used classic execution stages.
@@ -774,9 +821,9 @@ Use Node.js 22.13+ for the full development workflow, including the in-memory SQ
774
821
 
775
822
  ### Source conventions
776
823
 
777
- The CLI and checkers are TypeScript (`.ts`) compiled in place to ES modules (`.js`, not committed) by `npm run build`, while shared VS Code modules under `editor/` are `.cts` compiled to CommonJS (`.cjs`); `npm test` builds first and `npm run typecheck` checks without emitting. Import with the runtime extension (`.js` or `.cjs`). The compiler runs in `strict` mode.
824
+ The CLI and checkers are TypeScript (`.ts`) compiled in place to ES modules (`.js`, not committed) by `npm run build`, while the security example tables under `lib/security/examples/` are `.cts` compiled to CommonJS (`.cjs`); `npm test` builds first and `npm run typecheck` checks without emitting. Import with the runtime extension (`.js` or `.cjs`). The compiler runs in `strict` mode.
778
825
 
779
- - Write ES `import`/`export`, with imports at the top of the file. `require()` is limited to the files listed under `overrides` in `.oxlintrc.json`, where load order or startup cost forbids a top-level import (the compiler must be chosen before the rules load, and `maint --staged` must not load TypeScript). Lazy loads in an async function use `await import()`. Do not add files to that list.
826
+ - Write ES `import`/`export`, with imports at the top of the file. Oxlint rejects `require()`. Where load order or startup cost forbids a top-level import (the compiler must be chosen before the rules load, and `maint --staged` must not load TypeScript), load lazily in an async function with `await import()`.
780
827
  - No `any` and no `as` assertions (`as const` is fine) in new code. Narrow with type guards, give a function a precise type, or use overloads. A deliberate exception needs a lint-disable comment that says why.
781
828
  - Types shared by two or more files live in the `types/` folder of their area (`lib/performance/types/`, `lib/security/types/`, `lib/maintainability/types/`, `lib/shared/types/`, `test/types/`), one topic per file. Cross-pillar types are in `lib/shared/types.ts`. A type used by one file stays in that file.
782
829
  - Comments wrap at 100 columns, and Prettier formats everything. `.vscode/settings.json` formats on save, and the pre-commit hook in `hooks/` formats and lints staged files (`npm install` enables it).
@@ -821,70 +868,97 @@ Sentry also has an N+1 detector that considers sequential spans and their total
821
868
 
822
869
  The rules from `pg-transaction-on-pool` to `swallowed-error` moved from the performance and maintainability checkers with the same ids, so existing `// loadwise-reviewed` comments, `--ignore` flags and config `rules` entries keep working. Migration and API contract rules are described in [Migration safety](#migration-safety) and [API contract safety](#api-contract-safety). `csharp-async-void` and the `python-`, `go-`, `java-`, `csharp-` and `rust-` rules come from `loadwise rel polyglot`, which needs the optional ast-grep executable.
823
870
 
824
- | Rule | What to review |
825
- | ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
826
- | <a id="pg-transaction-on-pool"></a>`pg-transaction-on-pool` | A standalone transaction-control statement is sent to a typed pool. Use the same checked-out client for the whole transaction and release it in `finally`. |
827
- | <a id="prisma-transaction-client-escape"></a>`prisma-transaction-client-escape` | A direct model operation uses the same outer client that opened an interactive transaction. Verify that the operation belongs inside that transaction. |
828
- | <a id="typeorm-transaction-client-escape"></a>`typeorm-transaction-client-escape` | An awaited write inside a TypeORM transaction goes through a repository or manager that is not bound to it, so it autocommits on another pooled connection, is not rolled back with the transaction and can block on its locks. Use the transaction's manager (`manager.getRepository(Entity)`). |
829
- | <a id="prisma-read-modify-write"></a>`prisma-read-modify-write` | A direct read of one row feeds a numeric update of the same field and key. Review atomic arithmetic, an optimistic version check or serializable execution with retries. |
830
- | <a id="drizzle-unfiltered-write"></a>`drizzle-unfiltered-write` | An executed update/delete has no effective predicate in a recognized direct chain. An intentional whole-table maintenance operation can legitimately match. |
831
- | <a id="prisma-dependent-writes"></a>`prisma-dependent-writes` | Adjacent creates pass a value from the first record into the next write. Explicit single-key nested `connect` can use a custom unique field when generated types confirm a relation. Direct scalar assignments currently recognize `parent.id` going into a field ending in `Id` or `_id`. Other scalar foreign-key conventions can be missed. If both writes must succeed together, consider a nested write or an appropriate transaction. |
832
- | <a id="find-then-create-race"></a>`find-then-create-race` | A Prisma or TypeORM lookup by one key is followed in the same function by an insert with the same key, and the schema shows no unique constraint on it. Add the constraint and catch the violation (Prisma P2002, Postgres 23505) or use `upsert` / `ON CONFLICT`. Without a readable schema the finding is contextual; serializable transactions, locks and handled duplicates are skipped. |
833
- | <a id="floating-promise"></a>`floating-promise` | A promise-returning call is a bare statement in an async function or request handler, or `array.forEach(async ...)` runs awaits nobody waits for. Returning, awaiting, using `void`, or attaching a rejection callback suppresses the bare-call warning. Omitted or nullish callbacks do not handle rejections. Test files and helpers listed under `fireAndForget` in the policy are skipped. |
834
- | <a id="discarded-error-result"></a>`discarded-error-result` | A call discards a typed `fp-ts` `Either` or `neverthrow` `Result`. This includes async calls, standalone `await` and explicit `void`. Check the failure branch or return the result to a caller that handles it. |
835
- | <a id="promise-return-escapes-catch"></a>`promise-return-escapes-catch` | An async function returns a typed promise directly from the `try` block of a `try`/`catch`. A rejection can bypass that catch. Use `return await` when the catch owns the failure. |
836
- | <a id="return-in-finally"></a>`return-in-finally` | A return in `finally` can replace an earlier return value or suppress a thrown error. Keep cleanup in `finally` and return from `try`, `catch`, or after the statement. |
837
- | <a id="return-newline"></a>`return-newline` | A line break immediately after `return` ends the statement before an apparent object or parenthesized return value. Start the expression on the same line as `return`. |
838
- | <a id="drizzle-write-preflight"></a>`drizzle-write-preflight` | An existence check immediately precedes a write on the same key. Review the database constraint or affected-row count alongside the intended error response when requests race. |
839
- | <a id="http-call-without-timeout"></a>`http-call-without-timeout` | A `fetch` or axios call has no `signal` or `timeout`, so a hung upstream holds the request. Set a timeout or an abort signal. |
840
- | <a id="upload-without-size-limit"></a>`upload-without-size-limit` | A multer or Nest upload interceptor has no `limits.fileSize`, so one large upload can exhaust memory. A global `MulterModule.register({ limits })` set elsewhere is not visible to the check. |
841
- | <a id="mongoose-aggregate-uncast-id"></a>`mongoose-aggregate-uncast-id` | A Mongoose `aggregate()` `$match` compares `_id` to a plain string. Aggregation does not cast, so the stage matches nothing; wrap the value in `new Types.ObjectId(id)`. Skipped when a schema declares a String `_id`. |
842
- | <a id="check-then-update-race"></a>`check-then-update-race` | A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates. |
843
- | <a id="payment-missing-idempotency-key"></a>`payment-missing-idempotency-key` | A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice. |
844
- | <a id="webhook-missing-idempotency-check"></a>`webhook-missing-idempotency-check` | A webhook route inserts rows without first checking whether the event was already processed. |
845
- | <a id="redis-incr-then-expire"></a>`redis-incr-then-expire` | An `incr`, `incrby` or `hincrby` followed by `expire` or `pexpire` on the same key and client takes two round trips and is not atomic: a crash between them leaves the counter without a TTL. Send both in one `multi()` (with `NX` on Redis 7+) or a Lua script. |
846
- | <a id="retry-without-backoff"></a>`retry-without-backoff` | A network call is retried in a loop, or axios-retry is set up, with no wait between attempts. Add exponential backoff with jitter. axios-retry without `retryDelay` is contextual. |
847
- | <a id="async-route-unhandled-rejection"></a>`async-route-unhandled-rejection` | An async Express 4 route handler awaits outside a try/catch and takes no `next`, so a rejection skips the error middleware and the request hangs. Silent on Express 5 and with express-async-errors, express-async-handler or a wrapping call; an unknown Express version is contextual. Fix (review): wrap the body in try/catch and pass the error to `next`. |
848
- | <a id="async-callback-unhandled-rejection"></a>`async-callback-unhandled-rejection` | An async callback given to `.on`/`.once`, a timer, `process.nextTick` or `cron.schedule` awaits outside a try/catch; nothing handles its promise, so a rejection crashes Node 15+. Fix (review): wrap the body in try/catch that logs the error. |
849
- | <a id="stream-pipe-unhandled-error"></a>`stream-pipe-unhandled-error` | `.pipe()` on a Node stream with no `error` listener and no `pipeline`/`finished` in the function, so a stream error crashes the process or leaks the file and socket. RxJS pipes are skipped; a stream known only by its name is contextual. Fix (review): `await pipeline(...)` from `node:stream/promises`. |
850
- | <a id="json-parse-unguarded"></a>`json-parse-unguarded` | `JSON.parse` of request, queue-message, file, fetch, storage or environment input outside a try/catch. Framework handlers that turn a throw into a 500, and startup parses, are contextual. |
851
- | <a id="request-number-unvalidated"></a>`request-number-unvalidated` | `Number`, `parseInt`, `parseFloat` or unary `+` of raw request input reaches a query, `slice`/`limit`/`skip`/`take`, an index or kept arithmetic with no NaN or range check. Schema-validated values, Nest DTOs and pipes are skipped. Fix (review): a 400 guard after the declaration. |
852
- | <a id="unbounded-promise-all"></a>`unbounded-promise-all` | `Promise.all` runs over an unbounded collection without a concurrency limit (`p-limit`, `pMap`, `PromisePool`, or chunking). |
853
- | <a id="csharp-async-void"></a>`csharp-async-void` | An `async void` method cannot be awaited and can crash the process on unhandled exceptions. Event handlers (`object sender, …EventArgs e`) and `override` methods, which cannot change their return type, are accepted. |
854
- | <a id="sql-insert-truncated-at-semicolon"></a>`sql-insert-truncated-at-semicolon` | An INSERT dump parser ends its captured values at the next semicolon, which can occur inside quoted data. Use a parser for the dump dialect and test a quoted semicolon. |
855
- | <a id="swallowed-error"></a>`swallowed-error` | A JS/TS `catch` block in non-test code is empty, or only calls `console.*`, `logger.*` or `this.logger.*` while the code after the `try` carries on as if it had succeeded. A comment inside the block, an optional `require()` or `import()` probe, a cleanup in a `finally` or `catch` block, and a `try` made only of `close`, `destroy`, `release`-style calls are accepted. A catch that rethrows, returns or records a failure is not reported. |
856
- | <a id="unguarded-boundary-access"></a>`unguarded-boundary-access` | A nested read such as `req.body.user.email`, `JSON.parse(text).a.b` or `response.data.x.y` on untyped input, or on a `find()` / `Map#get` result in files without `strictNullChecks`, throws a TypeError when the value is missing. Reads under optional chaining, a guard (including `map.has(key)` before `map.get(key)`), an early return, an `assert`/`invariant` call or a `try` are accepted; typed values are left to the compiler. The fix adds optional chaining and is marked for review: add a default or answer with a 400, or validate the input first. |
857
- | <a id="assignment-in-condition"></a>`assignment-in-condition` | A condition uses `=` where `===` was probably meant, so it overwrites the variable and tests the assigned value. Doubled parentheses `if ((match = re.exec(text)))`, ternary conditions, calls and loops that read and assign are accepted. |
858
- | <a id="nan-comparison"></a>`nan-comparison` | A value is compared to `NaN` with `==` or `===`, which is never true. Reported only in JavaScript the compiler does not check, since TypeScript reports it otherwise. The fix uses `Number.isNaN` and is marked for review, since the branch starts to run. |
859
- | <a id="invalid-typeof-comparison"></a>`invalid-typeof-comparison` | A `typeof` result is compared to a name it never returns, such as `'strnig'`, so the branch never runs. Reported only in JavaScript the compiler does not check; the fix corrects a close misspelling and is marked for review, since the branch starts to run. |
860
- | <a id="unreachable-code"></a>`unreachable-code` | Statements after `return`, `throw`, `break` or `continue` in the same block never run. Hoisted function declarations and type declarations are accepted, and the rule stays silent when `allowUnreachableCode` is `false` because the compiler reports it. |
861
- | <a id="loop-index-past-length"></a>`loop-index-past-length` | A `for` loop starts at `0`, runs `i <= items.length` and reads `items[i]`, so the last pass reads past the end. Loops starting at `1` are accepted. The fix changes `<=` to `<` and is marked for review. |
862
- | <a id="file-handle-not-closed"></a>`file-handle-not-closed` | A `FileHandle` from `fs/promises` `open()` is not closed in `finally`, so an error before `close()` leaks the file descriptor. Handles that are returned, stored, passed on or turned into a stream are accepted. Confirm nothing else closes it, then close it in `finally` or use `await using`. |
863
- | <a id="query-runner-not-released"></a>`query-runner-not-released` | A TypeORM `createQueryRunner()` is not released in `finally`, so an early return or failed transaction keeps the pooled connection. Confirm no caller releases it, then call `release()` in `finally`. |
864
- | <a id="browser-not-closed"></a>`browser-not-closed` | A Playwright or Puppeteer browser is launched without a `close()` (or `disconnect()` for `puppeteer.connect`) in `finally`, so a failed run leaves the browser process running. Playwright test files, whose fixtures close the browser, are skipped. |
865
- | <a id="interval-not-cleared"></a>`interval-not-cleared` | A `setInterval` in a function outside any frontend lifecycle keeps no handle, or its handle never reaches `clearInterval`, so the timer outlives its owner. Startup code, `unref()` timers and React, Vue, Svelte and Angular files (covered by the frontend cleanup rules) are skipped. Decide who owns the timer and clear it when that owner stops. |
866
- | <a id="python-bare-except"></a>`python-bare-except` | `except:` with no exception type also catches `SystemExit` and `KeyboardInterrupt`. Name the exceptions the block handles. A block that ends in a bare `raise` is accepted. Reported by `loadwise rel polyglot`. |
867
- | <a id="python-swallowed-exception"></a>`python-swallowed-exception` | `except Exception` or `except BaseException` (alone or in a tuple) whose body is only `pass` or `...` makes every failure disappear. Narrow types such as `FileNotFoundError` or `KeyError` with `pass` are accepted as deliberate. |
868
- | <a id="go-error-discarded"></a>`go-error-discarded` | An error result is dropped with `_`: `value, _ := f()` for calls known to return `(T, error)` (the `os`, `io`, `strconv`, `json`, `sql` and `net` packages, `http.Get`, `url.Parse`, `time.Parse`, and methods such as `Marshal`, `ReadAll`, `Atoi`, `Query`, `Decode`), or `_ = w.Write(...)` and similar write, flush, sync, encode, exec and commit calls. Calls whose second result is a bool, such as `os.LookupEnv`, `cache.Get` or `q.Pop()`, and explicit `_ = x.Close()` or `_ = tx.Rollback()` are accepted. |
869
- | <a id="go-defer-before-error-check"></a>`go-defer-before-error-check` | `defer resp.Body.Close()`, or `defer rows.Close()` after `Query`/`QueryContext`, runs before `err` is checked, so a failed call defers `Close` on a nil value and panics. `os.Open` files are accepted, since `Close` on a nil `*os.File` returns an error instead. |
870
- | <a id="java-resource-without-try"></a>`java-resource-without-try` | A stream, reader, writer or JDBC connection is opened outside try-with-resources and not closed by a later `try`/`finally`, returned or stored, so an exception leaks it. |
871
- | <a id="csharp-disposable-without-using"></a>`csharp-disposable-without-using` | A stream or database connection is created without `using`, so an exception skips `Dispose()`. Variables that are returned, stored, handed to another object or disposed in a later `finally` are accepted. |
872
- | <a id="rust-unwrap-in-production"></a>`rust-unwrap-in-production` | `.unwrap()` in non-test code panics on `None` or `Err`. Test modules, `static`/`const` items and lock guards are accepted. Handle the case or use `expect` with the invariant that makes it safe. |
871
+ <!-- loadwise:rules:start checker=reliability group=source-rules -->
872
+
873
+ | Rule | Impact | What it flags |
874
+ | --------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
875
+ | <a id="assignment-in-condition"></a>[`assignment-in-condition`](docs/rules/assignment-in-condition.md) | high | A condition assigns with = where a comparison was probably meant. |
876
+ | <a id="async-callback-unhandled-rejection"></a>[`async-callback-unhandled-rejection`](docs/rules/async-callback-unhandled-rejection.md) | high | An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled. |
877
+ | <a id="async-route-unhandled-rejection"></a>[`async-route-unhandled-rejection`](docs/rules/async-route-unhandled-rejection.md) | high | An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware. |
878
+ | <a id="browser-not-closed"></a>[`browser-not-closed`](docs/rules/browser-not-closed.md) | high | A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running. |
879
+ | <a id="check-then-update-race"></a>[`check-then-update-race`](docs/rules/check-then-update-race.md) | high | A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates. |
880
+ | <a id="child-process-without-error-listener"></a>[`child-process-without-error-listener`](docs/rules/child-process-without-error-listener.md) | high | A spawned child process has no 'error' listener, so a failed spawn crashes the parent process. |
881
+ | <a id="csharp-async-void"></a>[`csharp-async-void`](docs/rules/csharp-async-void.md) | high | An async void method cannot be awaited and can crash the process on unhandled exceptions. |
882
+ | <a id="csharp-disposable-without-using"></a>[`csharp-disposable-without-using`](docs/rules/csharp-disposable-without-using.md) | medium | A C# stream, connection or other IDisposable is created without using, so an exception leaks it. |
883
+ | <a id="discarded-error-result"></a>[`discarded-error-result`](docs/rules/discarded-error-result.md) | high | A call discards a typed Either or Result that can carry a failure as a value. |
884
+ | <a id="drizzle-unfiltered-write"></a>[`drizzle-unfiltered-write`](docs/rules/drizzle-unfiltered-write.md) | critical | A Drizzle update or delete executes without an effective where clause. |
885
+ | <a id="drizzle-write-preflight"></a>[`drizzle-write-preflight`](docs/rules/drizzle-write-preflight.md) | medium | A separate existence check before a Drizzle write can race with another request. |
886
+ | <a id="error-logged-without-stack"></a>[`error-logged-without-stack`](docs/rules/error-logged-without-stack.md) | low | A catch block logs only error.message and carries on, so the stack trace is lost. |
887
+ | <a id="error-rethrown-without-cause"></a>[`error-rethrown-without-cause`](docs/rules/error-rethrown-without-cause.md) | low | A catch block throws a new error without the caught one, so the original message and stack are lost. |
888
+ | <a id="file-handle-not-closed"></a>[`file-handle-not-closed`](docs/rules/file-handle-not-closed.md) | high | A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor. |
889
+ | <a id="find-then-create-race"></a>[`find-then-create-race`](docs/rules/find-then-create-race.md) | high | A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates. |
890
+ | <a id="floating-promise"></a>[`floating-promise`](docs/rules/floating-promise.md) | high | A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen. |
891
+ | <a id="go-defer-before-error-check"></a>[`go-defer-before-error-check`](docs/rules/go-defer-before-error-check.md) | high | A Go defer closes a resource before its error is checked, so a failed open dereferences nil. |
892
+ | <a id="go-error-discarded"></a>[`go-error-discarded`](docs/rules/go-error-discarded.md) | high | A Go error result is assigned to the blank identifier and never checked. |
893
+ | <a id="http-call-without-timeout"></a>[`http-call-without-timeout`](docs/rules/http-call-without-timeout.md) | high | A fetch or axios call has no timeout or abort signal. |
894
+ | <a id="interval-not-cleared"></a>[`interval-not-cleared`](docs/rules/interval-not-cleared.md) | medium | A setInterval handle is discarded or never cleared, so the timer outlives its owner. |
895
+ | <a id="invalid-typeof-comparison"></a>[`invalid-typeof-comparison`](docs/rules/invalid-typeof-comparison.md) | high | A typeof result is compared to a string typeof never returns, so the check never matches. |
896
+ | <a id="java-resource-without-try"></a>[`java-resource-without-try`](docs/rules/java-resource-without-try.md) | high | A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it. |
897
+ | <a id="json-parse-unguarded"></a>[`json-parse-unguarded`](docs/rules/json-parse-unguarded.md) | medium | JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled. |
898
+ | <a id="loop-index-past-length"></a>[`loop-index-past-length`](docs/rules/loop-index-past-length.md) | high | A loop runs its index up to and including length, so the last pass reads past the end. |
899
+ | <a id="mongoose-aggregate-uncast-id"></a>[`mongoose-aggregate-uncast-id`](docs/rules/mongoose-aggregate-uncast-id.md) | high | A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId. |
900
+ | <a id="nan-comparison"></a>[`nan-comparison`](docs/rules/nan-comparison.md) | high | A value is compared to NaN with an equality operator, which is never true. |
901
+ | <a id="next-server-env-in-client"></a>[`next-server-env-in-client`](docs/rules/next-server-env-in-client.md) | high | A 'use client' file reads a process.env variable without the NEXT_PUBLIC_ prefix, so it is unavailable in the browser by default. |
902
+ | <a id="payment-missing-idempotency-key"></a>[`payment-missing-idempotency-key`](docs/rules/payment-missing-idempotency-key.md) | high | A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice. |
903
+ | <a id="pg-transaction-on-pool"></a>[`pg-transaction-on-pool`](docs/rules/pg-transaction-on-pool.md) | critical | A transaction statement is sent to a pool, so its statements can run on different connections. |
904
+ | <a id="pool-without-connection-timeout"></a>[`pool-without-connection-timeout`](docs/rules/pool-without-connection-timeout.md) | medium | A pg Pool or Client sets no connectionTimeoutMillis, so its default of 0 waits for a connection forever. |
905
+ | <a id="prisma-dependent-writes"></a>[`prisma-dependent-writes`](docs/rules/prisma-dependent-writes.md) | high | Adjacent Prisma creates pass a value from the first record into the next write. |
906
+ | <a id="prisma-read-modify-write"></a>[`prisma-read-modify-write`](docs/rules/prisma-read-modify-write.md) | critical | A Prisma read feeds a numeric update of the same row, losing concurrent updates. |
907
+ | <a id="prisma-transaction-client-escape"></a>[`prisma-transaction-client-escape`](docs/rules/prisma-transaction-client-escape.md) | critical | A Prisma call inside an interactive transaction uses the outer client instead of the transaction client. |
908
+ | <a id="promise-return-escapes-catch"></a>[`promise-return-escapes-catch`](docs/rules/promise-return-escapes-catch.md) | high | Returning a promise directly from a protected try block can bypass its catch on rejection. |
909
+ | <a id="python-bare-except"></a>[`python-bare-except`](docs/rules/python-bare-except.md) | medium | A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs. |
910
+ | <a id="python-swallowed-exception"></a>[`python-swallowed-exception`](docs/rules/python-swallowed-exception.md) | medium | A Python except block only passes, so the failure is dropped silently. |
911
+ | <a id="query-runner-not-released"></a>[`query-runner-not-released`](docs/rules/query-runner-not-released.md) | critical | A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection. |
912
+ | <a id="react-async-effect-callback"></a>[`react-async-effect-callback`](docs/rules/react-async-effect-callback.md) | medium | An async function is passed to useEffect, so its promise is treated as the cleanup function and its errors go unhandled. |
913
+ | <a id="react-effect-sets-state-every-render"></a>[`react-effect-sets-state-every-render`](docs/rules/react-effect-sets-state-every-render.md) | high | An effect with no dependency array sets state to a new value on every run, so the component re-renders forever. |
914
+ | <a id="react-list-missing-key"></a>[`react-list-missing-key`](docs/rules/react-list-missing-key.md) | medium | An element or fragment returned from .map() has no key prop, so React cannot track items when the list changes. |
915
+ | <a id="react-state-mutated-in-place"></a>[`react-state-mutated-in-place`](docs/rules/react-state-mutated-in-place.md) | high | A useState value is mutated in place and passed to its own setter, so React sees the same reference and skips the re-render. |
916
+ | <a id="redis-incr-then-expire"></a>[`redis-incr-then-expire`](docs/rules/redis-incr-then-expire.md) | medium | A Redis counter increment and its expire on the same key are two round trips and not atomic. |
917
+ | <a id="request-number-unvalidated"></a>[`request-number-unvalidated`](docs/rules/request-number-unvalidated.md) | medium | A number parsed from request input reaches a query or calculation with no NaN or range check. |
918
+ | <a id="retry-without-backoff"></a>[`retry-without-backoff`](docs/rules/retry-without-backoff.md) | medium | A retry loop calls the network again with no delay between attempts. |
919
+ | <a id="return-in-finally"></a>[`return-in-finally`](docs/rules/return-in-finally.md) | high | Returning from finally can replace a pending return value or suppress a thrown error. |
920
+ | <a id="return-newline"></a>[`return-newline`](docs/rules/return-newline.md) | high | A line break after return ends the statement before the apparent return value. |
921
+ | <a id="rust-unwrap-in-production"></a>[`rust-unwrap-in-production`](docs/rules/rust-unwrap-in-production.md) | medium | Rust code outside tests calls unwrap(), turning an Err or None into a panic. |
922
+ | <a id="sql-insert-truncated-at-semicolon"></a>[`sql-insert-truncated-at-semicolon`](docs/rules/sql-insert-truncated-at-semicolon.md) | high | A SQL dump parser ends INSERT values at a semicolon inside quoted text. |
923
+ | <a id="stream-pipe-unhandled-error"></a>[`stream-pipe-unhandled-error`](docs/rules/stream-pipe-unhandled-error.md) | high | A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file. |
924
+ | <a id="swallowed-error"></a>[`swallowed-error`](docs/rules/swallowed-error.md) | medium | A catch block drops the error and the code after the try carries on as if it succeeded. |
925
+ | <a id="switch-not-exhaustive"></a>[`switch-not-exhaustive`](docs/rules/switch-not-exhaustive.md) | medium | A switch over a union or enum has no default and misses members, so the missing value leaves the result undefined. |
926
+ | <a id="throw-non-error"></a>[`throw-non-error`](docs/rules/throw-non-error.md) | medium | A string, number or object literal is thrown instead of an Error, so there is no stack trace. |
927
+ | <a id="typeorm-transaction-client-escape"></a>[`typeorm-transaction-client-escape`](docs/rules/typeorm-transaction-client-escape.md) | critical | A write inside a TypeORM transaction goes through a repository not bound to it. |
928
+ | <a id="unbounded-promise-all"></a>[`unbounded-promise-all`](docs/rules/unbounded-promise-all.md) | high | Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation. |
929
+ | <a id="uncaught-exception-continues"></a>[`uncaught-exception-continues`](docs/rules/uncaught-exception-continues.md) | high | An uncaughtException handler neither exits nor rethrows, so the process keeps running in an undefined state. |
930
+ | <a id="unguarded-boundary-access"></a>[`unguarded-boundary-access`](docs/rules/unguarded-boundary-access.md) | medium | A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError. |
931
+ | <a id="unreachable-code"></a>[`unreachable-code`](docs/rules/unreachable-code.md) | medium | Statements follow a return, throw, break or continue in the same block and never run. |
932
+ | <a id="upload-without-size-limit"></a>[`upload-without-size-limit`](docs/rules/upload-without-size-limit.md) | high | A multer or Nest upload interceptor has no file size limit. |
933
+ | <a id="webhook-missing-idempotency-check"></a>[`webhook-missing-idempotency-check`](docs/rules/webhook-missing-idempotency-check.md) | medium | A webhook route inserts rows without first checking whether the event was already processed. |
934
+
935
+ <!-- loadwise:rules:end -->
873
936
 
874
937
  ## Migration safety
875
938
 
876
939
  `npx loadwise rel migrations` reads Prisma, Drizzle, TypeORM, Knex and Sequelize migrations (SQL or code) and flags statements that lock or rewrite a table. It reads files only. `--dialect postgres|mysql` selects the rule set, `--json` for structured output and `--ignore RULE` to skip a rule. The older `loadwise perf migrations` and `loadwise perf contracts` still work and print a note pointing to `rel`.
877
940
 
878
- | Rule | What it flags |
879
- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
880
- | <a id="migration-index-not-concurrent"></a><a id="migration-concurrent-in-transaction"></a>`migration-index-not-concurrent`, `migration-concurrent-in-transaction` | A PostgreSQL index built without `CONCURRENTLY`, or `CONCURRENTLY` inside a transaction that cannot run it. |
881
- | <a id="migration-not-null-without-default"></a><a id="migration-volatile-default"></a>`migration-not-null-without-default`, `migration-volatile-default` | A NOT NULL column added without a default (fails once rows exist), or a volatile default that rewrites the table. |
882
- | <a id="migration-column-type-rewrite"></a><a id="migration-table-rewrite-command"></a>`migration-column-type-rewrite`, `migration-table-rewrite-command` | A column type change or command (`VACUUM FULL`, `CLUSTER`, `REINDEX`) that rewrites the table. |
883
- | <a id="migration-set-not-null-scan"></a><a id="migration-constraint-not-valid"></a><a id="migration-constraint-without-index"></a>`migration-set-not-null-scan`, `migration-constraint-not-valid`, `migration-constraint-without-index` | Full-table validation scans, constraints that should be added `NOT VALID` first, and constraints that build an index while blocking writes. |
884
- | <a id="migration-breaking-drop"></a><a id="migration-breaking-rename"></a>`migration-breaking-drop`, `migration-breaking-rename` | Dropping or renaming a column or table that running application code may still use. |
885
- | <a id="migration-missing-lock-timeout"></a>`migration-missing-lock-timeout` | A locking statement with no `lock_timeout`. |
886
- | <a id="migration-mysql-table-copy"></a><a id="migration-mysql-lock-unspecified"></a>`migration-mysql-table-copy`, `migration-mysql-lock-unspecified` | MySQL changes that copy the table or leave the lock level unspecified. |
887
- | <a id="migration-unparsed"></a>`migration-unparsed` | A statement the checker could not read. Review it by hand. |
941
+ <!-- loadwise:rules:start checker=reliability group=migration-safety -->
942
+
943
+ | Rule | Impact | What it flags |
944
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------- |
945
+ | <a id="migration-breaking-drop"></a>[`migration-breaking-drop`](docs/rules/migration-breaking-drop.md) | critical | A migration drops a column or table that running code may still use. |
946
+ | <a id="migration-breaking-rename"></a>[`migration-breaking-rename`](docs/rules/migration-breaking-rename.md) | high | A migration renames a column or table that running code may still use. |
947
+ | <a id="migration-column-type-rewrite"></a>[`migration-column-type-rewrite`](docs/rules/migration-column-type-rewrite.md) | critical | A migration changes a column type in a way that rewrites the table. |
948
+ | <a id="migration-concurrent-in-transaction"></a>[`migration-concurrent-in-transaction`](docs/rules/migration-concurrent-in-transaction.md) | high | A CONCURRENTLY index statement runs inside a transaction, where PostgreSQL rejects it. |
949
+ | <a id="migration-constraint-not-valid"></a>[`migration-constraint-not-valid`](docs/rules/migration-constraint-not-valid.md) | high | A constraint is added and validated in one step instead of NOT VALID first. |
950
+ | <a id="migration-constraint-without-index"></a>[`migration-constraint-without-index`](docs/rules/migration-constraint-without-index.md) | high | A unique or primary key constraint builds its index while blocking writes. |
951
+ | <a id="migration-index-not-concurrent"></a>[`migration-index-not-concurrent`](docs/rules/migration-index-not-concurrent.md) | critical | A PostgreSQL index is built without CONCURRENTLY, blocking writes to the table. |
952
+ | <a id="migration-missing-lock-timeout"></a>[`migration-missing-lock-timeout`](docs/rules/migration-missing-lock-timeout.md) | high | A migration statement takes a lock with no lock_timeout set. |
953
+ | <a id="migration-mysql-lock-unspecified"></a>[`migration-mysql-lock-unspecified`](docs/rules/migration-mysql-lock-unspecified.md) | high | A MySQL ALTER does not state its LOCK level. |
954
+ | <a id="migration-mysql-table-copy"></a>[`migration-mysql-table-copy`](docs/rules/migration-mysql-table-copy.md) | critical | A MySQL ALTER copies the whole table. |
955
+ | <a id="migration-not-null-without-default"></a>[`migration-not-null-without-default`](docs/rules/migration-not-null-without-default.md) | high | A NOT NULL column is added without a default, which fails once rows exist. |
956
+ | <a id="migration-set-not-null-scan"></a>[`migration-set-not-null-scan`](docs/rules/migration-set-not-null-scan.md) | high | SET NOT NULL scans the whole table while holding a lock. |
957
+ | <a id="migration-table-rewrite-command"></a>[`migration-table-rewrite-command`](docs/rules/migration-table-rewrite-command.md) | critical | A migration runs VACUUM FULL, CLUSTER or REINDEX, which rewrites or locks the table. |
958
+ | <a id="migration-unparsed"></a>[`migration-unparsed`](docs/rules/migration-unparsed.md) | low | A migration statement could not be parsed and needs a manual review. |
959
+ | <a id="migration-volatile-default"></a>[`migration-volatile-default`](docs/rules/migration-volatile-default.md) | high | A column is added with a volatile default, which rewrites the table. |
960
+
961
+ <!-- loadwise:rules:end -->
888
962
 
889
963
  Only new migrations fail the run. Older migrations are contextual: counted, listed with `--include-contextual`, and never exit 1.
890
964
 
@@ -913,13 +987,17 @@ It compares three kinds of source:
913
987
  - **GraphQL SDL** (`*.graphql`, `*.gql`, for example the `schema.gql` a code-first server emits). Query documents are skipped.
914
988
  - **NestJS classes** used as `@Body()` types or as controller return types (also `@ApiResponse({ type })`), found in `*.controller.ts` and read from the file that declares them (relative imports only). Only property names, `?`, `@IsOptional()` and the written type text are compared.
915
989
 
916
- | Rule | What it flags |
917
- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
918
- | <a id="api-removed-operation"></a>`api-removed-operation` | An OpenAPI path and method, or a GraphQL `Query`, `Mutation` or `Subscription` field, that no longer exists. |
919
- | <a id="api-removed-field"></a>`api-removed-field` | A response field, GraphQL type, field, argument or union member, or a DTO property returned to clients, that was removed. |
920
- | <a id="api-required-input"></a>`api-required-input` | A request field, parameter, GraphQL argument or input field that is new and required, or changed from optional to required. |
921
- | <a id="api-type-changed"></a>`api-type-changed` | A field or parameter whose type changed, or a GraphQL type that became nullable (output) or non-null (input). |
922
- | <a id="api-enum-value-removed"></a>`api-enum-value-removed` | An enum value or string-literal option that requests (or, in GraphQL, any client) can no longer use. |
990
+ <!-- loadwise:rules:start checker=reliability group=api-contract-safety -->
991
+
992
+ | Rule | Impact | What it flags |
993
+ | --------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
994
+ | <a id="api-enum-value-removed"></a>[`api-enum-value-removed`](docs/rules/api-enum-value-removed.md) | high | An enum value or string-literal option that clients could send was removed. |
995
+ | <a id="api-removed-field"></a>[`api-removed-field`](docs/rules/api-removed-field.md) | high | A response field, GraphQL type, field, argument or union member, or returned DTO property was removed. |
996
+ | <a id="api-removed-operation"></a>[`api-removed-operation`](docs/rules/api-removed-operation.md) | critical | An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed. |
997
+ | <a id="api-required-input"></a>[`api-required-input`](docs/rules/api-required-input.md) | high | A request field, parameter or GraphQL argument is new and required, or became required. |
998
+ | <a id="api-type-changed"></a>[`api-type-changed`](docs/rules/api-type-changed.md) | high | A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction. |
999
+
1000
+ <!-- loadwise:rules:end -->
923
1001
 
924
1002
  Removals point at the line in the old version (the message says so); every other finding points at the new line. A new version next to the old one (`/v2/users` added while `/v1/users` stays) breaks nothing and is not flagged. A removed request property is flagged only when the project builds a `ValidationPipe` with `forbidNonWhitelisted: true`, because only then do clients that still send it get a 400. Properties inherited from a base class in a relative import count as the class's own.
925
1003
 
@@ -930,77 +1008,7 @@ npx loadwise check --changed-since origin/main
930
1008
 
931
1009
  ## Impact levels
932
1010
 
933
- The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise rel` and the reliability section of `loadwise check` use this table.
934
-
935
- | Rule | Impact |
936
- | ------------------------------------- | -------- |
937
- | `api-removed-operation` | critical |
938
- | `drizzle-unfiltered-write` | critical |
939
- | `migration-breaking-drop` | critical |
940
- | `migration-column-type-rewrite` | critical |
941
- | `migration-index-not-concurrent` | critical |
942
- | `migration-mysql-table-copy` | critical |
943
- | `migration-table-rewrite-command` | critical |
944
- | `pg-transaction-on-pool` | critical |
945
- | `prisma-read-modify-write` | critical |
946
- | `prisma-transaction-client-escape` | critical |
947
- | `query-runner-not-released` | critical |
948
- | `typeorm-transaction-client-escape` | critical |
949
- | `api-enum-value-removed` | high |
950
- | `api-removed-field` | high |
951
- | `api-required-input` | high |
952
- | `api-type-changed` | high |
953
- | `assignment-in-condition` | high |
954
- | `async-callback-unhandled-rejection` | high |
955
- | `async-route-unhandled-rejection` | high |
956
- | `browser-not-closed` | high |
957
- | `check-then-update-race` | high |
958
- | `csharp-async-void` | high |
959
- | `discarded-error-result` | high |
960
- | `file-handle-not-closed` | high |
961
- | `find-then-create-race` | high |
962
- | `floating-promise` | high |
963
- | `go-defer-before-error-check` | high |
964
- | `go-error-discarded` | high |
965
- | `http-call-without-timeout` | high |
966
- | `invalid-typeof-comparison` | high |
967
- | `java-resource-without-try` | high |
968
- | `loop-index-past-length` | high |
969
- | `migration-breaking-rename` | high |
970
- | `migration-concurrent-in-transaction` | high |
971
- | `migration-constraint-not-valid` | high |
972
- | `migration-constraint-without-index` | high |
973
- | `migration-missing-lock-timeout` | high |
974
- | `migration-mysql-lock-unspecified` | high |
975
- | `migration-not-null-without-default` | high |
976
- | `migration-set-not-null-scan` | high |
977
- | `migration-volatile-default` | high |
978
- | `mongoose-aggregate-uncast-id` | high |
979
- | `nan-comparison` | high |
980
- | `payment-missing-idempotency-key` | high |
981
- | `prisma-dependent-writes` | high |
982
- | `promise-return-escapes-catch` | high |
983
- | `return-in-finally` | high |
984
- | `return-newline` | high |
985
- | `sql-insert-truncated-at-semicolon` | high |
986
- | `stream-pipe-unhandled-error` | high |
987
- | `unbounded-promise-all` | high |
988
- | `upload-without-size-limit` | high |
989
- | `csharp-disposable-without-using` | medium |
990
- | `drizzle-write-preflight` | medium |
991
- | `interval-not-cleared` | medium |
992
- | `json-parse-unguarded` | medium |
993
- | `python-bare-except` | medium |
994
- | `python-swallowed-exception` | medium |
995
- | `redis-incr-then-expire` | medium |
996
- | `request-number-unvalidated` | medium |
997
- | `retry-without-backoff` | medium |
998
- | `rust-unwrap-in-production` | medium |
999
- | `swallowed-error` | medium |
1000
- | `unguarded-boundary-access` | medium |
1001
- | `unreachable-code` | medium |
1002
- | `webhook-missing-idempotency-check` | medium |
1003
- | `migration-unparsed` | low |
1011
+ The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise rel` and the reliability section of `loadwise check` use the impact levels in the rule index.
1004
1012
 
1005
1013
  # Maintainability checker
1006
1014
 
@@ -1008,23 +1016,33 @@ The levels and the `--min-impact` flag work as described under the performance c
1008
1016
 
1009
1017
  ## What gets checked
1010
1018
 
1011
- | Rule | Evidence |
1012
- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1013
- | <a id="deep-control-flow"></a>`deep-control-flow` | Four nested control structures. JS/TS reports the deepest site in each function. The other parsers report threshold crossings in supported conditional and loop bodies. Independent function scopes start fresh. |
1014
- | <a id="high-branch-complexity"></a>`high-branch-complexity` | A JS/TS function reaches a score of 15. Start at one and count each conditional, loop, switch, catch or ternary. A flat switch contributes one decision. When most of a function's decisions are plain bail-outs (an `if` with no `else` that only returns, throws, continues or breaks, at the top of the body), up to twelve of them count half toward the 15, so a long run of independent guards is not reported on its own. The reported score is still the plain count. |
1015
- | <a id="duplicate-implementation"></a>`duplicate-implementation` | Substantial functions share a verified implementation. The report groups matching sites so a reviewer can compare their contracts before introducing a shared abstraction. JS/TS compares syntax while preserving identifiers, literals and operations. Python, Go, Java, C# and Rust compare exact body text of named functions selected by the parser. This deliberately misses reformatted or renamed copies. |
1016
- | <a id="dependency-cycle"></a>`dependency-cycle` | An eager internal dependency path returns to its starting module. One ordered example path is shown per strongly connected component. Deferred loads can still be checked against folder boundaries. |
1017
- | <a id="folder-boundary"></a><a id="file-placement"></a>`folder-boundary` and `file-placement` | An import crosses a boundary declared by the team, or a filename suffix occurs outside its allowed folders. Both policies are opt-in. |
1018
- | <a id="data-access-boundary"></a>`data-access-boundary` | A JS/TS file outside the approved paths imports a configured database driver or ORM module at runtime. Static imports, re-exports, `import x = require()`, literal dynamic imports and unshadowed `require()` calls are checked. The policy is opt-in via `dataAccess`. |
1019
- | <a id="query-mutates-state"></a>`query-mutates-state` | A JS/TS class instance method marked `/** @maintainabilityQuery */` writes directly through `this`. Assignments, increments, deletes and destructuring writes are covered. Mutations through aliases or arbitrary helper calls require review. |
1020
- | <a id="unused-export"></a><a id="unreferenced-file"></a>`unused-export` and `unreferenced-file` | An export no scanned file imports, and a source file nothing imports that is not an entry point. Static, type-only, `require()`, literal dynamic imports, `export … from` and `export *` count as use. An unshadowed `new Worker(new URL('./worker.ts', import.meta.url))` or `SharedWorker` counts as loading the file. A namespace import or `require()` uses the whole module. Deep imports by package name from sibling workspace members count as use of the names they import. When the scanned folder's own config has no `paths`, the aliases of an ancestor `tsconfig.json` or `jsconfig.json` that covers it resolve imports. Entry points are `package.json` `main`, `module`, `bin`, `exports` and script paths (also from a `package.json` above the scanned folder, mapped onto the scanned source), literal Node commands in GitHub Actions job steps, local script references in HTML, `nest-cli.json` entry files, `project.json` commands, `tsconfig` `files`, tests, scripts, configuration, migrations, entities, seeds, route folders (`pages/`, `routes/`, and `app/` in Next or Remix projects) and `main`/`index` files at a package root. A non-literal `import()` or `require()` makes findings contextual, project-wide when the specifier is unknown and for one folder when it starts with a relative path. Skipped in `--staged` and `--changed-since` runs, which do not see the whole project. When adopting loadwise on an existing codebase, record the current findings once with `loadwise check --write-baseline` and check with `--baseline`, so only new unused exports and files are reported. |
1021
- | <a id="large-module"></a>`large-module` | A JS/TS file has more than 600 lines of code, not counting comments and blank lines. Generated and test files are skipped. Override with `limits.largeModuleLines`. |
1022
- | <a id="large-class"></a>`large-class` | A class has more than 30 methods, accessors, constructors or function-valued fields. Plain data properties (entities, DTOs) are not counted. Override with `limits.largeClassMembers`. |
1023
- | <a id="long-parameter-list"></a>`long-parameter-list` | A function with a body takes more than 5 positional parameters. A destructured object counts as one. Constructors with decorators or parameter properties (dependency injection lists) and parameters with decorators (`@Body()`, `@Param()`) are not counted. Override with `limits.longParameterCount`. |
1024
- | <a id="unused-import"></a>`unused-import` | An imported name is never used in the file. Type positions, `typeof`, re-exports, decorators, JSDoc references and the `React` import under the classic JSX runtime count as use, and side-effect imports are never reported. Skipped when `noUnusedLocals` is on, since the compiler reports it, when an eslint-disable comment names `no-unused-vars` or `@typescript-eslint/no-unused-vars`, and in codemod `*.input` / `*.output` fixtures, fixture folders, docs, examples, vendored code and assets. The fix removes the name; removing a whole declaration is marked for review because the module may have side effects. |
1025
- | <a id="unused-local-variable"></a>`unused-local-variable` | A `const`, `let` or `var` is declared and never read. Names starting with `_`, destructuring (rest siblings omit keys on purpose), loop and catch variables, exports and files using `eval` or `with` are skipped, as is the whole rule when `noUnusedLocals` is on, a variable under an eslint-disable comment for `no-unused-vars` or `@typescript-eslint/no-unused-vars`, and codemod `*.input` / `*.output` fixtures, fixture folders, docs, examples, vendored code and assets. The fix deletes the declaration only when its initializer has no side effects. |
1026
- | <a id="stray-console"></a>`stray-console` | A `console.*` call in server or Node code, as the execution context classifies it, writes unleveled, unstructured output. Browser and frontend files, CLI scripts (a shebang or `process.argv`), vendored or bundled libraries, stories, playgrounds, docs, examples and fixtures, calls under an eslint-disable comment for `no-console`, and a call directly followed by `process.exit` or `throw` are skipped, as are tests, configuration, seeds, migrations, logger implementations, development-only guards, last-resort `uncaughtException` handlers and error boundaries. When the file already has a `logger` (or a Nest `this.logger`), the fix routes the call through it and is marked for review. |
1027
- | <a id="deprecated-node-api"></a>`deprecated-node-api` | `new Buffer()` (use `Buffer.alloc` or `Buffer.from`), `url.parse()` (use `new URL()`) or `fs.exists()` (use `fs.access` or `existsSync`). The `Buffer` fix applies to literal arguments; the `url.parse` fix is marked for review because relative input throws and the result has no `path`, `auth` or `query`. |
1019
+ <!-- loadwise:rules:start checker=maintainability group=what-gets-checked -->
1020
+
1021
+ | Rule | Impact | What it flags |
1022
+ | ------------------------------------------------------------------------------------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------- |
1023
+ | <a id="data-access-boundary"></a>[`data-access-boundary`](docs/rules/data-access-boundary.md) | medium | A file outside the approved paths imports a configured database driver or ORM. |
1024
+ | <a id="deep-control-flow"></a>[`deep-control-flow`](docs/rules/deep-control-flow.md) | low | Control structures are nested four levels deep. |
1025
+ | <a id="dependency-cycle"></a>[`dependency-cycle`](docs/rules/dependency-cycle.md) | high | An eager chain of internal imports leads back to the module it started from. |
1026
+ | <a id="deprecated-node-api"></a>[`deprecated-node-api`](docs/rules/deprecated-node-api.md) | medium | A deprecated Node.js API is used: new Buffer(), url.parse() or fs.exists(). |
1027
+ | <a id="double-type-assertion"></a>[`double-type-assertion`](docs/rules/double-type-assertion.md) | low | A value is cast through unknown or any to a second type, bypassing the type checker. |
1028
+ | <a id="duplicate-implementation"></a>[`duplicate-implementation`](docs/rules/duplicate-implementation.md) | medium | Substantial functions share the same implementation. |
1029
+ | <a id="file-placement"></a>[`file-placement`](docs/rules/file-placement.md) | low | A file with a configured suffix sits outside its allowed folders. |
1030
+ | <a id="focused-test-committed"></a>[`focused-test-committed`](docs/rules/focused-test-committed.md) | medium | A committed .only, fit or fdescribe makes the test runner skip every other test. |
1031
+ | <a id="folder-boundary"></a>[`folder-boundary`](docs/rules/folder-boundary.md) | medium | An import crosses a folder boundary the team declared. |
1032
+ | <a id="high-branch-complexity"></a>[`high-branch-complexity`](docs/rules/high-branch-complexity.md) | medium | A function reaches a branch complexity score of 15. |
1033
+ | <a id="large-class"></a>[`large-class`](docs/rules/large-class.md) | low | A class has more than 30 methods, accessors, constructors or function-valued fields. |
1034
+ | <a id="large-module"></a>[`large-module`](docs/rules/large-module.md) | low | A file has more than 600 lines of code. |
1035
+ | <a id="long-parameter-list"></a>[`long-parameter-list`](docs/rules/long-parameter-list.md) | low | A function takes more than 5 positional parameters. |
1036
+ | <a id="query-mutates-state"></a>[`query-mutates-state`](docs/rules/query-mutates-state.md) | medium | A method marked @maintainabilityQuery writes through this. |
1037
+ | <a id="stray-console"></a>[`stray-console`](docs/rules/stray-console.md) | low | A console call in production code bypasses the logger, so its output has no level or structure. |
1038
+ | <a id="ts-suppression-without-reason"></a>[`ts-suppression-without-reason`](docs/rules/ts-suppression-without-reason.md) | low | A @ts-ignore, @ts-expect-error or @ts-nocheck directive has no explanation. |
1039
+ | <a id="tsconfig-strict-disabled"></a>[`tsconfig-strict-disabled`](docs/rules/tsconfig-strict-disabled.md) | medium | A tsconfig turns off strict type checking. |
1040
+ | <a id="unreferenced-file"></a>[`unreferenced-file`](docs/rules/unreferenced-file.md) | low | A source file that nothing imports and that is not an entry point. |
1041
+ | <a id="unused-export"></a>[`unused-export`](docs/rules/unused-export.md) | low | An export that no scanned file imports. |
1042
+ | <a id="unused-import"></a>[`unused-import`](docs/rules/unused-import.md) | low | An imported name is never used in the file. |
1043
+ | <a id="unused-local-variable"></a>[`unused-local-variable`](docs/rules/unused-local-variable.md) | low | A local variable is assigned but never read. |
1044
+
1045
+ <!-- loadwise:rules:end -->
1028
1046
 
1029
1047
  JS and TS source checks use the TypeScript parser. The optional ast-grep executable supplies native parsers for Python, Go, Java, C#, Rust, PHP, Ruby, Kotlin, C and C++. The nesting rule recognizes specific grammar constructs. Braceless forms and pattern-matching constructs have different coverage across languages. A `.h` file uses the C grammar. Use a C++ header extension for C++ grammar.
1030
1048
 
@@ -1061,12 +1079,7 @@ npx loadwise maint . --fix --yes # applies every fix without asking
1061
1079
 
1062
1080
  `--fix` is refused with `--json` or `--graph`, and `--yes` alone is refused. Without a terminal, `--fix` requires `--yes`. A fix applies only where the original lines still exist. One that an earlier fix made stale is skipped and reappears, rebuilt, on the next run. Review the diff and run your tests afterwards.
1063
1081
 
1064
- | Rule | Rewrite |
1065
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1066
- | `deep-control-flow` | Lifts the deepest branch one level with a guard clause, a merged nested `if`, or by dropping an `else` after a branch that exits. |
1067
- | `high-branch-complexity` | Combines nested conditional expressions with the same literal success label while preserving short-circuit order. Other fixes merge nested `if`s, join adjacent same-exit `if`s with `\|\|`, turn `x ? true : false` into `Boolean(x)`, and `if (!x) x = value` into `x \|\|= value`. |
1068
- | `duplicate-implementation` | Keeps one top-level function and makes each other copy delegate to it, adding an import where needed. Applied only when every name the copies use resolves to the same binding. |
1069
- | `dependency-cycle` | Turns an import whose names are used only as types into `import type`, which removes that edge from the runtime cycle. |
1082
+ The rules with an automatic rewrite are `deep-control-flow`, `high-branch-complexity`, `duplicate-implementation` and `dependency-cycle`. Each rule page describes its rewrite.
1070
1083
 
1071
1084
  Other rules have no automatic rewrite.
1072
1085
 
@@ -1124,27 +1137,6 @@ Only the changed files are analysed, while imports still resolve through the who
1124
1137
 
1125
1138
  The levels and the `--min-impact` flag work as described under the performance checker's impact levels.
1126
1139
 
1127
- | Rule | Impact |
1128
- | -------------------------- | ------ |
1129
- | `dependency-cycle` | high |
1130
- | `data-access-boundary` | medium |
1131
- | `deprecated-node-api` | medium |
1132
- | `duplicate-implementation` | medium |
1133
- | `folder-boundary` | medium |
1134
- | `high-branch-complexity` | medium |
1135
- | `query-mutates-state` | medium |
1136
- | `syntax-error` | medium |
1137
- | `deep-control-flow` | low |
1138
- | `file-placement` | low |
1139
- | `large-class` | low |
1140
- | `large-module` | low |
1141
- | `long-parameter-list` | low |
1142
- | `stray-console` | low |
1143
- | `unreferenced-file` | low |
1144
- | `unused-export` | low |
1145
- | `unused-import` | low |
1146
- | `unused-local-variable` | low |
1147
-
1148
1140
  # Security checker
1149
1141
 
1150
1142
  `loadwise sec` reports code paths where input or missing scope can expose data: runtime text composed into SQL and, when the project declares them, Prisma and Drizzle queries that do not prove their row scope. Findings are review prompts with a location, a rule ID, an impact level, a generic fix example and, where it is safe, a source-based fix.
@@ -1164,77 +1156,84 @@ It accepts the source-check flags of `loadwise perf`, including `--format`, `--m
1164
1156
 
1165
1157
  ## Rules
1166
1158
 
1167
- | Rule | What to review |
1168
- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1169
- | <a id="pg-dynamic-query-text"></a>`pg-dynamic-query-text` | Runtime fragments enter SQL text directly. Bind data as parameters and verify how any dynamic identifiers are chosen and quoted. A finding is a code-review prompt. |
1170
- | <a id="prisma-scope-unverified"></a>`prisma-scope-unverified` | A Prisma read or write on a model listed in `prismaScopes` does not prove the configured scope in its filter, projection or write data. |
1171
- | <a id="drizzle-scope-unverified"></a>`drizzle-scope-unverified` | A Drizzle query on a table listed in `drizzleScopes` does not prove the configured predicate, projection or write data. |
1172
- | <a id="code-injection"></a>`code-injection` | Request data is evaluated as code: `eval`, `new Function`, `vm`, a string timer callback, `require`/`import()` of a request path, or node-serialize. |
1173
- | <a id="command-injection"></a>`command-injection` | Request data reaches a command line a shell parses: `exec`, or `spawn`/`execFile`/execa with `shell` or `sh -c`. An interpolated parameter with no traced caller is contextual. |
1174
- | <a id="drizzle-sql-raw-dynamic"></a>`drizzle-sql-raw-dynamic` | `sql.raw` from drizzle-orm receives text built from a runtime value. |
1175
- | <a id="knex-raw-dynamic-text"></a>`knex-raw-dynamic-text` | A Knex `*Raw` fragment or `knex.raw` receives text built from a runtime value instead of `?`/`??` bindings. |
1176
- | <a id="mysql-dynamic-query-text"></a>`mysql-dynamic-query-text` | A `mysql`/`mysql2` `query` or `execute` receives SQL text built from a runtime value instead of `?` placeholders. |
1177
- | <a id="nosql-operator-injection"></a>`nosql-operator-injection` | Request data that can arrive as an object is a Mongoose or MongoDB filter, a filter value or a `$where` expression. Contextual when applicable Express sanitizer registration is visible. Fix: wrap the value in `$eq`. |
1178
- | <a id="prisma-raw-unsafe-dynamic"></a>`prisma-raw-unsafe-dynamic` | `$queryRawUnsafe`, `$executeRawUnsafe` or `Prisma.raw` receives SQL text built from a runtime value. |
1179
- | <a id="regex-from-input"></a>`regex-from-input` | Request text becomes a regular expression through `RegExp`, `match`/`matchAll`/`search` on a string, or a `$regex` operand, without escaping. |
1180
- | <a id="regex-catastrophic-backtracking"></a>`regex-catastrophic-backtracking` | A fixed regular expression with nested or overlapping repetition (such as `(a+)+` or `(a\|aa)+`), or overlapping repeats in sequence (such as `\s+.*\s+$`), runs on request input and can backtrack exponentially or in polynomial time, blocking the event loop. Rewrite it so each part matches text one way, or cut the input to a fixed length first. |
1181
- | <a id="sequelize-dynamic-query-text"></a>`sequelize-dynamic-query-text` | `sequelize.query` or `literal` receives SQL text built from a runtime value instead of `replacements` or `bind`. |
1182
- | <a id="template-injection"></a>`template-injection` | Request data is the template text of `ejs`, `pug`, `handlebars`, `nunjucks`, `mustache` or lodash `template`. |
1183
- | <a id="typeorm-dynamic-query-text"></a>`typeorm-dynamic-query-text` | A TypeORM `query` or a query-builder condition, order, group, select or join receives SQL text built from a runtime value. |
1184
- | <a id="open-redirect"></a>`open-redirect` | A redirect target whose site comes from request data. A fixed origin or an enforced relative-path check can keep the target on site. A Referer target is contextual. |
1185
- | <a id="path-traversal"></a>`path-traversal` | A file path built from request data reaches `fs`, `res.sendFile` without `root`, `res.download` or `res.render`. `path.basename` and a containment check clear it. An anchored filename allowlist also clears it when the checker can prove the allowed characters and the validated value reaches the file operation unchanged. |
1186
- | <a id="ssrf-request-url"></a>`ssrf-request-url` | An outgoing HTTP request whose URL or host comes from request data. A fixed origin with a request path, an enforced exact host allowlist on the parsed URL, or an SSRF-filtering agent is quiet. |
1187
- | <a id="upload-client-filename"></a>`upload-client-filename` | multer disk storage saves uploads under the client's file name, so same-named uploads overwrite each other and the client picks the extension. |
1188
- | <a id="zip-slip-extraction"></a>`zip-slip-extraction` | An archive entry name (adm-zip, yauzl, unzipper, tar-stream, jszip, node-stream-zip) reaches a file write without a prior containment check. The trace follows aliases, destructuring and local call hops. |
1189
- | <a id="bcrypt-low-cost"></a>`bcrypt-low-cost` | A literal bcrypt cost below 10 passed to `hash`, `hashSync`, `genSalt` or `genSaltSync`. Use 10 or higher and measure the hashing time; the fix writes 12. |
1190
- | <a id="hardcoded-secret"></a>`hardcoded-secret` | A known credential shape (`sk_live_`, `AKIA...`, `ghp_`, private keys), a string literal used as a JWT, HMAC or session signing key, or a high-entropy value assigned to a secret-named variable or property. Placeholders, documentation examples and test sources are skipped; low-entropy named values are contextual. |
1191
- | <a id="insecure-cipher"></a>`insecure-cipher` | `createCipher` or `createDecipher` (no IV), DES, RC2, RC4 or Blowfish algorithms, ECB mode, or a fixed string or `Buffer.alloc` IV in `createCipheriv`. |
1192
- | <a id="insecure-random-for-secret"></a>`insecure-random-for-secret` | `Math.random()` feeds a token, code, nonce, session or secret. Use `crypto.randomBytes`, `randomInt` or `randomUUID`; names that only end in `id` are contextual. `Math.floor(Math.random() * N)` has a source fix. |
1193
- | <a id="jwt-decode-for-auth"></a>`jwt-decode-for-auth` | `decode` (`jsonwebtoken`, `JwtService`, the jwt-decode package) has no `verify` on the same token and its result becomes `req.user`, is used in a guard or auth middleware, or filters a query. Other uses are contextual. |
1194
- | <a id="jwt-none-algorithm"></a>`jwt-none-algorithm` | The `none` algorithm appears in an `algorithms` list or a `sign` call, so unsigned tokens are accepted or produced. |
1195
- | <a id="jwt-sign-without-expiry"></a>`jwt-sign-without-expiry` | `jsonwebtoken` `sign` with a literal payload and no `expiresIn` option or `exp` claim. Literal NestJS JwtService signing also uses expiry set by its bound JwtModule registration. Unresolved defaults are contextual. |
1196
- | <a id="jwt-verify-without-algorithms"></a>`jwt-verify-without-algorithms` | `jsonwebtoken` `verify` without `algorithms` in a literal options object. Public keys, key files and key-lookup callbacks are default; shared secrets are contextual. The fix pins the algorithm the same key signs with in the file. |
1197
- | <a id="secret-compared-non-constant-time"></a>`secret-compared-non-constant-time` | An HMAC or hash digest, or a value named like a signature, secret, token, OTP, password or CSRF token, is compared directly with request input. For strict comparisons of two proven strings in a Node module, the fix uses `crypto.timingSafeEqual` and preserves JavaScript string equality. |
1198
- | <a id="tls-verification-disabled"></a>`tls-verification-disabled` | A literal `rejectUnauthorized: false`, `strictSSL: false` or `NODE_TLS_REJECT_UNAUTHORIZED = '0'`. Under a non-production guard it is contextual; database `ssl` options count too. |
1199
- | <a id="weak-password-hash"></a>`weak-password-hash` | `createHash` with md5, sha1, sha256 or sha512 (or the crypto-js or md5 package) hashes a password or the digest is stored as one. Use `argon2`, `bcrypt` or `crypto.scrypt`. |
1200
- | <a id="plaintext-password-storage"></a>`plaintext-password-storage` | A request password is written by an ORM create, update or save, or a raw INSERT or UPDATE, without being hashed. A value named like a hash or digest, and a model hook that hashes on save, keep it quiet. Hash it with `argon2`, `bcrypt` or `crypto.scrypt` first. |
1201
- | <a id="auth-route-without-rate-limit"></a>`auth-route-without-rate-limit` | A login, signup, password-reset or OTP route has no rate limiter, which allows brute force and credential stuffing. A route is contextual when a limiter package is imported in a module connected to its file by imports (the file itself, one it imports, or app setup that imports it) but not tied to the route; dismiss a gateway or proxy limit with a review comment. |
1202
- | <a id="cookie-missing-security-flags"></a>`cookie-missing-security-flags` | A session, token or auth cookie is set without `httpOnly`, or with `secure: false`. A missing `secure` or `sameSite` is contextual. Non-literal options are not judged. |
1203
- | <a id="cors-credentials-any-origin"></a>`cors-credentials-any-origin` | CORS options allow credentials with origin `*`, `true`, a match-everything regex or a callback that always accepts. Listed or configured origins are clean. |
1204
- | <a id="cors-origin-regex-unanchored"></a>`cors-origin-regex-unanchored` | CORS `origin` regexes, and regex `.test` calls on the request origin, whose host can be prefixed (no `^`, `//` or `\.` before it), extended (no `$` after it) or has an unescaped dot. URL values passed to `new RegExp` count too. Without credentials it is contextual. The fix anchors and escapes a single-branch literal and needs review. |
1205
- | <a id="error-stack-in-response"></a>`error-stack-in-response` | An error `.stack` is written into a response body. A whole error object is contextual. Code that runs only outside production is clean. |
1206
- | <a id="graphql-introspection-enabled"></a>`graphql-introspection-enabled` | A GraphQL server config turns on `introspection`, `playground` or `graphiql` with a literal `true`. Expressions are not judged. |
1207
- | <a id="mass-assignment"></a>`mass-assignment` | The whole request body reaches a Prisma, TypeORM, Mongoose or Sequelize write. Decorated DTO classes, schema parses and explicit field picks are clean. |
1208
- | <a id="nest-validation-without-whitelist"></a>`nest-validation-without-whitelist` | A NestJS `ValidationPipe` is created without `whitelist: true`, so undeclared properties reach handlers. Without `forbidNonWhitelisted` it is contextual. |
1209
- | <a id="prototype-pollution"></a>`prototype-pollution` | A request-controlled key is written through a nested path, or the whole request goes to lodash `merge`, `defaultsDeep`, a path `set` or an unguarded local deep merge. |
1210
- | <a id="reflected-xss-response"></a>`reflected-xss-response` | Request data is interpolated into an HTML string sent with `res.send`. Contextual only in this version. |
1211
- | <a id="secret-in-log"></a>`secret-in-log` | A password, token, key or authorization value is passed to a logger call. Logging a whole request body or headers object is contextual. |
1212
- | <a id="template-autoescape-disabled"></a>`template-autoescape-disabled` | `swig.setDefaults`, `nunjucks.configure` or `new nunjucks.Environment` sets `autoescape: false`, or Handlebars `compile`/`precompile` sets `noEscape: true`. |
1213
- | <a id="xml-external-entities"></a>`xml-external-entities` | `libxmljs` is asked to load entities or the DTD with `noent: true` or `dtdload: true`. |
1214
- | <a id="password-hash-in-response"></a>`password-hash-in-response` | A request handler sends a user record read without a field selection, so its password hash reaches the client. Select or omit the field, or hide it on the model (`select: false`, `@Exclude()`). |
1215
- | <a id="storage-object-public-acl"></a>`storage-object-public-acl` | An S3 or Google Cloud Storage upload sets a public-read ACL, so anyone can read the object. Keep objects private and hand out short-lived presigned URLs. Keys or buckets named like public assets are contextual; a public read-write ACL never is. |
1216
- | <a id="secret-in-url-query"></a>`secret-in-url-query` | A password, token or API key is read from, or sent in, a URL query string, where it ends up in access logs, browser history and Referer headers. Send it in a header or the body. Reset, verify and invite tokens, and map or weather APIs that require a query key, are contextual. |
1217
- | <a id="graphql-query-depth-unbounded"></a>`graphql-query-depth-unbounded` | An Apollo, Yoga, graphql-http, mercurius or Nest GraphQL server has no query depth or cost limit, so one deeply nested query can exhaust it. Contextual when the options are not visible or a limit library is imported elsewhere. |
1218
- | <a id="database-error-in-response"></a>`database-error-in-response` | A 5xx response sends a raw database error, or its message, caught from a database call. Driver messages reveal table, column and constraint names; log the error and return a generic message. Express error middleware is contextual. |
1219
- | <a id="dom-xss-sink"></a>`dom-xss-sink` | Untrusted or dynamic HTML is written to innerHTML, outerHTML, insertAdjacentHTML, document.write or createContextualFragment, which allows DOM-based XSS. |
1220
- | <a id="react-dangerously-set-inner-html"></a>`react-dangerously-set-inner-html` | dangerouslySetInnerHTML receives HTML that is not a constant or sanitized. |
1221
- | <a id="angular-bypass-security-trust"></a>`angular-bypass-security-trust` | DomSanitizer.bypassSecurityTrust* is called on a dynamic value, which turns off Angular's built-in sanitization. |
1222
- | <a id="vue-v-html-unsanitized"></a>`vue-v-html-unsanitized` | A Vue render function binds unsanitized dynamic HTML to innerHTML. |
1223
- | <a id="frontend-storage-secret-token"></a>`frontend-storage-secret-token` | A token, JWT, password or API key is stored in localStorage or sessionStorage, readable by any script on the page. |
1224
- | <a id="postmessage-missing-origin-check"></a>`postmessage-missing-origin-check` | postMessage targets '*', or a window message listener reads event.data without checking origin or source. |
1225
- | <a id="express-missing-helmet"></a>`express-missing-helmet` | The Express or NestJS server starts without helmet security headers middleware (contextual: a proxy may set them). |
1226
- | <a id="committed-secret"></a>`committed-secret` | A tracked file holds a credential: a non-placeholder value for a secret-looking key in a tracked `.env` file, or a high-confidence token format (AWS, GitHub, Slack, Stripe live, Google API key, private key block) in any tracked text file. Ignored `.env` files are never read, and the message shows only the key and a four-character prefix. |
1227
- | <a id="compose-hardcoded-secret"></a>`compose-hardcoded-secret` | A docker-compose `environment:` entry sets a secret-looking key to a literal value instead of a substitution or secret. |
1228
- | <a id="dockerfile-add-remote-url"></a>`dockerfile-add-remote-url` | `ADD` fetches an `http(s)` URL without a checksum. Download with curl and verify a checksum, or `COPY` a local file. |
1229
- | <a id="dockerfile-runs-as-root"></a>`dockerfile-runs-as-root` | The final stage has no `USER` instruction, or its last `USER` is root. Builder stages are not checked. |
1230
- | <a id="dockerfile-secret-in-build"></a>`dockerfile-secret-in-build` | An `ARG` or `ENV` with a secret-looking name has a literal default, or `COPY`/`ADD` puts an env file or private key into the image. |
1231
- | <a id="dockerfile-unpinned-base-image"></a>`dockerfile-unpinned-base-image` | A `FROM` image has no tag or uses `:latest`. A version tag is fine; a digest is best. |
1232
- | <a id="server-action-missing-auth"></a>`server-action-missing-auth` | An exported Next.js Server Action performs work without verifying authentication or session state. |
1233
- | <a id="ssrf-redirect-bypass"></a>`ssrf-redirect-bypass` | An outbound HTTP request with a dynamic URL does not disable redirects (`redirect: 'error'` / `'manual'` or `maxRedirects: 0`), allowing SSRF allowlist bypasses. |
1234
- | <a id="vm-sandbox-escape"></a>`vm-sandbox-escape` | Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE. |
1235
- | <a id="jwt-weak-secret-literal"></a>`jwt-weak-secret-literal` | JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery. |
1236
- | <a id="graphql-batching-unbounded"></a>`graphql-batching-unbounded` | GraphQL query batching is enabled without a batch size, query depth, or cost/complexity limit. |
1237
- | <a id="express-cookie-auth-missing-csrf"></a>`express-cookie-auth-missing-csrf` | Cookie-based session or auth is paired with state-changing routes without CSRF protection or `sameSite: "strict"`. |
1159
+ <!-- loadwise:rules:start checker=security group=rules -->
1160
+
1161
+ | Rule | Impact | What it flags |
1162
+ | ------------------------------------------------------------------------------------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
1163
+ | <a id="angular-bypass-security-trust"></a>[`angular-bypass-security-trust`](docs/rules/angular-bypass-security-trust.md) | high | DomSanitizer.bypassSecurityTrust* is called on a dynamic value, which turns off Angular's built-in sanitization. |
1164
+ | <a id="auth-route-without-rate-limit"></a>[`auth-route-without-rate-limit`](docs/rules/auth-route-without-rate-limit.md) | medium | A login, signup or password-reset route has no rate limiter. |
1165
+ | <a id="bcrypt-low-cost"></a>[`bcrypt-low-cost`](docs/rules/bcrypt-low-cost.md) | medium | A bcrypt password hash uses a work factor below the recommended minimum. |
1166
+ | <a id="client-env-secret-exposed"></a>[`client-env-secret-exposed`](docs/rules/client-env-secret-exposed.md) | critical | A secret-named env variable is read under a browser prefix (NEXT_PUBLIC_, VITE_, REACT_APP_...), so the build ships it to every visitor. |
1167
+ | <a id="code-injection"></a>[`code-injection`](docs/rules/code-injection.md) | critical | Request-controlled input becomes source code evaluated by the application. |
1168
+ | <a id="command-injection"></a>[`command-injection`](docs/rules/command-injection.md) | critical | Request-controlled input reaches a shell command string. |
1169
+ | <a id="committed-secret"></a>[`committed-secret`](docs/rules/committed-secret.md) | critical | A tracked file contains a value that appears to be a credential. |
1170
+ | <a id="compose-hardcoded-secret"></a>[`compose-hardcoded-secret`](docs/rules/compose-hardcoded-secret.md) | high | A Docker Compose service supplies a secret as a literal environment value. |
1171
+ | <a id="cookie-missing-security-flags"></a>[`cookie-missing-security-flags`](docs/rules/cookie-missing-security-flags.md) | high | A sensitive cookie is set without the expected security attributes. |
1172
+ | <a id="cors-credentials-any-origin"></a>[`cors-credentials-any-origin`](docs/rules/cors-credentials-any-origin.md) | high | A credentialed CORS response allows arbitrary origins. |
1173
+ | <a id="cors-origin-regex-unanchored"></a>[`cors-origin-regex-unanchored`](docs/rules/cors-origin-regex-unanchored.md) | medium | A CORS origin regex also accepts look-alike hosts. |
1174
+ | <a id="database-error-in-response"></a>[`database-error-in-response`](docs/rules/database-error-in-response.md) | medium | An HTTP response includes a raw database error message. |
1175
+ | <a id="dockerfile-add-remote-url"></a>[`dockerfile-add-remote-url`](docs/rules/dockerfile-add-remote-url.md) | medium | A Dockerfile ADD instruction retrieves a resource from a remote URL. |
1176
+ | <a id="dockerfile-runs-as-root"></a>[`dockerfile-runs-as-root`](docs/rules/dockerfile-runs-as-root.md) | medium | The final image selects root or inherits an unverified base-image user. |
1177
+ | <a id="dockerfile-secret-in-build"></a>[`dockerfile-secret-in-build`](docs/rules/dockerfile-secret-in-build.md) | high | A Dockerfile exposes a secret through a build argument or environment variable. |
1178
+ | <a id="dockerfile-unpinned-base-image"></a>[`dockerfile-unpinned-base-image`](docs/rules/dockerfile-unpinned-base-image.md) | low | A Dockerfile uses a base image reference that can change between builds. |
1179
+ | <a id="dom-xss-sink"></a>[`dom-xss-sink`](docs/rules/dom-xss-sink.md) | high | Untrusted or dynamic HTML reaches innerHTML, outerHTML, insertAdjacentHTML, document.write or createContextualFragment (DOM XSS). |
1180
+ | <a id="drizzle-scope-unverified"></a>[`drizzle-scope-unverified`](docs/rules/drizzle-scope-unverified.md) | high | A Drizzle operation lacks the row scope required by the declared policy. |
1181
+ | <a id="drizzle-sql-raw-dynamic"></a>[`drizzle-sql-raw-dynamic`](docs/rules/drizzle-sql-raw-dynamic.md) | critical | A dynamic SQL fragment reaches Drizzle without parameter binding. |
1182
+ | <a id="error-stack-in-response"></a>[`error-stack-in-response`](docs/rules/error-stack-in-response.md) | medium | An HTTP response includes an internal error stack. |
1183
+ | <a id="express-cookie-auth-missing-csrf"></a>[`express-cookie-auth-missing-csrf`](docs/rules/express-cookie-auth-missing-csrf.md) | high | Cookie-based session or auth is paired with state-changing routes without CSRF protection or `sameSite: "strict"`. |
1184
+ | <a id="express-missing-helmet"></a>[`express-missing-helmet`](docs/rules/express-missing-helmet.md) | low | The Express or NestJS server starts without helmet security headers middleware (contextual: a proxy may set them). |
1185
+ | <a id="frontend-storage-secret-token"></a>[`frontend-storage-secret-token`](docs/rules/frontend-storage-secret-token.md) | medium | A token, JWT, password or API key is stored in localStorage or sessionStorage, readable by any script on the page. |
1186
+ | <a id="graphql-batching-unbounded"></a>[`graphql-batching-unbounded`](docs/rules/graphql-batching-unbounded.md) | medium | GraphQL query batching is enabled without a batch size, query depth, or cost/complexity limit. |
1187
+ | <a id="graphql-introspection-enabled"></a>[`graphql-introspection-enabled`](docs/rules/graphql-introspection-enabled.md) | medium | A GraphQL server explicitly enables schema introspection. |
1188
+ | <a id="graphql-query-depth-unbounded"></a>[`graphql-query-depth-unbounded`](docs/rules/graphql-query-depth-unbounded.md) | medium | A GraphQL server accepts queries of any depth. |
1189
+ | <a id="hardcoded-secret"></a>[`hardcoded-secret`](docs/rules/hardcoded-secret.md) | critical | The source supplies a literal credential or cryptographic secret. |
1190
+ | <a id="insecure-cipher"></a>[`insecure-cipher`](docs/rules/insecure-cipher.md) | medium | A cryptographic operation selects an insecure cipher or mode. |
1191
+ | <a id="insecure-random-for-secret"></a>[`insecure-random-for-secret`](docs/rules/insecure-random-for-secret.md) | high | A sensitive token or secret uses a non-cryptographic random source. |
1192
+ | <a id="jsx-javascript-url"></a>[`jsx-javascript-url`](docs/rules/jsx-javascript-url.md) | high | In React 18 and older or Preact, a URL search parameter or location hash starts a JSX href, action or iframe src (javascript: XSS). |
1193
+ | <a id="jwt-decode-for-auth"></a>[`jwt-decode-for-auth`](docs/rules/jwt-decode-for-auth.md) | high | Authentication uses decoded JWT claims without verifying the token signature. |
1194
+ | <a id="jwt-none-algorithm"></a>[`jwt-none-algorithm`](docs/rules/jwt-none-algorithm.md) | critical | JWT signing or verification allows an unsigned token. |
1195
+ | <a id="jwt-sign-without-expiry"></a>[`jwt-sign-without-expiry`](docs/rules/jwt-sign-without-expiry.md) | medium | A signed JWT has no explicit expiration. |
1196
+ | <a id="jwt-verify-without-algorithms"></a>[`jwt-verify-without-algorithms`](docs/rules/jwt-verify-without-algorithms.md) | high | JWT verification does not restrict the accepted signing algorithms. |
1197
+ | <a id="jwt-weak-secret-literal"></a>[`jwt-weak-secret-literal`](docs/rules/jwt-weak-secret-literal.md) | high | JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery. |
1198
+ | <a id="knex-raw-dynamic-text"></a>[`knex-raw-dynamic-text`](docs/rules/knex-raw-dynamic-text.md) | critical | A dynamic SQL fragment reaches Knex without parameter binding. |
1199
+ | <a id="mass-assignment"></a>[`mass-assignment`](docs/rules/mass-assignment.md) | high | An unfiltered request body reaches a persistence operation. |
1200
+ | <a id="mysql-dynamic-query-text"></a>[`mysql-dynamic-query-text`](docs/rules/mysql-dynamic-query-text.md) | critical | Dynamic SQL text reaches a MySQL client without parameter binding. |
1201
+ | <a id="nest-validation-without-whitelist"></a>[`nest-validation-without-whitelist`](docs/rules/nest-validation-without-whitelist.md) | medium | A NestJS ValidationPipe permits properties outside the validated DTO. |
1202
+ | <a id="next-image-any-remote-host"></a>[`next-image-any-remote-host`](docs/rules/next-image-any-remote-host.md) | medium | A Next.js images.remotePatterns entry sets hostname '**', so the image optimizer fetches and serves any host (open proxy). |
1203
+ | <a id="nosql-operator-injection"></a>[`nosql-operator-injection`](docs/rules/nosql-operator-injection.md) | high | Request data can introduce query operators into a NoSQL filter. |
1204
+ | <a id="open-redirect"></a>[`open-redirect`](docs/rules/open-redirect.md) | medium | An HTTP redirect destination is controlled by request data. |
1205
+ | <a id="password-hash-in-response"></a>[`password-hash-in-response`](docs/rules/password-hash-in-response.md) | high | A response returns a user record that still holds its password hash. |
1206
+ | <a id="path-traversal"></a>[`path-traversal`](docs/rules/path-traversal.md) | high | Request data controls a filesystem path without a recognized containment check. |
1207
+ | <a id="pg-dynamic-query-text"></a>[`pg-dynamic-query-text`](docs/rules/pg-dynamic-query-text.md) | medium | Dynamic SQL text reaches the PostgreSQL client without parameter binding. |
1208
+ | <a id="plaintext-password-storage"></a>[`plaintext-password-storage`](docs/rules/plaintext-password-storage.md) | critical | A password is stored or written without being hashed. |
1209
+ | <a id="postmessage-missing-origin-check"></a>[`postmessage-missing-origin-check`](docs/rules/postmessage-missing-origin-check.md) | medium | postMessage targets '*', or a window message listener reads event.data without checking origin or source. |
1210
+ | <a id="prisma-raw-unsafe-dynamic"></a>[`prisma-raw-unsafe-dynamic`](docs/rules/prisma-raw-unsafe-dynamic.md) | critical | Dynamic SQL text reaches an unsafe Prisma raw-query method. |
1211
+ | <a id="prisma-scope-unverified"></a>[`prisma-scope-unverified`](docs/rules/prisma-scope-unverified.md) | high | A Prisma operation lacks the row scope required by the declared policy. |
1212
+ | <a id="prototype-pollution"></a>[`prototype-pollution`](docs/rules/prototype-pollution.md) | high | Request data can supply keys to a write or merge that can modify an object prototype. |
1213
+ | <a id="react-dangerously-set-inner-html"></a>[`react-dangerously-set-inner-html`](docs/rules/react-dangerously-set-inner-html.md) | high | dangerouslySetInnerHTML receives HTML that is not a constant or sanitized. |
1214
+ | <a id="reflected-xss-response"></a>[`reflected-xss-response`](docs/rules/reflected-xss-response.md) | low | An HTML response reflects request data without recognized escaping. |
1215
+ | <a id="regex-catastrophic-backtracking"></a>[`regex-catastrophic-backtracking`](docs/rules/regex-catastrophic-backtracking.md) | high | A regular expression that can backtrack exponentially or in polynomial time runs on request input. |
1216
+ | <a id="regex-from-input"></a>[`regex-from-input`](docs/rules/regex-from-input.md) | medium | Request input supplies a regular expression pattern without recognized escaping. |
1217
+ | <a id="secret-compared-non-constant-time"></a>[`secret-compared-non-constant-time`](docs/rules/secret-compared-non-constant-time.md) | medium | A secret is compared with an operation that can vary in timing with its contents. |
1218
+ | <a id="secret-in-log"></a>[`secret-in-log`](docs/rules/secret-in-log.md) | high | A log statement can expose a credential, token, or other secret. |
1219
+ | <a id="secret-in-url-query"></a>[`secret-in-url-query`](docs/rules/secret-in-url-query.md) | medium | A password, token or API key is passed in a URL query string. |
1220
+ | <a id="sequelize-dynamic-query-text"></a>[`sequelize-dynamic-query-text`](docs/rules/sequelize-dynamic-query-text.md) | critical | Dynamic SQL text reaches Sequelize without parameter binding. |
1221
+ | <a id="server-action-missing-auth"></a>[`server-action-missing-auth`](docs/rules/server-action-missing-auth.md) | high | An exported Next.js Server Action performs work without verifying authentication or session state. |
1222
+ | <a id="ssrf-redirect-bypass"></a>[`ssrf-redirect-bypass`](docs/rules/ssrf-redirect-bypass.md) | high | An outbound HTTP request with a dynamic URL does not disable redirects, allowing SSRF allowlist bypasses. |
1223
+ | <a id="ssrf-request-url"></a>[`ssrf-request-url`](docs/rules/ssrf-request-url.md) | high | Request data controls the destination of a server-side network request. |
1224
+ | <a id="storage-object-public-acl"></a>[`storage-object-public-acl`](docs/rules/storage-object-public-acl.md) | high | A storage upload makes the object publicly readable. |
1225
+ | <a id="template-autoescape-disabled"></a>[`template-autoescape-disabled`](docs/rules/template-autoescape-disabled.md) | medium | A template engine is configured to render values without HTML escaping. |
1226
+ | <a id="template-injection"></a>[`template-injection`](docs/rules/template-injection.md) | critical | Request data is interpreted as template source rather than a template value. |
1227
+ | <a id="tls-verification-disabled"></a>[`tls-verification-disabled`](docs/rules/tls-verification-disabled.md) | high | A TLS client skips certificate or server hostname verification. |
1228
+ | <a id="typeorm-dynamic-query-text"></a>[`typeorm-dynamic-query-text`](docs/rules/typeorm-dynamic-query-text.md) | critical | A dynamic SQL fragment reaches TypeORM without parameter binding. |
1229
+ | <a id="upload-client-filename"></a>[`upload-client-filename`](docs/rules/upload-client-filename.md) | medium | A file upload is stored under the original name supplied by the client. |
1230
+ | <a id="vm-sandbox-escape"></a>[`vm-sandbox-escape`](docs/rules/vm-sandbox-escape.md) | critical | Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE. |
1231
+ | <a id="vue-v-html-unsanitized"></a>[`vue-v-html-unsanitized`](docs/rules/vue-v-html-unsanitized.md) | high | A Vue render function binds unsanitized dynamic HTML to innerHTML. |
1232
+ | <a id="weak-password-hash"></a>[`weak-password-hash`](docs/rules/weak-password-hash.md) | high | A password is hashed with an algorithm unsuitable for password storage. |
1233
+ | <a id="xml-external-entities"></a>[`xml-external-entities`](docs/rules/xml-external-entities.md) | medium | An XML parser allows processing of external entities. |
1234
+ | <a id="zip-slip-extraction"></a>[`zip-slip-extraction`](docs/rules/zip-slip-extraction.md) | high | An archive entry controls an extraction path without a recognized containment check. |
1235
+
1236
+ <!-- loadwise:rules:end -->
1238
1237
 
1239
1238
  The SQL rules report text assembled from a runtime value. When a part of that text traces to request data the finding is default and names the source; when no part does, it is contextual, because the value is usually an internal schema or table name. Every injection rule other than the SQL rules reports only values traced to request data.
1240
1239
 
@@ -1248,19 +1247,23 @@ Example: `pool.query('SELECT * FROM orders ORDER BY ' + req.query.sort)` reports
1248
1247
 
1249
1248
  `npx loadwise sec polyglot src/` accepts directories or individual `.py`, `.go`, `.java`, `.cs` and `.rs` files. It uses the optional ast-grep native binary and its syntax-tree patterns. These are syntactic patterns without taint tracking, so each finding is a review prompt: confirm that untrusted input can reach the call. They are not `--ignore` rule ids of the TypeScript source checks. [ast-grep](https://ast-grep.github.io/)
1250
1249
 
1251
- | Rule | What to review |
1252
- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
1253
- | <a id="csharp-process-start"></a>`csharp-process-start` | `Process.Start` launches an external process. Validate inputs and use `ProcessStartInfo` with `ArgumentList`. |
1254
- | <a id="csharp-ef-from-sql-raw"></a>`csharp-ef-from-sql-raw` | `FromSqlRaw` or `ExecuteSqlRaw` receives a concatenated or interpolated string. Use `FromSqlInterpolated` or bind parameters. |
1255
- | <a id="go-exec-command-shell"></a>`go-exec-command-shell` | `exec.Command` invokes a shell. Execute the target binary directly with explicit arguments. |
1256
- | <a id="go-sql-sprintf-injection"></a>`go-sql-sprintf-injection` | SQL text is formatted with `fmt.Sprintf`. Use parameterized queries with placeholders. |
1257
- | <a id="java-runtime-exec"></a>`java-runtime-exec` | `Runtime.getRuntime().exec` runs an OS command. Use `ProcessBuilder` with an explicit argument array. |
1258
- | <a id="java-sql-string-concat"></a>`java-sql-string-concat` | A SQL query is built by string concatenation. Use `PreparedStatement` with bound parameters. |
1259
- | <a id="python-insecure-deserialization"></a>`python-insecure-deserialization` | `pickle` or `marshal` deserializes data that may be untrusted. Use `json` or a schema-validated format. |
1260
- | <a id="python-unsafe-yaml-load"></a>`python-unsafe-yaml-load` | `yaml.load` without `SafeLoader` can construct arbitrary objects. Use `yaml.safe_load`. |
1261
- | <a id="python-subprocess-shell-true"></a>`python-subprocess-shell-true` | `subprocess` with `shell=True` or `os.system` passes input through a shell. Pass an argument list with `shell=False`. |
1262
- | <a id="rust-command-shell"></a>`rust-command-shell` | `Command::new("sh")` or `Command::new("bash")` spawns a shell. Invoke the executable directly with `.arg()`. |
1263
- | <a id="rust-unsafe-raw-pointer-deref"></a>`rust-unsafe-raw-pointer-deref` | A raw pointer is dereferenced in an `unsafe` block. Verify pointer validity and alignment or use safe abstractions. |
1250
+ <!-- loadwise:rules:start checker=security group=polyglot-source-checks -->
1251
+
1252
+ | Rule | Impact | What it flags |
1253
+ | ------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------------- |
1254
+ | <a id="csharp-ef-from-sql-raw"></a>[`csharp-ef-from-sql-raw`](docs/rules/csharp-ef-from-sql-raw.md) | high | FromSqlRaw or ExecuteSqlRaw receives a concatenated or interpolated string, risking SQL injection. |
1255
+ | <a id="csharp-process-start"></a>[`csharp-process-start`](docs/rules/csharp-process-start.md) | medium | Process.Start launches an external process and risks command injection with untrusted arguments. |
1256
+ | <a id="go-exec-command-shell"></a>[`go-exec-command-shell`](docs/rules/go-exec-command-shell.md) | high | exec.Command invokes a shell, which risks command injection. |
1257
+ | <a id="go-sql-sprintf-injection"></a>[`go-sql-sprintf-injection`](docs/rules/go-sql-sprintf-injection.md) | high | SQL text formatted with fmt.Sprintf risks SQL injection. |
1258
+ | <a id="java-runtime-exec"></a>[`java-runtime-exec`](docs/rules/java-runtime-exec.md) | medium | Runtime.getRuntime().exec runs an OS command and risks command injection with untrusted arguments. |
1259
+ | <a id="java-sql-string-concat"></a>[`java-sql-string-concat`](docs/rules/java-sql-string-concat.md) | high | A SQL query built by string concatenation risks SQL injection. |
1260
+ | <a id="python-insecure-deserialization"></a>[`python-insecure-deserialization`](docs/rules/python-insecure-deserialization.md) | high | pickle or marshal deserialization of untrusted data can execute arbitrary code. |
1261
+ | <a id="python-subprocess-shell-true"></a>[`python-subprocess-shell-true`](docs/rules/python-subprocess-shell-true.md) | high | subprocess with shell=True or os.system passes input through a shell, risking command injection. |
1262
+ | <a id="python-unsafe-yaml-load"></a>[`python-unsafe-yaml-load`](docs/rules/python-unsafe-yaml-load.md) | high | yaml.load without SafeLoader can construct arbitrary Python objects. |
1263
+ | <a id="rust-command-shell"></a>[`rust-command-shell`](docs/rules/rust-command-shell.md) | high | Command::new("sh") or Command::new("bash") spawns a shell and risks command injection. |
1264
+ | <a id="rust-unsafe-raw-pointer-deref"></a>[`rust-unsafe-raw-pointer-deref`](docs/rules/rust-unsafe-raw-pointer-deref.md) | medium | A raw pointer dereference in an unsafe block bypasses Rust memory safety guarantees. |
1265
+
1266
+ <!-- loadwise:rules:end -->
1264
1267
 
1265
1268
  ## Dependency checks
1266
1269
 
@@ -1268,98 +1271,18 @@ Example: `pool.query('SELECT * FROM orders ORDER BY ' + req.query.sort)` reports
1268
1271
 
1269
1272
  The network is opt-in: `loadwise sec --online` and `loadwise check --online` add these findings to their security report, and without `--online` they print one note that dependency checks were skipped.
1270
1273
 
1271
- | Rule | What to review |
1272
- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1273
- | <a id="dependency-known-vulnerability"></a>`dependency-known-vulnerability` | A locked package version has published advisories. One finding per package and version lists the advisory ids, the highest severity, the fixed version and the fix: `npm install pkg@fixed` for a direct dependency, or an overrides or resolutions entry for a transitive one. Development-only dependencies are contextual. |
1274
+ <!-- loadwise:rules:start checker=security group=dependency-checks -->
1275
+
1276
+ | Rule | Impact | What it flags |
1277
+ | --------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------ |
1278
+ | <a id="dependency-known-vulnerability"></a>[`dependency-known-vulnerability`](docs/rules/dependency-known-vulnerability.md) | medium | A resolved dependency version is listed in a published vulnerability advisory. |
1279
+
1280
+ <!-- loadwise:rules:end -->
1274
1281
 
1275
1282
  ## Security impact levels
1276
1283
 
1277
1284
  `--min-impact` sets the minimum level to report. Dependency findings use the advisory severity.
1278
1285
 
1279
- | Rule | Impact |
1280
- | ----------------------------------- | ------------------------------------------- |
1281
- | `pg-dynamic-query-text` | medium |
1282
- | `prisma-scope-unverified` | high |
1283
- | `drizzle-scope-unverified` | high |
1284
- | `code-injection` | critical |
1285
- | `command-injection` | critical |
1286
- | `drizzle-sql-raw-dynamic` | critical |
1287
- | `knex-raw-dynamic-text` | critical |
1288
- | `mysql-dynamic-query-text` | critical |
1289
- | `nosql-operator-injection` | high |
1290
- | `prisma-raw-unsafe-dynamic` | critical |
1291
- | `regex-from-input` | medium |
1292
- | `regex-catastrophic-backtracking` | high |
1293
- | `sequelize-dynamic-query-text` | critical |
1294
- | `template-injection` | critical |
1295
- | `typeorm-dynamic-query-text` | critical |
1296
- | `open-redirect` | medium |
1297
- | `path-traversal` | high |
1298
- | `ssrf-request-url` | high |
1299
- | `upload-client-filename` | medium |
1300
- | `zip-slip-extraction` | high |
1301
- | `bcrypt-low-cost` | medium |
1302
- | `hardcoded-secret` | critical |
1303
- | `insecure-cipher` | medium |
1304
- | `insecure-random-for-secret` | high |
1305
- | `jwt-decode-for-auth` | high |
1306
- | `jwt-none-algorithm` | critical |
1307
- | `jwt-sign-without-expiry` | medium |
1308
- | `jwt-verify-without-algorithms` | high |
1309
- | `secret-compared-non-constant-time` | medium |
1310
- | `tls-verification-disabled` | high |
1311
- | `weak-password-hash` | high |
1312
- | `plaintext-password-storage` | critical |
1313
- | `cookie-missing-security-flags` | high |
1314
- | `cors-credentials-any-origin` | high |
1315
- | `cors-origin-regex-unanchored` | medium |
1316
- | `error-stack-in-response` | medium |
1317
- | `graphql-introspection-enabled` | medium |
1318
- | `mass-assignment` | high |
1319
- | `nest-validation-without-whitelist` | medium |
1320
- | `prototype-pollution` | high |
1321
- | `reflected-xss-response` | low |
1322
- | `secret-in-log` | high |
1323
- | `template-autoescape-disabled` | medium |
1324
- | `xml-external-entities` | medium |
1325
- | `password-hash-in-response` | high |
1326
- | `storage-object-public-acl` | high |
1327
- | `secret-in-url-query` | medium |
1328
- | `auth-route-without-rate-limit` | medium |
1329
- | `graphql-query-depth-unbounded` | medium |
1330
- | `database-error-in-response` | medium |
1331
- | `dom-xss-sink` | high |
1332
- | `react-dangerously-set-inner-html` | high |
1333
- | `angular-bypass-security-trust` | high |
1334
- | `vue-v-html-unsanitized` | high |
1335
- | `frontend-storage-secret-token` | medium |
1336
- | `postmessage-missing-origin-check` | medium |
1337
- | `express-missing-helmet` | low |
1338
- | `dependency-known-vulnerability` | Advisory severity (medium when unavailable) |
1339
- | `committed-secret` | critical |
1340
- | `compose-hardcoded-secret` | high |
1341
- | `dockerfile-add-remote-url` | medium |
1342
- | `dockerfile-runs-as-root` | medium |
1343
- | `dockerfile-secret-in-build` | high |
1344
- | `dockerfile-unpinned-base-image` | low |
1345
- | `server-action-missing-auth` | high |
1346
- | `ssrf-redirect-bypass` | high |
1347
- | `vm-sandbox-escape` | critical |
1348
- | `jwt-weak-secret-literal` | high |
1349
- | `graphql-batching-unbounded` | medium |
1350
- | `express-cookie-auth-missing-csrf` | high |
1351
- | `csharp-process-start` | medium |
1352
- | `csharp-ef-from-sql-raw` | high |
1353
- | `go-exec-command-shell` | high |
1354
- | `go-sql-sprintf-injection` | high |
1355
- | `java-runtime-exec` | medium |
1356
- | `java-sql-string-concat` | high |
1357
- | `python-insecure-deserialization` | high |
1358
- | `python-unsafe-yaml-load` | high |
1359
- | `python-subprocess-shell-true` | high |
1360
- | `rust-command-shell` | high |
1361
- | `rust-unsafe-raw-pointer-deref` | medium |
1362
-
1363
1286
  ## Project-defined row scopes
1364
1287
 
1365
1288
  Row-scope checks read `prismaScopes` and `drizzleScopes` from the `performance` section of `loadwise.config.json`, found the same way as for the performance checker (see [Project-defined access policy](#project-defined-access-policy)). Every other rule runs without a scope policy. Row-scope checks start when the project identifies the existing model or table, its scoped property, and the helper that supplies an authorized scalar. Columns such as `tenantId`, `organizationId` and `workspace_id` have no special meaning to the checker on their own. Database mappings can keep the original storage column name. [Prisma database mapping](https://www.prisma.io/docs/orm/prisma-schema/data-model/database-mapping) · [Drizzle schema declarations](https://orm.drizzle.team/docs/sql-schema-declaration)
@@ -1389,33 +1312,25 @@ npx loadwise a11y --fix --only <id> # apply one generated fix
1389
1312
 
1390
1313
  ## Rules
1391
1314
 
1392
- | Rule | What to review | Fix |
1393
- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
1394
- | <a id="a11y-img-missing-alt"></a>`a11y-img-missing-alt` | Review whether the image is informative, which needs descriptive alt text, or decorative, which needs `alt=""`. | Manual |
1395
- | <a id="a11y-button-missing-type"></a>`a11y-button-missing-type` | A button inside a form (or tied to one with `form=`) has no `type`, so it submits. Review whether it should submit (`type="submit"`) or only run a click handler (`type="button"`). | Automatic (review) |
1396
- | <a id="a11y-clickable-non-interactive"></a>`a11y-clickable-non-interactive` | Review whether a `<button>` or `<a>` can replace the element, or whether it needs a role, `tabIndex` and key handler. Handlers that only stop propagation are accepted. | Manual |
1397
- | <a id="a11y-invalid-aria"></a>`a11y-invalid-aria` | Review the misspelled ARIA attribute or role against the WAI-ARIA names and use the suggested one. | Manual |
1398
- | <a id="a11y-missing-form-label"></a>`a11y-missing-form-label` | Review how the control is named: a wrapping `<label>`, a `<label for>` matching its id, or aria-label. A placeholder is not a label. | Manual |
1399
- | <a id="a11y-html-missing-lang"></a>`a11y-html-missing-lang` | Review which language the page is written in and set `lang` to it. | Manual |
1400
- | <a id="a11y-iframe-missing-title"></a>`a11y-iframe-missing-title` | Review what the embedded content is and give the iframe a `title` that says so. | Manual |
1401
- | <a id="a11y-positive-tabindex"></a>`a11y-positive-tabindex` | Review whether the focus order can come from the markup order, then use `tabIndex` 0 or -1. | Manual |
1402
- | <a id="a11y-viewport-zoom-disabled"></a>`a11y-viewport-zoom-disabled` | Review whether the zoom limit is needed. Remove `user-scalable=no` and keep maximum-scale at 2 or more. | Manual |
1315
+ <!-- loadwise:rules:start checker=accessibility group=rules -->
1316
+
1317
+ | Rule | Impact | What it flags |
1318
+ | --------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
1319
+ | <a id="a11y-button-missing-type"></a>[`a11y-button-missing-type`](docs/rules/a11y-button-missing-type.md) | medium | A button inside a form has no type, so it submits the form even when it only meant to run a handler. |
1320
+ | <a id="a11y-clickable-non-interactive"></a>[`a11y-clickable-non-interactive`](docs/rules/a11y-clickable-non-interactive.md) | high | A click handler sits on a non-interactive element without a role and keyboard support, so keyboard users cannot activate it. |
1321
+ | <a id="a11y-html-missing-lang"></a>[`a11y-html-missing-lang`](docs/rules/a11y-html-missing-lang.md) | medium | The html element has no lang attribute, so screen readers guess the pronunciation. |
1322
+ | <a id="a11y-iframe-missing-title"></a>[`a11y-iframe-missing-title`](docs/rules/a11y-iframe-missing-title.md) | medium | An iframe has no title, so screen readers cannot say what it contains. |
1323
+ | <a id="a11y-img-missing-alt"></a>[`a11y-img-missing-alt`](docs/rules/a11y-img-missing-alt.md) | high | An image has no alt text, so screen readers announce its file name or nothing. |
1324
+ | <a id="a11y-invalid-aria"></a>[`a11y-invalid-aria`](docs/rules/a11y-invalid-aria.md) | high | An ARIA attribute or role is misspelled or invalid, so assistive technology ignores it. |
1325
+ | <a id="a11y-missing-form-label"></a>[`a11y-missing-form-label`](docs/rules/a11y-missing-form-label.md) | high | A form control has no label, so screen readers announce it without its purpose. |
1326
+ | <a id="a11y-positive-tabindex"></a>[`a11y-positive-tabindex`](docs/rules/a11y-positive-tabindex.md) | medium | A positive tabindex reorders keyboard focus away from the visual order. |
1327
+ | <a id="a11y-viewport-zoom-disabled"></a>[`a11y-viewport-zoom-disabled`](docs/rules/a11y-viewport-zoom-disabled.md) | high | The viewport meta tag disables zoom, so people with low vision cannot enlarge the page. |
1328
+
1329
+ <!-- loadwise:rules:end -->
1403
1330
 
1404
1331
  ## Impact levels
1405
1332
 
1406
- The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise a11y` and the accessibility section of `loadwise check` use this table.
1407
-
1408
- | Rule | Impact |
1409
- | -------------------------------- | ------ |
1410
- | `a11y-clickable-non-interactive` | high |
1411
- | `a11y-img-missing-alt` | high |
1412
- | `a11y-invalid-aria` | high |
1413
- | `a11y-missing-form-label` | high |
1414
- | `a11y-viewport-zoom-disabled` | high |
1415
- | `a11y-button-missing-type` | medium |
1416
- | `a11y-html-missing-lang` | medium |
1417
- | `a11y-iframe-missing-title` | medium |
1418
- | `a11y-positive-tabindex` | medium |
1333
+ The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise a11y` and the accessibility section of `loadwise check` use the impact levels in the rule index.
1419
1334
 
1420
1335
  # Developing locally
1421
1336