loadwise 0.6.2 → 0.8.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.
- package/README.md +175 -115
- package/dist/bin/loadwise.js +132 -67
- package/dist/lib/accessibility/analyze.js +5 -3
- package/dist/lib/accessibility/angular-inline.js +9 -11
- package/dist/lib/accessibility/angular-literal.js +39 -0
- package/dist/lib/accessibility/form-context.js +36 -0
- package/dist/lib/accessibility/frame-head.js +92 -0
- package/dist/lib/accessibility/frame-viewport.js +149 -0
- package/dist/lib/accessibility/frontend-detect.js +6 -5
- package/dist/lib/accessibility/jsx-elements.js +13 -3
- package/dist/lib/accessibility/markup-files.js +7 -2
- package/dist/lib/accessibility/rule-ids.js +3 -0
- package/dist/lib/accessibility/rules.js +128 -41
- package/dist/lib/accessibility/site-fixes/buttons.js +5 -1
- package/dist/lib/accessibility/template-attributes.js +5 -3
- package/dist/lib/accessibility/template-elements.js +25 -6
- package/dist/lib/accessibility/template-file.js +40 -25
- package/dist/lib/accessibility/usage.js +10 -2
- package/dist/lib/editor/accessibility-examples.js +6 -1
- package/dist/lib/editor/actions.js +46 -7
- package/dist/lib/editor/apply-fix.js +69 -4
- package/dist/lib/editor/configured-setup.js +63 -0
- package/dist/lib/editor/diagnostics.js +206 -17
- package/dist/lib/editor/dismissals.js +85 -26
- package/dist/lib/editor/editor-document.js +5 -2
- package/dist/lib/editor/editor-launcher.js +170 -0
- package/dist/lib/editor/fix-edits.js +19 -0
- package/dist/lib/editor/jetbrains-setup.js +53 -0
- package/dist/lib/editor/language-server.js +80 -24
- package/dist/lib/editor/managed-config.js +37 -0
- package/dist/lib/editor/native-setup.js +86 -0
- package/dist/lib/editor/perf-watch.js +8 -6
- package/dist/lib/editor/release-vsix.js +61 -0
- package/dist/lib/editor/reliability-examples.js +15 -0
- package/dist/lib/editor/scan-session.js +29 -8
- package/dist/lib/editor/server-commands.js +38 -9
- package/dist/lib/editor/setup-server.js +87 -0
- package/dist/lib/editor/setup-vim.js +63 -0
- package/dist/lib/editor/setup.js +131 -0
- package/dist/lib/editor/stdio-setup.js +6 -0
- package/dist/lib/editor/workspace-files.js +61 -7
- package/dist/lib/editor/workspace-paths.js +41 -1
- package/dist/lib/maintainability/analysis/analyze-source.js +1 -1
- package/dist/lib/maintainability/architecture/architecture.js +4 -4
- package/dist/lib/maintainability/cli/changed-lines.js +20 -2
- package/dist/lib/maintainability/cli/inputs.js +12 -3
- package/dist/lib/maintainability/cli.js +18 -5
- package/dist/lib/maintainability/entry-points/entry-points.js +44 -15
- package/dist/lib/maintainability/entry-points/html-entry-points.js +5 -1
- package/dist/lib/maintainability/examples.js +4 -0
- package/dist/lib/maintainability/quality/functions.js +9 -6
- package/dist/lib/maintainability/quality/limits.js +19 -0
- package/dist/lib/maintainability/quality/size-limits.js +8 -2
- package/dist/lib/maintainability/quality/stray-console.js +62 -1
- package/dist/lib/maintainability/quality/tsconfig-strict.js +2 -0
- package/dist/lib/maintainability/rule-ids.js +3 -0
- package/dist/lib/maintainability/scan-changed.js +4 -1
- package/dist/lib/maintainability/scan-worker.js +6 -2
- package/dist/lib/maintainability/scan.js +21 -8
- package/dist/lib/maintainability/site-fixes/unused-bindings.js +138 -3
- package/dist/lib/maintainability/unused/module-usage.js +43 -21
- package/dist/lib/maintainability/unused/unused-bindings.js +39 -4
- package/dist/lib/maintainability/unused/unused-modules.js +5 -10
- package/dist/lib/performance/analysis/source-inputs.js +7 -2
- package/dist/lib/performance/analysis/source-options.js +7 -6
- package/dist/lib/performance/analyze.js +16 -3
- package/dist/lib/performance/cli/changed-lines.js +8 -1
- package/dist/lib/performance/cli/cli-arguments.js +19 -8
- package/dist/lib/performance/cli/cli-output.js +4 -0
- package/dist/lib/performance/cli/cli-scan.js +21 -2
- package/dist/lib/performance/cli.js +16 -7
- package/dist/lib/performance/collections/memory-growth.js +55 -12
- package/dist/lib/performance/contracts/openapi.js +13 -4
- package/dist/lib/performance/datastores/pg-integrity.js +68 -22
- package/dist/lib/performance/datastores/pg-session-release.js +114 -0
- package/dist/lib/performance/datastores/pg-session-sql.js +144 -0
- package/dist/lib/performance/datastores/pooling.js +62 -3
- package/dist/lib/performance/datastores/redis.js +94 -18
- package/dist/lib/performance/datastores/session-store.js +2 -1
- package/dist/lib/performance/db/checks.js +19 -8
- package/dist/lib/performance/db/gateway.js +3 -1
- package/dist/lib/performance/db/plan-estimates.js +4 -4
- package/dist/lib/performance/engine/native-syntax.js +3 -0
- package/dist/lib/performance/engine/native.js +11 -7
- package/dist/lib/performance/evidence/plans.js +7 -5
- package/dist/lib/performance/evidence/traces.js +21 -1
- package/dist/lib/performance/frontend/angular-teardown.js +96 -0
- package/dist/lib/performance/frontend/effect-cleanup.js +148 -0
- package/dist/lib/performance/frontend/frontend-dom-perf.js +14 -2
- package/dist/lib/performance/frontend/frontend-helpers.js +1 -9
- package/dist/lib/performance/frontend/frontend-perf.js +149 -74
- package/dist/lib/performance/migrations/extract-code-sql.js +16 -4
- package/dist/lib/performance/migrations/extract-code.js +13 -5
- package/dist/lib/performance/migrations/extract-sql.js +82 -38
- package/dist/lib/performance/migrations/operations.js +56 -13
- package/dist/lib/performance/migrations/postgres-lock-timeout.js +52 -0
- package/dist/lib/performance/migrations/postgres-registry.js +127 -26
- package/dist/lib/performance/migrations/postgres-settings.js +78 -0
- package/dist/lib/performance/migrations/rules-postgres-add-column.js +3 -3
- package/dist/lib/performance/migrations/rules-postgres-shared.js +9 -0
- package/dist/lib/performance/migrations/rules-postgres.js +88 -39
- package/dist/lib/performance/orm/offset-pagination.js +6 -4
- package/dist/lib/performance/orm/prisma-aggregates.js +69 -18
- package/dist/lib/performance/orm/unbounded-list-chain.js +29 -0
- package/dist/lib/performance/orm/unbounded-list-queries.js +18 -13
- package/dist/lib/performance/polyglot.js +111 -14
- package/dist/lib/performance/projects.js +3 -3
- package/dist/lib/performance/query-loops/sequential-loops.js +1 -0
- package/dist/lib/performance/request/backend-mastery.js +151 -42
- package/dist/lib/performance/request/bulk-listener-registration.js +111 -0
- package/dist/lib/performance/request/fastify-receivers.js +93 -0
- package/dist/lib/performance/request/fresh-loop-socket.js +103 -0
- package/dist/lib/performance/request/mongoose-lean.js +298 -46
- package/dist/lib/performance/request/node-event-listener-leak.js +99 -5
- package/dist/lib/performance/request/phase5-ast.js +6 -7
- package/dist/lib/performance/request/phase5-rules.js +204 -23
- package/dist/lib/performance/request/request-handlers.js +120 -23
- package/dist/lib/performance/request/sql-select-star.js +150 -0
- package/dist/lib/performance/request/unbounded-promise-all.js +54 -29
- package/dist/lib/performance/request/upload-limits.js +5 -1
- package/dist/lib/performance/site-fix.js +4 -4
- package/dist/lib/performance/site-fixes/backend-mastery-fixes.js +298 -16
- package/dist/lib/performance/site-fixes/collection-existence.js +2 -1
- package/dist/lib/performance/site-fixes/collections.js +1 -2
- package/dist/lib/performance/site-fixes/frontend-fixes.js +358 -14
- package/dist/lib/performance/site-fixes/helpers.js +3 -4
- package/dist/lib/performance/site-fixes/integrity.js +2 -4
- package/dist/lib/performance/site-fixes/migration-context.js +8 -1
- package/dist/lib/performance/site-fixes/migration-lock-rules.js +66 -30
- package/dist/lib/performance/site-fixes/prisma-aggregates.js +29 -9
- package/dist/lib/performance/site-fixes/small-rewrites.js +168 -10
- package/dist/lib/performance/site-fixes/sync-calls.js +14 -12
- package/dist/lib/performance/site-fixes/upload-limits.js +13 -7
- package/dist/lib/performance/sql/mysql-tokens.js +38 -12
- package/dist/lib/reliability/boundary-access.js +114 -57
- package/dist/lib/reliability/react-bugs.js +29 -7
- package/dist/lib/reliability/resource-leak-intervals.js +258 -0
- package/dist/lib/reliability/resource-leaks.js +209 -195
- package/dist/lib/reliability/rule-ids.js +10 -1
- package/dist/lib/reliability/site-fixes/resource-leaks.js +16 -1
- package/dist/lib/reliability/swallowed-errors.js +107 -21
- package/dist/lib/reliability/test-cleanup-after-await.js +92 -18
- package/dist/lib/reliability/usage.js +16 -5
- package/dist/lib/reliability/walk.js +3 -2
- package/dist/lib/security/auth-crypto/hashing.js +24 -8
- package/dist/lib/security/auth-crypto/jwt.js +21 -6
- package/dist/lib/security/auth-crypto/secrets.js +44 -1
- package/dist/lib/security/auth-crypto/shared.js +3 -1
- package/dist/lib/security/auth-crypto/signing-algorithm.js +79 -0
- package/dist/lib/security/auth-crypto/transport-and-ciphers.js +85 -1
- package/dist/lib/security/cli.js +21 -6
- package/dist/lib/security/cookie-credentials.js +115 -0
- package/dist/lib/security/cookie-csrf.js +241 -0
- package/dist/lib/security/deps/advisory.js +50 -109
- package/dist/lib/security/deps/cli.js +1 -1
- package/dist/lib/security/deps/cvss-score.js +14 -0
- package/dist/lib/security/deps/fixed-version.js +97 -0
- package/dist/lib/security/deps/lockfiles.js +135 -74
- package/dist/lib/security/deps/osv.js +11 -3
- package/dist/lib/security/deps/scan.js +47 -20
- package/dist/lib/security/deps/yarn-lock.js +158 -0
- package/dist/lib/security/examples/injection.cjs +4 -0
- package/dist/lib/security/exposure/cookies.js +17 -2
- package/dist/lib/security/exposure/cors-origin-regex.js +2 -3
- package/dist/lib/security/exposure/frontend-security.js +21 -14
- package/dist/lib/security/exposure/jsx-url.js +18 -33
- package/dist/lib/security/exposure/logging.js +49 -10
- package/dist/lib/security/exposure/prototype-pollution.js +126 -56
- package/dist/lib/security/exposure/react-html.js +26 -0
- package/dist/lib/security/exposure/reflected-xss.js +34 -5
- package/dist/lib/security/files/compose.js +126 -1
- package/dist/lib/security/files/dockerfile.js +62 -4
- package/dist/lib/security/files/index.js +1 -1
- package/dist/lib/security/injection/command.js +46 -18
- package/dist/lib/security/injection/index.js +2 -0
- package/dist/lib/security/injection/ldap.js +86 -0
- package/dist/lib/security/injection/nosql.js +28 -4
- package/dist/lib/security/injection/redos.js +1 -1
- package/dist/lib/security/injection/rule-ids.js +1 -0
- package/dist/lib/security/injection/shared.js +5 -1
- package/dist/lib/security/injection/sql.js +28 -13
- package/dist/lib/security/lexical-declaration.js +113 -0
- package/dist/lib/security/pg-dynamic-query.js +28 -1
- package/dist/lib/security/pg-identifier-guards.js +107 -3
- package/dist/lib/security/phase5-rules.js +26 -135
- package/dist/lib/security/polyglot.js +2 -2
- package/dist/lib/security/redirect-settings.js +98 -0
- package/dist/lib/security/request-forgery/open-redirect.js +18 -5
- package/dist/lib/security/request-forgery/path-traversal.js +84 -6
- package/dist/lib/security/request-forgery/shared.js +1 -7
- package/dist/lib/security/request-forgery/ssrf.js +176 -14
- package/dist/lib/security/rule-descriptions.js +5 -1
- package/dist/lib/security/rule-ids.js +7 -0
- package/dist/lib/security/site-fixes/auth-crypto.js +5 -78
- package/dist/lib/security/site-fixes/exposure.js +21 -3
- package/dist/lib/security/site-fixes/files.js +11 -13
- package/dist/lib/security/site-fixes/frontend-security-fixes.js +2 -2
- package/dist/lib/security/site-fixes/injection.js +17 -4
- package/dist/lib/security/site-fixes/jwt.js +1 -20
- package/dist/lib/security/site-fixes/request-forgery.js +37 -29
- package/dist/lib/security/taint/binding-inputs.js +236 -0
- package/dist/lib/security/taint/filename-guard.js +45 -45
- package/dist/lib/security/taint/guards.js +14 -8
- package/dist/lib/security/taint/index.js +126 -154
- package/dist/lib/security/taint/propagate.js +43 -9
- package/dist/lib/security/taint/record-writes.js +161 -0
- package/dist/lib/security/taint/resolution-cache.js +13 -7
- package/dist/lib/security/taint/sanitizers.js +89 -5
- package/dist/lib/security/taint/trace-nodes.js +61 -0
- package/dist/lib/security/taint/validators.js +89 -9
- package/dist/lib/shared/agent/agent-init.js +28 -5
- package/dist/lib/shared/agent/agent-prompt.js +74 -0
- package/dist/lib/shared/agent/agent-session.js +6 -1
- package/dist/lib/shared/agent/agent-verify.js +58 -11
- package/dist/lib/shared/agent/git-hook.js +17 -6
- package/dist/lib/shared/agent/review-delivery.js +1 -1
- package/dist/lib/shared/agent/review-mcp.js +8 -2
- package/dist/lib/shared/analysis/ast-semantics.js +2 -2
- package/dist/lib/shared/analysis/scan-cache.js +99 -14
- package/dist/lib/shared/check.js +172 -20
- package/dist/lib/shared/cli-dispatch.js +17 -0
- package/dist/lib/shared/config.js +27 -10
- package/dist/lib/shared/explain.js +1 -1
- package/dist/lib/shared/fix/fix-convergence.js +19 -31
- package/dist/lib/shared/fix/fix-handoff.js +16 -11
- package/dist/lib/shared/fix/fix-imports.js +4 -162
- package/dist/lib/shared/fix/fix-presentation-comments.js +23 -9
- package/dist/lib/shared/fix/fix-presentation-prettier.js +1 -46
- package/dist/lib/shared/fix/fix-presentation-rows.js +45 -1
- package/dist/lib/shared/fix/fix-presentation.js +9 -6
- package/dist/lib/shared/fix/fix-safety.js +32 -1
- package/dist/lib/shared/fix/fix-scope.js +82 -0
- package/dist/lib/shared/fix/fix-terminal.js +28 -1
- package/dist/lib/shared/fix/fix-typecheck.js +8 -4
- package/dist/lib/shared/fix/import-text-edits.js +148 -0
- package/dist/lib/shared/fix/project-file-access.js +17 -26
- package/dist/lib/shared/fix/read-fix-text.js +20 -0
- package/dist/lib/shared/fix.js +241 -104
- package/dist/lib/shared/formats/finding-location.js +4 -1
- package/dist/lib/shared/formats/github.js +3 -3
- package/dist/lib/shared/formats/sarif.js +9 -3
- package/dist/lib/shared/report-fp.js +97 -0
- package/dist/lib/shared/reporting/automatic-fix-signal.js +10 -0
- package/dist/lib/shared/reporting/baseline.js +7 -5
- package/dist/lib/shared/reporting/check-text.js +50 -0
- package/dist/lib/shared/reporting/pillars.js +54 -19
- package/dist/lib/shared/reporting/source-report.js +3 -0
- package/dist/lib/shared/system/atomic-write.js +5 -2
- package/dist/lib/shared/system/glob.js +34 -8
- package/dist/lib/shared/system/sentry.js +222 -0
- package/dist/lib/shared/system/shell-argument.js +5 -1
- package/dist/lib/shared/system/terminal-safe.js +3 -2
- package/dist/lib/shared/system/terminal-style.js +131 -0
- package/dist/lib/shared/workspaces.js +15 -3
- package/docs/assets/cli-workflow.gif +0 -0
- package/integrations/sublime/plugin.py +22 -0
- package/integrations/zed/Cargo.lock +845 -0
- package/integrations/zed/Cargo.toml +11 -0
- package/integrations/zed/extension.toml +11 -0
- package/integrations/zed/src/lib.rs +25 -0
- package/package.json +15 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/loadwise.md +11 -6
- package/plugin/hooks/check-edited-file.mjs +27 -5
- package/polyglot/performance/rules/csharp.yml +34 -5
- package/polyglot/performance/rules/java.yml +24 -1
- package/polyglot/performance/rules/python.yml +74 -2
- package/polyglot/performance/sgconfig.yml +1 -0
- package/polyglot/reliability/rules/csharp.yml +12 -6
- package/polyglot/reliability/rules/go.yml +86 -6
- package/polyglot/reliability/rules/java.yml +22 -1
- package/polyglot/reliability/sgconfig.yml +1 -0
- package/polyglot/security/rules/go.yml +100 -22
- package/polyglot/security/rules/python.yml +74 -6
- package/polyglot/security/rules/rust.yml +65 -0
- package/polyglot/security/sgconfig.yml +1 -0
- package/schema/loadwise.config.schema.json +556 -76
- /package/polyglot/{performance/rules → shared-rules}/input.yml +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
id = "loadwise"
|
|
2
|
+
name = "Loadwise"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
schema_version = 1
|
|
5
|
+
authors = ["Ibrahim Hafez"]
|
|
6
|
+
description = "Loadwise diagnostics and code actions"
|
|
7
|
+
repository = "https://github.com/IbrahimHafez1/loadwise"
|
|
8
|
+
|
|
9
|
+
[language_servers.loadwise]
|
|
10
|
+
name = "Loadwise"
|
|
11
|
+
languages = ["JavaScript", "JSX", "TypeScript", "TSX", "HTML", "Vue.js", "Svelte", "Python", "Go", "Java", "CSharp", "Rust"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
use zed_extension_api as zed;
|
|
2
|
+
|
|
3
|
+
struct Loadwise;
|
|
4
|
+
|
|
5
|
+
impl zed::Extension for Loadwise {
|
|
6
|
+
fn new() -> Self {
|
|
7
|
+
Self
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
fn language_server_command(
|
|
11
|
+
&mut self,
|
|
12
|
+
_: &zed::LanguageServerId,
|
|
13
|
+
worktree: &zed::Worktree,
|
|
14
|
+
) -> zed::Result<zed::Command> {
|
|
15
|
+
let [command, cli]: [String; 2] = zed::serde_json::from_str(include_str!("../server.json"))
|
|
16
|
+
.map_err(|error| format!("Invalid Loadwise server configuration: {error}"))?;
|
|
17
|
+
Ok(zed::Command {
|
|
18
|
+
command,
|
|
19
|
+
args: vec![cli, "lsp".to_owned(), "--stdio".to_owned()],
|
|
20
|
+
env: worktree.shell_env(),
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
zed::register_extension!(Loadwise);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadwise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Local static analysis for TypeScript & JavaScript: catches N+1 queries, PostgreSQL pool leaks, unsafe migrations, unhandled async errors, and security/a11y bugs ESLint misses.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Ibrahim Hafez",
|
|
8
8
|
"repository": {
|
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
"dist/bin/",
|
|
66
66
|
"dist/lib/",
|
|
67
67
|
"dist/polyglot/",
|
|
68
|
+
"!dist/**/*.map",
|
|
69
|
+
"integrations/sublime/",
|
|
70
|
+
"integrations/zed/",
|
|
68
71
|
"lib/performance/vendor/",
|
|
69
72
|
"plugin/.claude-plugin/",
|
|
70
73
|
"plugin/commands/",
|
|
@@ -74,13 +77,15 @@
|
|
|
74
77
|
"polyglot/performance/",
|
|
75
78
|
"polyglot/reliability/",
|
|
76
79
|
"polyglot/security/",
|
|
80
|
+
"polyglot/shared-rules/",
|
|
77
81
|
"schema/",
|
|
78
82
|
"examples/",
|
|
83
|
+
"docs/assets/cli-workflow.gif",
|
|
79
84
|
"PERFORMANCE.md",
|
|
80
85
|
"LICENSE"
|
|
81
86
|
],
|
|
82
87
|
"engines": {
|
|
83
|
-
"node": ">=22"
|
|
88
|
+
"node": ">=22.13.0"
|
|
84
89
|
},
|
|
85
90
|
"scripts": {
|
|
86
91
|
"format": "prettier --cache --log-level warn --write .",
|
|
@@ -98,17 +103,23 @@
|
|
|
98
103
|
"bench:security": "node dist/bench/security.js",
|
|
99
104
|
"bench:traces": "node dist/bench/traces.js",
|
|
100
105
|
"bench:recall": "node dist/bench/recall/runner.js",
|
|
106
|
+
"bench:evidence": "node bench/evidence/runner.mjs",
|
|
107
|
+
"bench:holdout": "node bench/holdout/runner.mjs",
|
|
101
108
|
"build": "tsc -p tsconfig.json",
|
|
109
|
+
"build:sentry": "tsc -p tsconfig.sentry.json",
|
|
102
110
|
"changelog": "npm run build && node dist/scripts/changelog.js",
|
|
103
111
|
"docs:rules": "npm run build && node dist/scripts/rule-docs.js",
|
|
104
112
|
"pack:smoke": "npm run build && node dist/scripts/pack-smoke.js",
|
|
113
|
+
"editor:package": "tsc -p editor/tsconfig.package.json && node editor/package-vsix.mjs",
|
|
105
114
|
"clean": "node -e \"import('node:fs').then(fs=>import('node:path').then(p=>{const walk=d=>{if(!fs.existsSync(d))return;for(const e of fs.readdirSync(d,{withFileTypes:true})){const f=p.join(d,e.name);if(e.isDirectory()&&e.name!=='node_modules'&&!f.includes('vendor'))walk(f);else if((e.name.endsWith('.js')&&fs.existsSync(f.slice(0,-3)+'.ts'))||(e.name.endsWith('.cjs')&&fs.existsSync(f.slice(0,-4)+'.cts')))fs.unlinkSync(f);}};['bin','lib','plugin','polyglot','scripts','bench','test'].forEach(walk);fs.rmSync('.tsbuildinfo',{force:true});fs.rmSync('dist',{recursive:true,force:true});}))\"",
|
|
106
115
|
"prepack": "npm run build",
|
|
107
116
|
"prepare": "node -e \"import('node:child_process').then(c=>{c.execSync('git rev-parse --git-dir',{stdio:'ignore'});c.execSync('git config core.hooksPath hooks')}).catch(()=>{})\"",
|
|
108
117
|
"lint:fix": "oxlint --fix ."
|
|
109
118
|
},
|
|
110
119
|
"dependencies": {
|
|
120
|
+
"@turingpointde/cvss.js": "2.1.0",
|
|
111
121
|
"libpg-query": "18.3.0",
|
|
122
|
+
"semver": "7.8.6",
|
|
112
123
|
"typescript": "6.0.3",
|
|
113
124
|
"vscode-languageserver": "11.0.2",
|
|
114
125
|
"vscode-languageserver-textdocument": "1.0.16"
|
|
@@ -139,6 +150,7 @@
|
|
|
139
150
|
},
|
|
140
151
|
"devDependencies": {
|
|
141
152
|
"@types/node": "26.6.11",
|
|
153
|
+
"@types/semver": "7.8.0",
|
|
142
154
|
"oxlint": "1.95.0",
|
|
143
155
|
"prettier": "3.10.1"
|
|
144
156
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadwise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Runs the project's local loadwise checkers on each file Claude edits and sends findings back with their fix commands.",
|
|
5
5
|
"author": { "name": "Ibrahim Hafez" },
|
|
6
6
|
"homepage": "https://loadwise.mintlify.app/",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Check a project or fix its Loadwise findings in this session
|
|
3
|
-
argument-hint: "[directory] [--only perf,rel,maint,sec,a11y] [--staged] | fix [--yes|--all|--handoff] [performance reliability maintainability security accessibility]"
|
|
3
|
+
argument-hint: "[directory] [--only perf,rel,maint,sec,a11y] [--staged|--uncommitted] | fix [--dry-run|--apply|--yes|--all|--handoff] [--id id] [--uncommitted] [performance reliability maintainability security accessibility]"
|
|
4
4
|
allowed-tools: Bash(npx loadwise:*), Bash(node_modules/.bin/loadwise:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -12,13 +12,18 @@ On every run, review all in-scope findings, including changes already applied. R
|
|
|
12
12
|
|
|
13
13
|
Use `{"outcomes":[{"checker":"perf","id":"...","status":"verified","evidence":"..."}]}` for the decisions file, replacing the placeholders with actual findings and evidence. Supported statuses are `fixed`, `verified`, `intentional`, `false-positive` and `deferred`. In a detected agent session or an initialized project add `--save` to retain the decisions locally for the next agent unless the user requested no persistence.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Explicit flags select the matching CLI operation. Handle these requests before the agent-guided edit workflow below. Pass through the supplied directory, checker selection, configuration, workspace, rule and Git filters, including `--uncommitted`.
|
|
16
|
+
|
|
17
|
+
- For any `fix --dry-run` or explicit preview request, run the requested fix with `--dry-run`, including when combined with `--apply`, `--yes`, `--all` or `--id`. Show the proposed edits and stop. Leave source files untouched and treat the printed apply command as information for the user.
|
|
18
|
+
- For `fix --handoff`, show the read-only brief and stop.
|
|
19
|
+
- For `fix --apply`, `fix --yes`, `fix --all` or an explicit `--id` selection, record existing working changes and run the requested operation with its supplied scope. Capture the applied hunks and outstanding findings with `--json` when compatible with the requested output. Review the actual changes using steps 5 and 6 below. When manual findings remain, use the printed scoped handoff command. Only edit manual findings if the user requested that work.
|
|
20
|
+
- If the CLI rejects a flag combination, report the error and stop.
|
|
21
|
+
|
|
22
|
+
For the agent-guided `/loadwise fix [checker names]` workflow, including a scope such as `--uncommitted`, review findings before choosing edits.
|
|
16
23
|
|
|
17
24
|
1. Record existing working changes and start with a read-only JSON scan. For example, `fix performance security` starts with `loadwise check --only perf,sec --json`. Preserve the selected project, configuration, workspaces and changed-line filters. Restrict work to the named files or ids if provided.
|
|
18
25
|
2. Evaluate both generated and manual findings against the actual code, callers and tests. Inspect proposed diffs and notes and check their assumptions. Use a generated edit only when you can justify that exact change. Adapt a suggestion or implement a manual fix yourself when warranted. Keep intentional behavior and false positives with a reason. Defer unresolved decisions and continue with independent findings.
|
|
19
|
-
3. For
|
|
20
|
-
4. For changed-line requests, confirm every hunk fits the authorized range
|
|
26
|
+
3. For a unified project scan, apply confirmed IDs with `loadwise fix --only <checker> --id <id>` and the original directory, config, workspaces and Git filters. For direct file or checker-specific scans, use the scoped report's per-ID fix command with its original settings. Review-marked changes require individual approval unless already authorized.
|
|
27
|
+
4. For changed-line requests, confirm every hunk fits the authorized range and current working tree, including when using a checker-specific fix command. Leave the Git index untouched.
|
|
21
28
|
5. After any fix, including a command the user already ran, inspect every applied hunk against code, callers and tests. Use the before/after report or original diff/output, and rescan. Review applied, skipped, review-marked and manual findings even when none are manual. Correct only attributable changes in scope. Preserve pre-existing work, thresholds and baselines.
|
|
22
29
|
6. Run the affected tests or typecheck and repeat the scoped check. If an id shifted, match the rule, location and code. Report verified edits and reasons for remaining findings. If earlier evidence is unavailable, verify the current code and state which prior edits cannot be identified. Request the original diff/output only if needed.
|
|
23
|
-
|
|
24
|
-
Explicit flags select the matching CLI operation. For `fix --handoff` alone, show the brief and stop. For `fix --yes` or `fix --all`, record existing working changes, run the requested operation with its checker selection, and capture its before/after hunks and per-finding outcomes with `--json` when compatible with the requested output. Verify the actual changes using steps 5 and 6. When manual findings remain in scope, read a fresh `loadwise fix --handoff` for the same checkers. Respect a request limited to generated fixes.
|
|
@@ -73,8 +73,14 @@ function findingsFor(report, relativeFile, checkerCommand) {
|
|
|
73
73
|
.map((finding) => ({ ...finding, checkerCommand }));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function quoteTarget(relativeFile, platform = process.platform) {
|
|
77
|
+
const normalized = './' + relativeFile.split(path.sep).join('/');
|
|
78
|
+
if (platform === 'win32') return "'" + normalized.replaceAll("'", "''") + "'";
|
|
79
|
+
return "'" + normalized.replaceAll("'", "'\\''") + "'";
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
function formatFeedback(projectRoot, relativeFile, findings) {
|
|
77
|
-
const sourceArgument =
|
|
83
|
+
const sourceArgument = quoteTarget(relativeFile);
|
|
78
84
|
const lines = findings.map((finding) => {
|
|
79
85
|
const target = finding.checkerCommand === 'maint' ? '.' : sourceArgument;
|
|
80
86
|
const action = finding.fixable
|
|
@@ -104,6 +110,15 @@ function sourceFindings(local, relativeFile, safeRelativeFile, deadline) {
|
|
|
104
110
|
];
|
|
105
111
|
}
|
|
106
112
|
|
|
113
|
+
function hasInlineTemplate(filename) {
|
|
114
|
+
try {
|
|
115
|
+
return fs.readFileSync(filename, 'utf8').includes('@Component');
|
|
116
|
+
} catch {
|
|
117
|
+
// Each source checker can report its own coverage even if the optional template probe fails.
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
function main() {
|
|
108
123
|
const input = JSON.parse(readStdin());
|
|
109
124
|
const filePath = input?.tool_input?.file_path;
|
|
@@ -111,9 +126,13 @@ function main() {
|
|
|
111
126
|
const extension = path.extname(filePath).toLowerCase();
|
|
112
127
|
const isSourceFile = SOURCE_EXTENSIONS.has(extension);
|
|
113
128
|
if (!isSourceFile && !MARKUP_EXTENSIONS.has(extension)) return;
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
129
|
+
const suppliedRoot = path.resolve(input?.cwd ?? process.cwd());
|
|
130
|
+
const suppliedFile = path.resolve(suppliedRoot, filePath);
|
|
131
|
+
if (path.relative(suppliedRoot, suppliedFile).split(path.sep).includes('node_modules')) return;
|
|
132
|
+
// The client can send the folder and the edited file through different spellings of one path.
|
|
133
|
+
const workspaceRoot = fs.realpathSync.native(suppliedRoot);
|
|
134
|
+
const absoluteFile = fs.realpathSync.native(suppliedFile);
|
|
135
|
+
if (path.relative(workspaceRoot, absoluteFile).split(path.sep).includes('node_modules')) return;
|
|
117
136
|
const local = findLocalBinary(path.dirname(absoluteFile), workspaceRoot);
|
|
118
137
|
if (!local) return;
|
|
119
138
|
const relativeFile = path.relative(local.projectRoot, absoluteFile);
|
|
@@ -127,9 +146,12 @@ function main() {
|
|
|
127
146
|
const parsedTimeout = Number(process.env.LOADWISE_HOOK_TIMEOUT_MS);
|
|
128
147
|
const timeoutMs = Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : DEFAULT_TIMEOUT_MS;
|
|
129
148
|
const deadline = Date.now() + timeoutMs;
|
|
149
|
+
// Match the accessibility analyzer's inline Angular template prefilter for script extensions.
|
|
150
|
+
const checkAccessibility =
|
|
151
|
+
ACCESSIBILITY_EXTENSIONS.has(extension) || (isSourceFile && hasInlineTemplate(absoluteFile));
|
|
130
152
|
const findings = [
|
|
131
153
|
...(isSourceFile ? sourceFindings(local, relativeFile, safeRelativeFile, deadline) : []),
|
|
132
|
-
...(
|
|
154
|
+
...(checkAccessibility
|
|
133
155
|
? findingsFor(
|
|
134
156
|
runLoadwise(local.binary, ['a11y', safeRelativeFile, '--json'], local.projectRoot, deadline),
|
|
135
157
|
relativeFile,
|
|
@@ -9,8 +9,11 @@ rule:
|
|
|
9
9
|
all:
|
|
10
10
|
- any:
|
|
11
11
|
- pattern: new System.Text.RegularExpressions.Regex($PAT)
|
|
12
|
+
- pattern: new System.Text.RegularExpressions.Regex($PAT, $FLAGS)
|
|
12
13
|
- all:
|
|
13
|
-
-
|
|
14
|
+
- any:
|
|
15
|
+
- pattern: new Regex($PAT)
|
|
16
|
+
- pattern: new Regex($PAT, $FLAGS)
|
|
14
17
|
- inside:
|
|
15
18
|
kind: compilation_unit
|
|
16
19
|
stopBy: end
|
|
@@ -44,6 +47,27 @@ constraints:
|
|
|
44
47
|
any:
|
|
45
48
|
- kind: string_literal
|
|
46
49
|
- kind: verbatim_string_literal
|
|
50
|
+
FLAGS:
|
|
51
|
+
kind: argument
|
|
52
|
+
not:
|
|
53
|
+
any:
|
|
54
|
+
- has: { kind: invocation_expression, stopBy: end }
|
|
55
|
+
- has: { kind: conditional_expression, stopBy: end }
|
|
56
|
+
- has:
|
|
57
|
+
stopBy: end
|
|
58
|
+
kind: identifier
|
|
59
|
+
not:
|
|
60
|
+
any:
|
|
61
|
+
- regex: '^(System|Text|RegularExpressions)$'
|
|
62
|
+
- all:
|
|
63
|
+
- regex: '^RegexOptions$'
|
|
64
|
+
- inside:
|
|
65
|
+
kind: member_access_expression
|
|
66
|
+
field: expression
|
|
67
|
+
- inside:
|
|
68
|
+
kind: member_access_expression
|
|
69
|
+
field: name
|
|
70
|
+
has: { field: expression, regex: '(^|\.)RegexOptions$' }
|
|
47
71
|
|
|
48
72
|
---
|
|
49
73
|
id: csharp-string-concat-in-loop
|
|
@@ -86,10 +110,15 @@ rule:
|
|
|
86
110
|
context: 'class C { void M() { $ACC = $ACC + $LIT; } }'
|
|
87
111
|
selector: assignment_expression
|
|
88
112
|
- has:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
field: right
|
|
114
|
+
has:
|
|
115
|
+
stopBy:
|
|
116
|
+
any:
|
|
117
|
+
- kind: bracketed_argument_list
|
|
118
|
+
- kind: argument_list
|
|
119
|
+
any:
|
|
120
|
+
- kind: string_literal
|
|
121
|
+
- kind: interpolated_string_expression
|
|
93
122
|
- inside:
|
|
94
123
|
kind: method_declaration
|
|
95
124
|
stopBy: end
|
|
@@ -9,8 +9,11 @@ rule:
|
|
|
9
9
|
all:
|
|
10
10
|
- any:
|
|
11
11
|
- pattern: java.util.regex.Pattern.compile($PAT)
|
|
12
|
+
- pattern: java.util.regex.Pattern.compile($PAT, $FLAGS)
|
|
12
13
|
- all:
|
|
13
|
-
-
|
|
14
|
+
- any:
|
|
15
|
+
- pattern: Pattern.compile($PAT)
|
|
16
|
+
- pattern: Pattern.compile($PAT, $FLAGS)
|
|
14
17
|
- inside:
|
|
15
18
|
kind: program
|
|
16
19
|
stopBy: end
|
|
@@ -45,6 +48,26 @@ rule:
|
|
|
45
48
|
constraints:
|
|
46
49
|
PAT:
|
|
47
50
|
kind: string_literal
|
|
51
|
+
FLAGS:
|
|
52
|
+
not:
|
|
53
|
+
any:
|
|
54
|
+
- has: { kind: method_invocation, stopBy: end }
|
|
55
|
+
- has: { kind: ternary_expression, stopBy: end }
|
|
56
|
+
- kind: identifier
|
|
57
|
+
- has:
|
|
58
|
+
stopBy: end
|
|
59
|
+
kind: identifier
|
|
60
|
+
not:
|
|
61
|
+
any:
|
|
62
|
+
- regex: '^(java|util|regex|Pattern)$'
|
|
63
|
+
- inside:
|
|
64
|
+
kind: field_access
|
|
65
|
+
field: field
|
|
66
|
+
has: { field: object, pattern: Pattern }
|
|
67
|
+
- inside:
|
|
68
|
+
kind: field_access
|
|
69
|
+
field: field
|
|
70
|
+
has: { field: object, pattern: java.util.regex.Pattern }
|
|
48
71
|
|
|
49
72
|
---
|
|
50
73
|
id: java-string-concat-in-loop
|
|
@@ -53,11 +53,55 @@ rule:
|
|
|
53
53
|
- pattern: requests.patch($$$ARGS)
|
|
54
54
|
- pattern: requests.delete($$$ARGS)
|
|
55
55
|
- pattern: requests.request($$$ARGS)
|
|
56
|
+
- inside:
|
|
57
|
+
kind: module
|
|
58
|
+
stopBy: end
|
|
59
|
+
has:
|
|
60
|
+
kind: import_statement
|
|
61
|
+
stopBy: end
|
|
62
|
+
all:
|
|
63
|
+
- not:
|
|
64
|
+
has:
|
|
65
|
+
kind: aliased_import
|
|
66
|
+
has: { field: name, regex: '^requests$' }
|
|
67
|
+
- has:
|
|
68
|
+
kind: dotted_name
|
|
69
|
+
regex: '^requests$'
|
|
56
70
|
- inside:
|
|
57
71
|
kind: function_definition
|
|
58
72
|
regex: '^async\s'
|
|
59
73
|
stopBy:
|
|
60
74
|
kind: function_definition
|
|
75
|
+
- not:
|
|
76
|
+
inside:
|
|
77
|
+
kind: function_definition
|
|
78
|
+
stopBy: end
|
|
79
|
+
any:
|
|
80
|
+
- has:
|
|
81
|
+
field: parameters
|
|
82
|
+
has: { kind: identifier, regex: '^requests$', stopBy: end }
|
|
83
|
+
- has:
|
|
84
|
+
field: body
|
|
85
|
+
has:
|
|
86
|
+
kind: assignment
|
|
87
|
+
has:
|
|
88
|
+
field: left
|
|
89
|
+
any:
|
|
90
|
+
- kind: identifier
|
|
91
|
+
regex: '^requests$'
|
|
92
|
+
- any:
|
|
93
|
+
- kind: pattern_list
|
|
94
|
+
- kind: tuple_pattern
|
|
95
|
+
- kind: list_pattern
|
|
96
|
+
has: { kind: identifier, regex: '^requests$' }
|
|
97
|
+
stopBy:
|
|
98
|
+
any:
|
|
99
|
+
- kind: function_definition
|
|
100
|
+
- kind: class_definition
|
|
101
|
+
stopBy:
|
|
102
|
+
any:
|
|
103
|
+
- kind: function_definition
|
|
104
|
+
- kind: class_definition
|
|
61
105
|
|
|
62
106
|
---
|
|
63
107
|
id: python-blocking-sleep-in-async
|
|
@@ -92,7 +136,13 @@ labels:
|
|
|
92
136
|
message: This loop compiles a fixed regex for each iteration. Compile it once outside the loop and reuse the pattern.
|
|
93
137
|
rule:
|
|
94
138
|
all:
|
|
95
|
-
-
|
|
139
|
+
- any:
|
|
140
|
+
- pattern: re.compile($PAT)
|
|
141
|
+
- pattern: re.compile($PAT, flags=$FLAGS)
|
|
142
|
+
- all:
|
|
143
|
+
- pattern: re.compile($PAT, $FLAGS)
|
|
144
|
+
- not:
|
|
145
|
+
pattern: re.compile($PAT, $K=$V)
|
|
96
146
|
- inside:
|
|
97
147
|
kind: module
|
|
98
148
|
stopBy: end
|
|
@@ -115,6 +165,26 @@ rule:
|
|
|
115
165
|
constraints:
|
|
116
166
|
PAT:
|
|
117
167
|
kind: string
|
|
168
|
+
not:
|
|
169
|
+
has: { kind: interpolation, stopBy: end }
|
|
170
|
+
FLAGS:
|
|
171
|
+
not:
|
|
172
|
+
any:
|
|
173
|
+
- has: { kind: call, stopBy: end }
|
|
174
|
+
- has: { kind: conditional_expression, stopBy: end }
|
|
175
|
+
- all:
|
|
176
|
+
- kind: identifier
|
|
177
|
+
- not: { regex: '^re$' }
|
|
178
|
+
- has:
|
|
179
|
+
stopBy: end
|
|
180
|
+
kind: identifier
|
|
181
|
+
not:
|
|
182
|
+
any:
|
|
183
|
+
- regex: '^re$'
|
|
184
|
+
- inside:
|
|
185
|
+
kind: attribute
|
|
186
|
+
field: attribute
|
|
187
|
+
has: { field: object, kind: identifier, regex: '^re$' }
|
|
118
188
|
|
|
119
189
|
---
|
|
120
190
|
id: python-n-plus-one-orm-loop
|
|
@@ -146,10 +216,12 @@ rule:
|
|
|
146
216
|
id: python-unbounded-comprehension
|
|
147
217
|
language: Python
|
|
148
218
|
severity: warning
|
|
149
|
-
message: Materializing a list comprehension inside an aggregation allocates the full list in memory. Use a generator expression instead.
|
|
219
|
+
message: Materializing a list comprehension inside an aggregation allocates the full list in memory. Use a generator expression (parenthesized if a second argument such as `start` follows) instead; only do so when evaluating `start` does not affect the iterated data or any other state the comprehension reads (for example `items.pop()`), because the generator defers iteration until after `start` is evaluated.
|
|
150
220
|
rule:
|
|
151
221
|
any:
|
|
152
222
|
- pattern: sum($COMP)
|
|
223
|
+
- pattern: sum($COMP, $START)
|
|
224
|
+
- pattern: sum($COMP, start=$START)
|
|
153
225
|
- pattern: any($COMP)
|
|
154
226
|
- pattern: all($COMP)
|
|
155
227
|
- pattern: min($COMP)
|
|
@@ -17,7 +17,7 @@ rule:
|
|
|
17
17
|
- has:
|
|
18
18
|
kind: parameter
|
|
19
19
|
nthChild: 2
|
|
20
|
-
has: { field: type, regex: 'EventArgs
|
|
20
|
+
has: { field: type, regex: 'EventArgs\??$' }
|
|
21
21
|
- not: { has: { kind: parameter, nthChild: 3 } }
|
|
22
22
|
|
|
23
23
|
---
|
|
@@ -40,11 +40,17 @@ rule:
|
|
|
40
40
|
kind: variable_declarator
|
|
41
41
|
all:
|
|
42
42
|
- has: { field: name, pattern: $VAR }
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
- any:
|
|
44
|
+
- has:
|
|
45
|
+
kind: object_creation_expression
|
|
46
|
+
has:
|
|
47
|
+
field: type
|
|
48
|
+
regex: &disposableType '^(?:(?:global::)?System\.IO\.)?(FileStream|StreamReader|StreamWriter|BinaryReader|BinaryWriter)$|^(?:(?:global::)?(?:System|Microsoft)\.Data\.SqlClient\.)?SqlConnection$|^(?:(?:global::)?Npgsql\.)?NpgsqlConnection$|^(?:(?:global::)?(?:MySqlConnector|MySql\.Data\.MySqlClient)\.)?MySqlConnection$|^(?:(?:global::)?Microsoft\.Data\.Sqlite\.)?SqliteConnection$'
|
|
49
|
+
- all:
|
|
50
|
+
- has: { kind: implicit_object_creation_expression }
|
|
51
|
+
- inside:
|
|
52
|
+
kind: variable_declaration
|
|
53
|
+
has: { field: type, regex: *disposableType }
|
|
48
54
|
- not:
|
|
49
55
|
precedes:
|
|
50
56
|
stopBy: end
|
|
@@ -4,6 +4,31 @@ language: Go
|
|
|
4
4
|
severity: warning
|
|
5
5
|
message: This assignment drops the error result with _, so a failure goes unnoticed. Check the error and return or log it.
|
|
6
6
|
ignores: ['**/*_test.go']
|
|
7
|
+
utils:
|
|
8
|
+
selector-extra-signature-shadow:
|
|
9
|
+
inside:
|
|
10
|
+
stopBy: end
|
|
11
|
+
any:
|
|
12
|
+
- has:
|
|
13
|
+
field: receiver
|
|
14
|
+
has: { kind: parameter_declaration, has: { kind: identifier, pattern: $OWNER } }
|
|
15
|
+
- has:
|
|
16
|
+
field: result
|
|
17
|
+
has: { kind: parameter_declaration, has: { kind: identifier, pattern: $OWNER } }
|
|
18
|
+
selector-local-shadow:
|
|
19
|
+
inside:
|
|
20
|
+
kind: block
|
|
21
|
+
stopBy: end
|
|
22
|
+
has:
|
|
23
|
+
kind: statement_list
|
|
24
|
+
has:
|
|
25
|
+
any:
|
|
26
|
+
- all:
|
|
27
|
+
- kind: short_var_declaration
|
|
28
|
+
- has: { field: left, has: { kind: identifier, pattern: $OWNER } }
|
|
29
|
+
- all:
|
|
30
|
+
- kind: var_declaration
|
|
31
|
+
- has: { kind: var_spec, stopBy: end, has: { kind: identifier, pattern: $OWNER } }
|
|
7
32
|
rule:
|
|
8
33
|
any:
|
|
9
34
|
# value, _ := call(...): reported only for an allow-list of calls known to return (T, error): selected stdlib packages,
|
|
@@ -49,6 +74,57 @@ rule:
|
|
|
49
74
|
has:
|
|
50
75
|
field: field
|
|
51
76
|
regex: '^(Write|WriteString|Flush|Sync|Encode|Exec|ExecContext|Commit)$'
|
|
77
|
+
# A single discarded result from these standard APIs is an error. Require the matching
|
|
78
|
+
# import and, for Scan, a visible database/sql receiver type.
|
|
79
|
+
- all:
|
|
80
|
+
- pattern: _ = $OWNER.$METHOD($$$ARGS)
|
|
81
|
+
- any:
|
|
82
|
+
- all:
|
|
83
|
+
- pattern: _ = json.Unmarshal($$$ARGS)
|
|
84
|
+
- inside:
|
|
85
|
+
{
|
|
86
|
+
kind: source_file,
|
|
87
|
+
stopBy: end,
|
|
88
|
+
has: { kind: import_spec, regex: '^"encoding/json"$', stopBy: end },
|
|
89
|
+
}
|
|
90
|
+
- all:
|
|
91
|
+
- pattern: _ = os.WriteFile($$$ARGS)
|
|
92
|
+
- inside: { kind: source_file, stopBy: end, has: { kind: import_spec, regex: '^"os"$', stopBy: end } }
|
|
93
|
+
- not:
|
|
94
|
+
inside:
|
|
95
|
+
any: [{ kind: function_declaration }, { kind: method_declaration }, { kind: func_literal }]
|
|
96
|
+
stopBy: end
|
|
97
|
+
has:
|
|
98
|
+
field: parameters
|
|
99
|
+
has: { kind: parameter_declaration, has: { kind: identifier, pattern: $OWNER } }
|
|
100
|
+
- not: { matches: selector-local-shadow }
|
|
101
|
+
- not: { matches: selector-extra-signature-shadow }
|
|
102
|
+
- all:
|
|
103
|
+
- pattern: _ = $OWNER.Scan($$$ARGS)
|
|
104
|
+
- not: { matches: selector-local-shadow }
|
|
105
|
+
- not: { matches: selector-extra-signature-shadow }
|
|
106
|
+
- inside: { kind: source_file, stopBy: end, has: { kind: import_spec, regex: '^"database/sql"$', stopBy: end } }
|
|
107
|
+
- inside:
|
|
108
|
+
any: [{ kind: function_declaration }, { kind: method_declaration }, { kind: func_literal }]
|
|
109
|
+
stopBy: end
|
|
110
|
+
has:
|
|
111
|
+
field: parameters
|
|
112
|
+
has:
|
|
113
|
+
kind: parameter_declaration
|
|
114
|
+
all:
|
|
115
|
+
- has: { kind: identifier, pattern: $OWNER }
|
|
116
|
+
- has: { field: type, regex: '^\*sql\.(Row|Rows)$' }
|
|
117
|
+
- not:
|
|
118
|
+
inside:
|
|
119
|
+
any: [{ kind: function_declaration }, { kind: method_declaration }, { kind: func_literal }]
|
|
120
|
+
stopBy: end
|
|
121
|
+
has:
|
|
122
|
+
field: parameters
|
|
123
|
+
has:
|
|
124
|
+
kind: parameter_declaration
|
|
125
|
+
all:
|
|
126
|
+
- has: { kind: identifier, pattern: $OWNER }
|
|
127
|
+
- not: { has: { field: type, regex: '^\*sql\.(Row|Rows)$' } }
|
|
52
128
|
|
|
53
129
|
---
|
|
54
130
|
id: go-defer-before-error-check
|
|
@@ -64,13 +140,17 @@ rule:
|
|
|
64
140
|
- pattern: defer $RES.Body.Close()
|
|
65
141
|
- follows:
|
|
66
142
|
any:
|
|
67
|
-
- pattern: $RES,
|
|
68
|
-
- pattern: $RES,
|
|
143
|
+
- pattern: $RES, $ERR := $CALL($$$ARGS)
|
|
144
|
+
- pattern: $RES, $ERR = $CALL($$$ARGS)
|
|
69
145
|
- all:
|
|
70
146
|
- pattern: defer $RES.Close()
|
|
71
147
|
- follows:
|
|
72
148
|
any:
|
|
73
|
-
- pattern: $RES,
|
|
74
|
-
- pattern: $RES,
|
|
75
|
-
- pattern: $RES,
|
|
76
|
-
- pattern: $RES,
|
|
149
|
+
- pattern: $RES, $ERR := $DB.Query($$$ARGS)
|
|
150
|
+
- pattern: $RES, $ERR = $DB.Query($$$ARGS)
|
|
151
|
+
- pattern: $RES, $ERR := $DB.QueryContext($$$ARGS)
|
|
152
|
+
- pattern: $RES, $ERR = $DB.QueryContext($$$ARGS)
|
|
153
|
+
constraints:
|
|
154
|
+
ERR:
|
|
155
|
+
not:
|
|
156
|
+
regex: '^_$'
|
|
@@ -28,7 +28,28 @@ rule:
|
|
|
28
28
|
stopBy: end
|
|
29
29
|
any:
|
|
30
30
|
- kind: try_statement
|
|
31
|
-
has:
|
|
31
|
+
has:
|
|
32
|
+
kind: finally_clause
|
|
33
|
+
has:
|
|
34
|
+
stopBy: end
|
|
35
|
+
any:
|
|
36
|
+
- pattern: $VAR.close()
|
|
37
|
+
- kind: method_invocation
|
|
38
|
+
all:
|
|
39
|
+
- has: { field: name, regex: '(?i)^close' }
|
|
40
|
+
- has:
|
|
41
|
+
field: arguments
|
|
42
|
+
has: { pattern: $VAR }
|
|
43
|
+
- kind: try_with_resources_statement
|
|
44
|
+
has:
|
|
45
|
+
kind: resource_specification
|
|
46
|
+
has: { stopBy: end, pattern: $VAR }
|
|
47
|
+
- kind: return_statement
|
|
48
|
+
has: { stopBy: end, pattern: $VAR }
|
|
49
|
+
- has:
|
|
50
|
+
stopBy: end
|
|
51
|
+
kind: assignment_expression
|
|
52
|
+
has: { field: right, pattern: $VAR }
|
|
32
53
|
- kind: try_with_resources_statement
|
|
33
54
|
has:
|
|
34
55
|
kind: resource_specification
|