dart-decimate 0.0.29 → 0.0.30
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +36 -60
- package/npm/bin/runner.js +26 -14
- package/npm/scripts/postinstall.js +89 -63
- package/package.json +3 -2
- package/src/baseline.rs +38 -0
- package/src/cli/health_args.rs +36 -7
- package/src/cli/html_open.rs +4 -0
- package/src/cli/issue_filter_args.rs +1 -0
- package/src/cli/security_summary_run.rs +1 -0
- package/src/config/health.rs +22 -2
- package/src/config/rule_aliases.rs +43 -0
- package/src/config/rules.rs +46 -1
- package/src/config.rs +2 -1
- package/src/dart_parser/test_support.rs +51 -0
- package/src/dart_parser.rs +8 -0
- package/src/dependencies/analyze.rs +3 -1
- package/src/dependencies/tests.rs +111 -7
- package/src/dependencies/usage.rs +5 -1
- package/src/dependencies.rs +7 -3
- package/src/explain/flutter_style.rs +43 -0
- package/src/explain/misc.rs +72 -0
- package/src/explain.rs +23 -67
- package/src/flutter_style/scanner.rs +883 -0
- package/src/flutter_style/types.rs +90 -0
- package/src/flutter_style/usage.rs +349 -0
- package/src/flutter_style.rs +72 -0
- package/src/generated.rs +154 -0
- package/src/health/large_units.rs +49 -0
- package/src/health/tests.rs +212 -1
- package/src/health/threshold_types.rs +31 -1
- package/src/health/thresholds.rs +49 -0
- package/src/health/types.rs +35 -0
- package/src/health.rs +72 -6
- package/src/inspect.rs +8 -0
- package/src/lib.rs +17 -5
- package/src/manifest.rs +7 -3
- package/src/output/dependency_findings.rs +14 -1
- package/src/output/flutter_style.rs +189 -0
- package/src/output/health_findings.rs +93 -10
- package/src/output/health_inventory.rs +121 -0
- package/src/output/html/tests.rs +20 -0
- package/src/output/html.rs +10 -1
- package/src/output/human.rs +85 -1
- package/src/output/human_details.rs +93 -12
- package/src/output/scope.rs +62 -2
- package/src/output/security_findings.rs +101 -76
- package/src/output/security_sarif.rs +24 -13
- package/src/output/suppressions.rs +4 -0
- package/src/output/types.rs +38 -2
- package/src/output/verdict.rs +12 -0
- package/src/output.rs +77 -74
- package/src/report_schema/inventory.rs +268 -4
- package/src/report_schema.rs +94 -60
- package/src/security/catalogue.rs +103 -0
- package/src/security/detect/weak_randomness.rs +762 -0
- package/src/security/detect.rs +1535 -221
- package/src/security/security_matchers.toml +172 -0
- package/src/security/tests.rs +336 -2
- package/src/security.rs +292 -56
- package/src/security_gate.rs +28 -0
- package/src/semantic.rs +276 -0
- package/src/symbols/semantic_evidence.rs +342 -0
- package/src/symbols.rs +20 -10
- package/src/trace/rendering.rs +54 -0
- package/src/trace/semantic.rs +126 -0
- package/src/trace.rs +54 -62
- package/src/widgets/inheritance.rs +63 -0
- package/src/widgets.rs +33 -3
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -239,10 +239,18 @@ Dart Decimate finds:
|
|
|
239
239
|
- high cognitive complexity
|
|
240
240
|
- high combined complexity
|
|
241
241
|
- high CRAP score
|
|
242
|
+
- advisory large functions
|
|
242
243
|
- coverage gaps
|
|
243
244
|
- low health score files
|
|
244
245
|
- hotspots
|
|
245
246
|
- refactoring targets
|
|
247
|
+
- opt-in Flutter raw-style, near-duplicate theme-token, and unused
|
|
248
|
+
`ThemeExtension` evidence
|
|
249
|
+
|
|
250
|
+
Flutter large-function classification uses the Flutter threshold for `build`
|
|
251
|
+
methods owned by `StatelessWidget`, `AnimatedWidget`, `State`, and
|
|
252
|
+
`ConsumerState`. Color matching follows the documented `Color` constructor
|
|
253
|
+
aliases, integer masking, and floating-component clamping.
|
|
246
254
|
|
|
247
255
|
Useful commands:
|
|
248
256
|
|
|
@@ -250,6 +258,7 @@ Useful commands:
|
|
|
250
258
|
dart-decimate health . --format json
|
|
251
259
|
dart-decimate health . --complexity-breakdown --top 10 --format json
|
|
252
260
|
dart-decimate health . --file-scores --hotspots --targets --format json
|
|
261
|
+
dart-decimate health . --flutter-style --format json
|
|
253
262
|
```
|
|
254
263
|
|
|
255
264
|
### 3. Duplicated Code
|
|
@@ -330,6 +339,7 @@ Dart Decimate finds:
|
|
|
330
339
|
|
|
331
340
|
- unused runtime dependencies
|
|
332
341
|
- unused dev dependencies
|
|
342
|
+
- dev dependencies imported by production-owned `lib/` or `bin/` code
|
|
333
343
|
- runtime dependencies used only by tests
|
|
334
344
|
- imports missing from `pubspec.yaml`
|
|
335
345
|
- unused dependency overrides
|
|
@@ -400,18 +410,33 @@ Dart Decimate finds candidates for:
|
|
|
400
410
|
- raw SQL
|
|
401
411
|
- Firebase client API keys in `FirebaseOptions`
|
|
402
412
|
- plain local storage of secret-like material
|
|
413
|
+
- predictable `dart:math Random()` output used by token-, secret-, nonce-,
|
|
414
|
+
salt-, OTP-, session-, key-, password-, or auth-shaped declarations/calls
|
|
403
415
|
|
|
404
416
|
Firebase client API keys are warning-level by default because FlutterFire
|
|
405
417
|
generates client config. To make them fail a gate, set
|
|
406
418
|
`"dart-decimate/security-firebase-api-key" = "error"` in `[rules]`. Common
|
|
407
|
-
authentication copy
|
|
408
|
-
|
|
409
|
-
secret-like
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
419
|
+
authentication copy is filtered unless bound to a secret-like name or concrete
|
|
420
|
+
token-like segment. OAuth endpoints are metadata only without userinfo
|
|
421
|
+
credentials or secret-like query/fragment data; cleartext transport remains a
|
|
422
|
+
candidate. Stripe secret-key names and `sk_test_`/`sk_live_` values remain
|
|
423
|
+
candidates even as placeholders. Fixed `dart:io` process calls and typed
|
|
424
|
+
`package:process` command lists are excluded; dynamic elements or shell
|
|
425
|
+
execution remain candidates.
|
|
426
|
+
Remote `Uri.http(...)` and `Uri(scheme: 'http', ...)` construction is covered,
|
|
427
|
+
while documented local targets and debug/private-host-only branches are
|
|
428
|
+
excluded. TLS candidates require a callback that can accept an invalid
|
|
429
|
+
certificate; false-only callbacks are excluded and unresolved tear-offs become
|
|
430
|
+
blind spots. `HttpOverrides.global` or an empty `SecurityContext` alone is not a
|
|
431
|
+
bypass. Raw SQL analysis distinguishes literal dollar signs from interpolation
|
|
432
|
+
and retains unresolved runtime queries for review.
|
|
433
|
+
`Random.secure()` and confirmed secure factory flows are excluded. Imports from
|
|
434
|
+
a uniquely resolved Dart library owner apply to its parts; ambiguous process
|
|
435
|
+
provenance, process tear-offs, orphaned or multiply owned part-file calls, and
|
|
436
|
+
indirect Random factory flows are reported as redacted `security_blind_spots`
|
|
437
|
+
instead of being called clean. The embedded matcher
|
|
438
|
+
catalogue owns rule IDs, callee shapes, import provenance, CWE/effect metadata,
|
|
439
|
+
and evidence templates.
|
|
415
440
|
|
|
416
441
|
Useful commands:
|
|
417
442
|
|
|
@@ -598,58 +623,9 @@ ask what is safest to do next.
|
|
|
598
623
|
|
|
599
624
|
## Config
|
|
600
625
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
2. `.dart-decimaterc.json`
|
|
605
|
-
3. `.dart-decimaterc.jsonc`
|
|
606
|
-
4. `dart-decimate.toml`
|
|
607
|
-
5. `.dart-decimate.toml`
|
|
608
|
-
|
|
609
|
-
Example:
|
|
610
|
-
|
|
611
|
-
```toml
|
|
612
|
-
[cli]
|
|
613
|
-
format = "json"
|
|
614
|
-
entry = ["lib/main.dart"]
|
|
615
|
-
production = true
|
|
616
|
-
|
|
617
|
-
[health]
|
|
618
|
-
max_cyclomatic = 20
|
|
619
|
-
max_cognitive = 15
|
|
620
|
-
coverage_gaps = true
|
|
621
|
-
fileScores = true
|
|
622
|
-
hotspots = true
|
|
623
|
-
targets = true
|
|
624
|
-
|
|
625
|
-
[dupes]
|
|
626
|
-
mode = "semantic"
|
|
627
|
-
min_tokens = 80
|
|
628
|
-
threshold = 5
|
|
629
|
-
ignore_mapper_pairs = true
|
|
630
|
-
|
|
631
|
-
[flags]
|
|
632
|
-
allow = ["SKIP_PERMISSION_PROMPT"]
|
|
633
|
-
|
|
634
|
-
[boundaries]
|
|
635
|
-
presets = ["layered"]
|
|
636
|
-
rules = ["lib/domain:lib/ui"]
|
|
637
|
-
|
|
638
|
-
[security]
|
|
639
|
-
surface = true
|
|
640
|
-
categories = ["hardcoded-secret", "firebase-api-key", "insecure-transport", "tls-bypass"]
|
|
641
|
-
|
|
642
|
-
[rules]
|
|
643
|
-
unused-files = "error"
|
|
644
|
-
unused-exports = "warn"
|
|
645
|
-
security-candidate = "warn"
|
|
646
|
-
"dart-decimate/security-firebase-api-key" = "error"
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
Allowed feature flags remain visible in the inventory but do not create
|
|
650
|
-
`feature-flag` findings. Inline suppressions can document intent after `--`,
|
|
651
|
-
`because`, or `reason:`, for example
|
|
652
|
-
`// dart-decimate-ignore-next-line feature-flag -- required by E2E startup`.
|
|
626
|
+
See [docs/configuration.md](docs/configuration.md) for config discovery,
|
|
627
|
+
health/style settings, rule levels, security categories, and suppression
|
|
628
|
+
examples.
|
|
653
629
|
|
|
654
630
|
## Full Issue List
|
|
655
631
|
|
package/npm/bin/runner.js
CHANGED
|
@@ -40,13 +40,14 @@ function installCachedBinary(root) {
|
|
|
40
40
|
stdio: "inherit",
|
|
41
41
|
windowsHide: false,
|
|
42
42
|
});
|
|
43
|
+
handleInstallerResult(result);
|
|
44
|
+
}
|
|
43
45
|
|
|
46
|
+
function handleInstallerResult(result) {
|
|
44
47
|
if (result.error && result.error.code !== "ENOENT") {
|
|
45
48
|
console.error(`dart-decimate: install step failed to start: ${result.error.message}`);
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
process.kill(process.pid, result.signal);
|
|
49
|
-
}
|
|
50
|
+
forwardSignal(result.signal);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
function run(command, commandArgs, cwd = undefined, label = command) {
|
|
@@ -57,23 +58,34 @@ function run(command, commandArgs, cwd = undefined, label = command) {
|
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
if (result.error) {
|
|
60
|
-
|
|
61
|
-
console.error(
|
|
62
|
-
`${label}: Rust/Cargo is required to build the npm source package. ` +
|
|
63
|
-
"Install Rust from https://rustup.rs or use a release package with a prebuilt binary.",
|
|
64
|
-
);
|
|
65
|
-
process.exit(127);
|
|
66
|
-
}
|
|
67
|
-
console.error(`${label}: failed to execute ${command}: ${result.error.message}`);
|
|
68
|
-
process.exit(1);
|
|
61
|
+
handleRunError(result.error, command, label);
|
|
69
62
|
}
|
|
70
63
|
|
|
71
|
-
if (result.signal) {
|
|
72
|
-
process.kill(process.pid, result.signal);
|
|
64
|
+
if (forwardSignal(result.signal)) {
|
|
73
65
|
return;
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
process.exit(result.status ?? 1);
|
|
77
69
|
}
|
|
78
70
|
|
|
71
|
+
function handleRunError(error, command, label) {
|
|
72
|
+
if (error.code === "ENOENT") {
|
|
73
|
+
console.error(
|
|
74
|
+
`${label}: Rust/Cargo is required to build the npm source package. ` +
|
|
75
|
+
"Install Rust from https://rustup.rs or use a release package with a prebuilt binary.",
|
|
76
|
+
);
|
|
77
|
+
process.exit(127);
|
|
78
|
+
}
|
|
79
|
+
console.error(`${label}: failed to execute ${command}: ${error.message}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function forwardSignal(signal) {
|
|
84
|
+
if (!signal) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
process.kill(process.pid, signal);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
79
91
|
module.exports = { runBinary };
|
|
@@ -56,7 +56,12 @@ async function installPrebuilt() {
|
|
|
56
56
|
const archivePath = path.join(os.tmpdir(), assetName);
|
|
57
57
|
const url = `${releaseBaseUrl.replace(/\/$/, "")}/${assetName}`;
|
|
58
58
|
await download(url, archivePath, 0);
|
|
59
|
+
extractArchive(assetName, archivePath);
|
|
60
|
+
activateCachedBinaries(assetName);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
59
63
|
|
|
64
|
+
function extractArchive(assetName, archivePath) {
|
|
60
65
|
const extract = spawnSync("tar", ["-xzf", archivePath, "-C", cacheDir], {
|
|
61
66
|
stdio: "pipe",
|
|
62
67
|
windowsHide: false,
|
|
@@ -72,7 +77,9 @@ async function installPrebuilt() {
|
|
|
72
77
|
`could not extract ${assetName}${stderr ? `: ${stderr}` : ""}`,
|
|
73
78
|
);
|
|
74
79
|
}
|
|
80
|
+
}
|
|
75
81
|
|
|
82
|
+
function activateCachedBinaries(assetName) {
|
|
76
83
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
77
84
|
const cachedBinary = path.join(cacheDir, `${binary}${exeExt}`);
|
|
78
85
|
if (!fs.existsSync(cachedBinary)) {
|
|
@@ -82,35 +89,38 @@ async function installPrebuilt() {
|
|
|
82
89
|
fs.chmodSync(cachedBinary, 0o755);
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
|
-
|
|
86
|
-
return true;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
function prebuiltAssetName() {
|
|
90
|
-
const platform =
|
|
91
|
-
|
|
92
|
-
? "darwin"
|
|
93
|
-
: process.platform === "linux"
|
|
94
|
-
? "linux"
|
|
95
|
-
: process.platform === "win32"
|
|
96
|
-
? "windows"
|
|
97
|
-
: null;
|
|
98
|
-
const arch =
|
|
99
|
-
process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : null;
|
|
95
|
+
const platform = prebuiltPlatform();
|
|
96
|
+
const arch = prebuiltArchitecture();
|
|
100
97
|
|
|
101
98
|
if (!platform || !arch) {
|
|
102
99
|
return null;
|
|
103
100
|
}
|
|
104
|
-
if (platform
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
if (platform === "windows" && arch === "arm64") {
|
|
101
|
+
if (!supportsPrebuiltTarget(platform, arch)) {
|
|
108
102
|
return null;
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
return `dart-decimate-${platform}-${arch}.tar.gz`;
|
|
112
106
|
}
|
|
113
107
|
|
|
108
|
+
function prebuiltPlatform() {
|
|
109
|
+
return new Map([
|
|
110
|
+
["darwin", "darwin"],
|
|
111
|
+
["linux", "linux"],
|
|
112
|
+
["win32", "windows"],
|
|
113
|
+
]).get(process.platform);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function prebuiltArchitecture() {
|
|
117
|
+
return new Set(["x64", "arm64"]).has(process.arch) ? process.arch : null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function supportsPrebuiltTarget(platform, arch) {
|
|
121
|
+
return !new Set(["linux:arm64", "windows:arm64"]).has(`${platform}:${arch}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
114
124
|
function download(url, destination, redirectCount) {
|
|
115
125
|
if (redirectCount > 5) {
|
|
116
126
|
return Promise.reject(
|
|
@@ -120,71 +130,87 @@ function download(url, destination, redirectCount) {
|
|
|
120
130
|
|
|
121
131
|
return new Promise((resolve, reject) => {
|
|
122
132
|
const client = url.startsWith("http://") ? http : https;
|
|
123
|
-
const request = client.get(url,
|
|
124
|
-
|
|
125
|
-
response
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (response.statusCode !== 200) {
|
|
136
|
-
response.resume();
|
|
137
|
-
reject(
|
|
138
|
-
new Error(`download ${url} returned HTTP ${response.statusCode}`),
|
|
139
|
-
);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
await pipeline(
|
|
145
|
-
response,
|
|
146
|
-
fs.createWriteStream(destination, { mode: 0o600 }),
|
|
147
|
-
);
|
|
148
|
-
resolve();
|
|
149
|
-
} catch (error) {
|
|
150
|
-
reject(error);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
133
|
+
const request = client.get(url, (response) =>
|
|
134
|
+
handleDownloadResponse(
|
|
135
|
+
response,
|
|
136
|
+
url,
|
|
137
|
+
destination,
|
|
138
|
+
redirectCount,
|
|
139
|
+
resolve,
|
|
140
|
+
reject,
|
|
141
|
+
),
|
|
142
|
+
);
|
|
154
143
|
request.on("error", reject);
|
|
155
144
|
});
|
|
156
145
|
}
|
|
157
146
|
|
|
147
|
+
function handleDownloadResponse(
|
|
148
|
+
response,
|
|
149
|
+
url,
|
|
150
|
+
destination,
|
|
151
|
+
redirectCount,
|
|
152
|
+
resolve,
|
|
153
|
+
reject,
|
|
154
|
+
) {
|
|
155
|
+
if (isRedirect(response)) {
|
|
156
|
+
response.resume();
|
|
157
|
+
const nextUrl = new URL(response.headers.location, url).toString();
|
|
158
|
+
download(nextUrl, destination, redirectCount + 1).then(resolve, reject);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (response.statusCode !== 200) {
|
|
162
|
+
response.resume();
|
|
163
|
+
reject(new Error(`download ${url} returned HTTP ${response.statusCode}`));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
pipeline(response, fs.createWriteStream(destination, { mode: 0o600 })).then(
|
|
167
|
+
resolve,
|
|
168
|
+
reject,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function isRedirect(response) {
|
|
173
|
+
return (
|
|
174
|
+
response.statusCode >= 300 &&
|
|
175
|
+
response.statusCode < 400 &&
|
|
176
|
+
Boolean(response.headers.location)
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
158
180
|
function buildFromSource(prebuiltError) {
|
|
159
181
|
const build = spawnSync(cargo, ["build", "--release", "--locked"], {
|
|
160
182
|
cwd: root,
|
|
161
183
|
stdio: "inherit",
|
|
162
184
|
windowsHide: false,
|
|
163
185
|
});
|
|
186
|
+
handleBuildStartError(build.error, prebuiltError);
|
|
187
|
+
if (build.status !== 0) {
|
|
188
|
+
process.exit(build.status ?? 1);
|
|
189
|
+
}
|
|
190
|
+
cacheBuiltBinaries();
|
|
191
|
+
}
|
|
164
192
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
193
|
+
function handleBuildStartError(error, prebuiltError) {
|
|
194
|
+
if (!error) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (error.code === "ENOENT") {
|
|
198
|
+
if (prebuiltError) {
|
|
172
199
|
console.error(
|
|
173
|
-
|
|
174
|
-
"could not be installed for this platform. Install Rust from https://rustup.rs.",
|
|
200
|
+
`dart-decimate: prebuilt install failed: ${prebuiltError.message}`,
|
|
175
201
|
);
|
|
176
|
-
process.exit(127);
|
|
177
202
|
}
|
|
178
203
|
console.error(
|
|
179
|
-
|
|
204
|
+
"dart-decimate: Rust/Cargo is required as a fallback because a prebuilt binary " +
|
|
205
|
+
"could not be installed for this platform. Install Rust from https://rustup.rs.",
|
|
180
206
|
);
|
|
181
|
-
process.exit(
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (build.status !== 0) {
|
|
185
|
-
process.exit(build.status ?? 1);
|
|
207
|
+
process.exit(127);
|
|
186
208
|
}
|
|
209
|
+
console.error(`dart-decimate: cargo build failed to start: ${error.message}`);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
187
212
|
|
|
213
|
+
function cacheBuiltBinaries() {
|
|
188
214
|
for (const binary of ["dart-decimate", "dart-decimate-mcp"]) {
|
|
189
215
|
const builtBinary = path.join(
|
|
190
216
|
root,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postinstall": "node npm/scripts/postinstall.js",
|
|
30
|
-
"test": "node --test tests/js
|
|
30
|
+
"test": "node --test tests/js/*.test.mjs",
|
|
31
|
+
"typecheck": "node scripts/typecheck-js.mjs",
|
|
31
32
|
"version:check": "node scripts/check-version-sync.mjs",
|
|
32
33
|
"lint": "npm run version:check && npm run migration:check && npm run lint:js && npm run format:check",
|
|
33
34
|
"lint:js": "oxlint .",
|
package/src/baseline.rs
CHANGED
|
@@ -424,6 +424,10 @@ fn filter_detail_sections(report: &mut JsonReport) {
|
|
|
424
424
|
report
|
|
425
425
|
.complexity
|
|
426
426
|
.retain(|finding| complexity_live(finding, &remaining));
|
|
427
|
+
report.flutter_style.retain(|finding| {
|
|
428
|
+
style_kind(&finding.kind)
|
|
429
|
+
.is_some_and(|kind| detail_path_live(kind, &finding.path, &remaining))
|
|
430
|
+
});
|
|
427
431
|
report
|
|
428
432
|
.hotspots
|
|
429
433
|
.retain(|hotspot| detail_path_live(FindingKind::HealthHotspot, &hotspot.path, &remaining));
|
|
@@ -441,6 +445,15 @@ fn filter_detail_sections(report: &mut JsonReport) {
|
|
|
441
445
|
.retain(|entry| attack_surface_live(entry, &report.security_candidates));
|
|
442
446
|
}
|
|
443
447
|
|
|
448
|
+
fn style_kind(kind: &str) -> Option<FindingKind> {
|
|
449
|
+
match kind {
|
|
450
|
+
"raw-flutter-style-value" => Some(FindingKind::RawFlutterStyleValue),
|
|
451
|
+
"near-duplicate-theme-token" => Some(FindingKind::NearDuplicateThemeToken),
|
|
452
|
+
"unused-theme-extension-token" => Some(FindingKind::UnusedThemeExtensionToken),
|
|
453
|
+
_ => None,
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
444
457
|
fn clone_group_live(
|
|
445
458
|
group: &JsonCloneGroup,
|
|
446
459
|
remaining: &[(FindingKind, String, Option<String>)],
|
|
@@ -547,6 +560,8 @@ fn recompute_summary(report: &mut JsonReport) {
|
|
|
547
560
|
report.summary.unused_dependencies = dependency_count(&report.findings);
|
|
548
561
|
report.summary.unused_dev_dependencies =
|
|
549
562
|
kind_count(&report.findings, FindingKind::UnusedDevDependency);
|
|
563
|
+
report.summary.dev_dependencies_in_production =
|
|
564
|
+
kind_count(&report.findings, FindingKind::DevDependencyInProduction);
|
|
550
565
|
report.summary.test_only_dependencies =
|
|
551
566
|
kind_count(&report.findings, FindingKind::TestOnlyDependency);
|
|
552
567
|
report.summary.dependency_overrides = dependency_override_count(&report.findings);
|
|
@@ -587,6 +602,19 @@ fn recompute_summary(report: &mut JsonReport) {
|
|
|
587
602
|
);
|
|
588
603
|
report.summary.code_duplications = report.clone_groups.len();
|
|
589
604
|
report.summary.complex_functions = report.complexity.len();
|
|
605
|
+
report.summary.large_functions = report.large_functions.len();
|
|
606
|
+
report.summary.raw_flutter_style_values = style_count(report, "raw-flutter-style-value");
|
|
607
|
+
report.summary.near_duplicate_theme_tokens = style_count(report, "near-duplicate-theme-token");
|
|
608
|
+
report.summary.unused_theme_extension_tokens =
|
|
609
|
+
style_count(report, "unused-theme-extension-token");
|
|
610
|
+
report.summary.semantic_evidence = report
|
|
611
|
+
.semantic
|
|
612
|
+
.as_ref()
|
|
613
|
+
.map_or(0, |semantic| semantic.evidence.len());
|
|
614
|
+
report.summary.type_couplings = report
|
|
615
|
+
.semantic
|
|
616
|
+
.as_ref()
|
|
617
|
+
.map_or(0, |semantic| semantic.type_couplings.len());
|
|
590
618
|
report.summary.coverage_gaps = kind_count(&report.findings, FindingKind::CoverageGap);
|
|
591
619
|
report.summary.crap_functions = kind_count(&report.findings, FindingKind::HighCrapScore);
|
|
592
620
|
report.summary.file_scores = report.file_scores.len();
|
|
@@ -604,6 +632,7 @@ fn recompute_summary(report: &mut JsonReport) {
|
|
|
604
632
|
.iter()
|
|
605
633
|
.map(|candidate| candidate.occurrences.len())
|
|
606
634
|
.sum();
|
|
635
|
+
report.summary.security_blind_spots = report.security_blind_spots.len();
|
|
607
636
|
report.summary.attack_surface = report.attack_surface.len();
|
|
608
637
|
report.summary.missing_entry_points =
|
|
609
638
|
kind_count(&report.findings, FindingKind::MissingEntryPoint);
|
|
@@ -620,6 +649,14 @@ fn recompute_summary(report: &mut JsonReport) {
|
|
|
620
649
|
report.summary.findings = report.findings.len();
|
|
621
650
|
}
|
|
622
651
|
|
|
652
|
+
fn style_count(report: &JsonReport, kind: &str) -> usize {
|
|
653
|
+
report
|
|
654
|
+
.flutter_style
|
|
655
|
+
.iter()
|
|
656
|
+
.filter(|finding| finding.kind == kind)
|
|
657
|
+
.count()
|
|
658
|
+
}
|
|
659
|
+
|
|
623
660
|
fn kind_count(findings: &[Finding], kind: FindingKind) -> usize {
|
|
624
661
|
findings
|
|
625
662
|
.iter()
|
|
@@ -644,6 +681,7 @@ const fn is_dependency_hygiene_kind(kind: FindingKind) -> bool {
|
|
|
644
681
|
kind,
|
|
645
682
|
FindingKind::UnusedDependency
|
|
646
683
|
| FindingKind::UnusedDevDependency
|
|
684
|
+
| FindingKind::DevDependencyInProduction
|
|
647
685
|
| FindingKind::TestOnlyDependency
|
|
648
686
|
| FindingKind::UnusedDependencyOverride
|
|
649
687
|
)
|
package/src/cli/health_args.rs
CHANGED
|
@@ -5,13 +5,20 @@ use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource, value_parse
|
|
|
5
5
|
use crate::{HealthOptions, LowTrafficThreshold};
|
|
6
6
|
|
|
7
7
|
pub(super) fn health_command(command: Command) -> Command {
|
|
8
|
-
health_command_without_top(command)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
health_command_without_top(command)
|
|
9
|
+
.arg(
|
|
10
|
+
Arg::new("top")
|
|
11
|
+
.long("top")
|
|
12
|
+
.value_name("N")
|
|
13
|
+
.help("Show only the N highest complexity findings")
|
|
14
|
+
.value_parser(value_parser!(usize)),
|
|
15
|
+
)
|
|
16
|
+
.arg(
|
|
17
|
+
Arg::new("flutter-style")
|
|
18
|
+
.long("flutter-style")
|
|
19
|
+
.help("Include advisory Flutter theme/style analysis")
|
|
20
|
+
.action(ArgAction::SetTrue),
|
|
21
|
+
)
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
pub(super) fn health_command_without_top(command: Command) -> Command {
|
|
@@ -32,6 +39,14 @@ pub(super) fn health_command_without_top(command: Command) -> Command {
|
|
|
32
39
|
.default_value("15")
|
|
33
40
|
.value_parser(value_parser!(usize)),
|
|
34
41
|
)
|
|
42
|
+
.arg(
|
|
43
|
+
Arg::new("max-unit-size")
|
|
44
|
+
.long("max-unit-size")
|
|
45
|
+
.value_name("N")
|
|
46
|
+
.help("Maximum inclusive physical lines in one function-like declaration")
|
|
47
|
+
.default_value("60")
|
|
48
|
+
.value_parser(value_parser!(usize)),
|
|
49
|
+
)
|
|
35
50
|
.arg(
|
|
36
51
|
Arg::new("complexity-breakdown")
|
|
37
52
|
.long("complexity-breakdown")
|
|
@@ -142,6 +157,11 @@ pub(super) fn health_options_with_defaults(
|
|
|
142
157
|
options.max_cognitive = *max_cognitive;
|
|
143
158
|
}
|
|
144
159
|
}
|
|
160
|
+
if is_command_line(matches, "max-unit-size") {
|
|
161
|
+
if let Some(max_unit_size) = matches.get_one::<usize>("max-unit-size") {
|
|
162
|
+
options.max_unit_size = *max_unit_size;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
145
165
|
if is_command_line(matches, "top") {
|
|
146
166
|
options.top = matches.get_one::<usize>("top").copied();
|
|
147
167
|
}
|
|
@@ -187,6 +207,15 @@ pub(super) fn health_options_with_defaults(
|
|
|
187
207
|
if is_command_line(matches, "ownership") {
|
|
188
208
|
options.ownership = matches.get_flag("ownership").into();
|
|
189
209
|
}
|
|
210
|
+
if matches
|
|
211
|
+
.try_get_one::<bool>("flutter-style")
|
|
212
|
+
.ok()
|
|
213
|
+
.flatten()
|
|
214
|
+
.copied()
|
|
215
|
+
.unwrap_or_default()
|
|
216
|
+
{
|
|
217
|
+
options.flutter_style = true.into();
|
|
218
|
+
}
|
|
190
219
|
if is_command_line(matches, "min-score") {
|
|
191
220
|
if let Some(min_score) = matches.get_one::<usize>("min-score") {
|
|
192
221
|
options.min_score = (*min_score).min(100);
|
package/src/cli/html_open.rs
CHANGED
|
@@ -207,12 +207,16 @@ mod tests {
|
|
|
207
207
|
findings: Vec::new(),
|
|
208
208
|
clone_groups: Vec::new(),
|
|
209
209
|
complexity: Vec::new(),
|
|
210
|
+
large_functions: Vec::new(),
|
|
211
|
+
flutter_style: Vec::new(),
|
|
212
|
+
semantic: None,
|
|
210
213
|
file_scores: Vec::new(),
|
|
211
214
|
hotspots: Vec::new(),
|
|
212
215
|
refactoring_targets: Vec::new(),
|
|
213
216
|
threshold_overrides: Vec::new(),
|
|
214
217
|
feature_flags: Vec::new(),
|
|
215
218
|
security_candidates: Vec::new(),
|
|
219
|
+
security_blind_spots: Vec::new(),
|
|
216
220
|
attack_surface: Vec::new(),
|
|
217
221
|
runtime_coverage: None,
|
|
218
222
|
next_steps: Vec::new(),
|
|
@@ -131,6 +131,7 @@ fn push_dependency_filters(matches: &ArgMatches, kinds: &mut Vec<FindingKind>) {
|
|
|
131
131
|
&[
|
|
132
132
|
FindingKind::UnusedDependency,
|
|
133
133
|
FindingKind::UnusedDevDependency,
|
|
134
|
+
FindingKind::DevDependencyInProduction,
|
|
134
135
|
FindingKind::TestOnlyDependency,
|
|
135
136
|
],
|
|
136
137
|
);
|
|
@@ -19,6 +19,7 @@ pub(super) fn apply_security_summary(request: &CommandRequest, report: &mut Json
|
|
|
19
19
|
report.threshold_overrides.clear();
|
|
20
20
|
report.feature_flags.clear();
|
|
21
21
|
report.security_candidates.clear();
|
|
22
|
+
report.security_blind_spots.clear();
|
|
22
23
|
report.attack_surface.clear();
|
|
23
24
|
report.runtime_coverage = None;
|
|
24
25
|
report.next_steps.clear();
|