dart-decimate 0.0.1

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 (188) hide show
  1. package/Cargo.lock +572 -0
  2. package/Cargo.toml +41 -0
  3. package/LICENSE +21 -0
  4. package/README.md +617 -0
  5. package/assets/dart-decimate-banner.png +0 -0
  6. package/npm/bin/dart-decimate-mcp.js +48 -0
  7. package/npm/bin/dart-decimate.js +48 -0
  8. package/npm/scripts/postinstall.js +46 -0
  9. package/npm/scripts/test-npx-local.js +54 -0
  10. package/npm/scripts/test-npx-mcp-local.js +56 -0
  11. package/package.json +45 -0
  12. package/src/baseline.rs +643 -0
  13. package/src/bin/dart-decimate-mcp.rs +11 -0
  14. package/src/boundaries/tests.rs +60 -0
  15. package/src/boundaries.rs +317 -0
  16. package/src/changed_scope.rs +117 -0
  17. package/src/ci_template.rs +399 -0
  18. package/src/cli/analyze.rs +462 -0
  19. package/src/cli/analyzer_options.rs +82 -0
  20. package/src/cli/audit_run.rs +327 -0
  21. package/src/cli/boundary_args.rs +44 -0
  22. package/src/cli/ci_template_run.rs +196 -0
  23. package/src/cli/command_name.rs +20 -0
  24. package/src/cli/common_args.rs +167 -0
  25. package/src/cli/config_run.rs +78 -0
  26. package/src/cli/coverage_run.rs +393 -0
  27. package/src/cli/decision_surface_run.rs +99 -0
  28. package/src/cli/default_command.rs +69 -0
  29. package/src/cli/dupes_args.rs +150 -0
  30. package/src/cli/entry_points.rs +121 -0
  31. package/src/cli/error.rs +149 -0
  32. package/src/cli/error_output.rs +68 -0
  33. package/src/cli/explain_run.rs +72 -0
  34. package/src/cli/fix_run.rs +162 -0
  35. package/src/cli/flags_args.rs +23 -0
  36. package/src/cli/health_args.rs +200 -0
  37. package/src/cli/hooks_run.rs +191 -0
  38. package/src/cli/impact_run.rs +95 -0
  39. package/src/cli/init_run.rs +49 -0
  40. package/src/cli/inspect_args.rs +20 -0
  41. package/src/cli/inspect_run.rs +66 -0
  42. package/src/cli/issue_filter_args.rs +240 -0
  43. package/src/cli/list_run.rs +311 -0
  44. package/src/cli/mode_args.rs +72 -0
  45. package/src/cli/output_format.rs +62 -0
  46. package/src/cli/regression_args.rs +156 -0
  47. package/src/cli/request_args.rs +175 -0
  48. package/src/cli/schema_commands.rs +72 -0
  49. package/src/cli/scope_args.rs +174 -0
  50. package/src/cli/security_args.rs +175 -0
  51. package/src/cli/security_gate_run.rs +66 -0
  52. package/src/cli/security_summary_run.rs +43 -0
  53. package/src/cli/summary_args.rs +12 -0
  54. package/src/cli/tests.rs +516 -0
  55. package/src/cli/trace_args.rs +67 -0
  56. package/src/cli/trace_run.rs +131 -0
  57. package/src/cli/trace_tests.rs +235 -0
  58. package/src/cli/unsupported_run.rs +116 -0
  59. package/src/cli/watch_run.rs +153 -0
  60. package/src/cli.rs +603 -0
  61. package/src/config/boundary_config.rs +235 -0
  62. package/src/config/cache.rs +25 -0
  63. package/src/config/dependencies.rs +114 -0
  64. package/src/config/health.rs +237 -0
  65. package/src/config/jsonc.rs +66 -0
  66. package/src/config/policy.rs +91 -0
  67. package/src/config/rule_aliases.rs +487 -0
  68. package/src/config/rules.rs +339 -0
  69. package/src/config.rs +635 -0
  70. package/src/coverage.rs +469 -0
  71. package/src/dart_parser.rs +673 -0
  72. package/src/decision_surface.rs +405 -0
  73. package/src/dependencies/analyze.rs +218 -0
  74. package/src/dependencies/codegen.rs +118 -0
  75. package/src/dependencies/discovery.rs +60 -0
  76. package/src/dependencies/overrides.rs +76 -0
  77. package/src/dependencies/private_src_imports.rs +32 -0
  78. package/src/dependencies/pubspec_document.rs +86 -0
  79. package/src/dependencies/pubspec_entry.rs +96 -0
  80. package/src/dependencies/tests.rs +544 -0
  81. package/src/dependencies/usage.rs +33 -0
  82. package/src/dependencies.rs +553 -0
  83. package/src/dependency_scripts.rs +91 -0
  84. package/src/dupes/lex.rs +236 -0
  85. package/src/dupes/tests.rs +119 -0
  86. package/src/dupes.rs +625 -0
  87. package/src/explain.rs +692 -0
  88. package/src/extract/directives.rs +252 -0
  89. package/src/extract/error_tests.rs +25 -0
  90. package/src/extract/members.rs +210 -0
  91. package/src/extract/primary_constructors.rs +421 -0
  92. package/src/extract/references.rs +151 -0
  93. package/src/extract/routes.rs +691 -0
  94. package/src/extract/signatures.rs +266 -0
  95. package/src/extract/string_tests.rs +18 -0
  96. package/src/extract/strings.rs +107 -0
  97. package/src/extract/tests.rs +697 -0
  98. package/src/extract.rs +680 -0
  99. package/src/feature_flags/tests.rs +76 -0
  100. package/src/feature_flags.rs +453 -0
  101. package/src/finding_identity.rs +60 -0
  102. package/src/fix.rs +551 -0
  103. package/src/generated.rs +53 -0
  104. package/src/graph/augment_tests.rs +212 -0
  105. package/src/graph/conditionals.rs +74 -0
  106. package/src/graph/package_config_tests.rs +100 -0
  107. package/src/graph/parts.rs +248 -0
  108. package/src/graph/pubspec_tests.rs +119 -0
  109. package/src/graph/tests.rs +837 -0
  110. package/src/graph/uri_tests.rs +102 -0
  111. package/src/graph.rs +644 -0
  112. package/src/health/coverage.rs +309 -0
  113. package/src/health/ownership.rs +175 -0
  114. package/src/health/runtime_coverage.rs +616 -0
  115. package/src/health/runtime_intelligence.rs +511 -0
  116. package/src/health/scores.rs +296 -0
  117. package/src/health/tests.rs +240 -0
  118. package/src/health/threshold_types.rs +163 -0
  119. package/src/health/thresholds.rs +229 -0
  120. package/src/health/types.rs +636 -0
  121. package/src/health.rs +597 -0
  122. package/src/hooks/agent_settings.rs +175 -0
  123. package/src/hooks/templates.rs +51 -0
  124. package/src/hooks.rs +569 -0
  125. package/src/impact.rs +287 -0
  126. package/src/init.rs +237 -0
  127. package/src/inspect.rs +142 -0
  128. package/src/intelligence/tests.rs +232 -0
  129. package/src/intelligence.rs +305 -0
  130. package/src/lib.rs +198 -0
  131. package/src/main.rs +5 -0
  132. package/src/manifest/mcp.rs +565 -0
  133. package/src/manifest.rs +552 -0
  134. package/src/mcp/cli_args/value_args.rs +175 -0
  135. package/src/mcp/cli_args.rs +658 -0
  136. package/src/mcp/cli_args_tests.rs +522 -0
  137. package/src/mcp/code_execute.rs +671 -0
  138. package/src/mcp/tools.rs +660 -0
  139. package/src/mcp.rs +325 -0
  140. package/src/output/audit_risk.rs +135 -0
  141. package/src/output/dependency_findings.rs +327 -0
  142. package/src/output/duplication_findings.rs +114 -0
  143. package/src/output/feature_flag_findings.rs +122 -0
  144. package/src/output/format.rs +31 -0
  145. package/src/output/graph_findings.rs +461 -0
  146. package/src/output/health_findings.rs +612 -0
  147. package/src/output/human.rs +27 -0
  148. package/src/output/next_steps.rs +92 -0
  149. package/src/output/route_findings.rs +76 -0
  150. package/src/output/runtime_coverage.rs +515 -0
  151. package/src/output/scope.rs +183 -0
  152. package/src/output/security_findings.rs +390 -0
  153. package/src/output/security_sarif.rs +150 -0
  154. package/src/output/suppressions.rs +323 -0
  155. package/src/output/symbol_findings.rs +257 -0
  156. package/src/output/tests.rs +114 -0
  157. package/src/output/types.rs +604 -0
  158. package/src/output/widget_findings.rs +213 -0
  159. package/src/output.rs +682 -0
  160. package/src/package_map.rs +495 -0
  161. package/src/policy/packs.rs +232 -0
  162. package/src/policy/tests.rs +134 -0
  163. package/src/policy.rs +640 -0
  164. package/src/project_list.rs +376 -0
  165. package/src/report_schema/inventory.rs +418 -0
  166. package/src/report_schema.rs +488 -0
  167. package/src/routes.rs +354 -0
  168. package/src/scan/tests.rs +250 -0
  169. package/src/scan.rs +275 -0
  170. package/src/security/detect.rs +639 -0
  171. package/src/security/tests.rs +178 -0
  172. package/src/security.rs +373 -0
  173. package/src/security_gate.rs +555 -0
  174. package/src/symbols/path_filters.rs +27 -0
  175. package/src/symbols/private_type_leaks.rs +125 -0
  176. package/src/symbols/riverpod.rs +113 -0
  177. package/src/symbols/tests.rs +692 -0
  178. package/src/symbols.rs +693 -0
  179. package/src/trace/tests.rs +225 -0
  180. package/src/trace.rs +690 -0
  181. package/src/unsupported.rs +47 -0
  182. package/src/widgets/lifecycle.rs +484 -0
  183. package/src/widgets/params.rs +236 -0
  184. package/src/widgets/tests.rs +430 -0
  185. package/src/widgets/top_level.rs +110 -0
  186. package/src/widgets/unrendered.rs +374 -0
  187. package/src/widgets.rs +590 -0
  188. package/src/workspace_scope.rs +358 -0
@@ -0,0 +1,418 @@
1
+ use serde_json::{Value, json};
2
+
3
+ pub(super) fn clone_group_schema() -> Value {
4
+ json!({
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["fingerprint", "instances", "line_count", "token_count"],
8
+ "properties": {
9
+ "fingerprint": string_schema(),
10
+ "instances": array_ref_schema("clone_instance"),
11
+ "line_count": nonnegative_integer_schema(),
12
+ "token_count": nonnegative_integer_schema()
13
+ }
14
+ })
15
+ }
16
+
17
+ pub(super) fn clone_instance_schema() -> Value {
18
+ json!({
19
+ "type": "object",
20
+ "additionalProperties": false,
21
+ "required": ["path", "start_line", "end_line", "column"],
22
+ "properties": {
23
+ "path": string_schema(),
24
+ "start_line": positive_integer_schema(),
25
+ "end_line": positive_integer_schema(),
26
+ "column": nonnegative_integer_schema()
27
+ }
28
+ })
29
+ }
30
+
31
+ pub(super) fn complexity_finding_schema() -> Value {
32
+ json!({
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "required": [
36
+ "rule_id",
37
+ "path",
38
+ "symbol",
39
+ "kind",
40
+ "line",
41
+ "column",
42
+ "cyclomatic_complexity",
43
+ "cognitive_complexity",
44
+ "line_coverage_percent",
45
+ "covered_lines",
46
+ "executable_lines",
47
+ "crap_score",
48
+ "coverage_status",
49
+ "contributions"
50
+ ],
51
+ "properties": {
52
+ "rule_id": string_schema(),
53
+ "path": string_schema(),
54
+ "symbol": string_schema(),
55
+ "kind": string_schema(),
56
+ "line": positive_integer_schema(),
57
+ "column": nonnegative_integer_schema(),
58
+ "cyclomatic_complexity": nonnegative_integer_schema(),
59
+ "cognitive_complexity": nonnegative_integer_schema(),
60
+ "line_coverage_percent": nullable_nonnegative_integer_schema(),
61
+ "covered_lines": nullable_nonnegative_integer_schema(),
62
+ "executable_lines": nullable_nonnegative_integer_schema(),
63
+ "crap_score": nullable_nonnegative_integer_schema(),
64
+ "coverage_status": nullable_string_schema(),
65
+ "effective_thresholds": { "$ref": "#/$defs/effective_thresholds" },
66
+ "threshold_source": nullable_string_schema(),
67
+ "threshold_reason": nullable_string_schema(),
68
+ "contributions": array_ref_schema("complexity_contribution")
69
+ }
70
+ })
71
+ }
72
+
73
+ pub(super) fn complexity_contribution_schema() -> Value {
74
+ json!({
75
+ "type": "object",
76
+ "additionalProperties": false,
77
+ "required": ["line", "column", "kind", "cyclomatic", "cognitive", "nesting"],
78
+ "properties": {
79
+ "line": positive_integer_schema(),
80
+ "column": nonnegative_integer_schema(),
81
+ "kind": string_schema(),
82
+ "cyclomatic": nonnegative_integer_schema(),
83
+ "cognitive": nonnegative_integer_schema(),
84
+ "nesting": nonnegative_integer_schema()
85
+ }
86
+ })
87
+ }
88
+
89
+ pub(super) fn effective_thresholds_schema() -> Value {
90
+ json!({
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "properties": {
94
+ "max_cyclomatic": nonnegative_integer_schema(),
95
+ "max_cognitive": nonnegative_integer_schema(),
96
+ "max_crap": nonnegative_integer_schema()
97
+ }
98
+ })
99
+ }
100
+
101
+ pub(super) fn file_health_score_schema() -> Value {
102
+ json!({
103
+ "type": "object",
104
+ "additionalProperties": false,
105
+ "required": [
106
+ "path",
107
+ "score",
108
+ "functions",
109
+ "complex_functions",
110
+ "max_cyclomatic_complexity",
111
+ "max_cognitive_complexity",
112
+ "max_crap_score",
113
+ "coverage_status",
114
+ "covered_lines",
115
+ "executable_lines",
116
+ "line_coverage_percent",
117
+ "reasons",
118
+ "owners",
119
+ "owner_source",
120
+ "owner_section"
121
+ ],
122
+ "properties": {
123
+ "path": string_schema(),
124
+ "score": nonnegative_integer_schema(),
125
+ "functions": nonnegative_integer_schema(),
126
+ "complex_functions": nonnegative_integer_schema(),
127
+ "max_cyclomatic_complexity": nonnegative_integer_schema(),
128
+ "max_cognitive_complexity": nonnegative_integer_schema(),
129
+ "max_crap_score": nonnegative_integer_schema(),
130
+ "coverage_status": coverage_status_schema(),
131
+ "covered_lines": nullable_nonnegative_integer_schema(),
132
+ "executable_lines": nullable_nonnegative_integer_schema(),
133
+ "line_coverage_percent": nullable_nonnegative_integer_schema(),
134
+ "reasons": string_array_schema(),
135
+ "owners": string_array_schema(),
136
+ "owner_source": nullable_string_schema(),
137
+ "owner_section": nullable_string_schema()
138
+ }
139
+ })
140
+ }
141
+
142
+ pub(super) fn health_hotspot_schema() -> Value {
143
+ health_location_score_schema(&[
144
+ "path",
145
+ "line",
146
+ "column",
147
+ "score",
148
+ "reasons",
149
+ "owners",
150
+ "owner_source",
151
+ "owner_section",
152
+ ])
153
+ }
154
+
155
+ pub(super) fn refactoring_target_schema() -> Value {
156
+ json!({
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": [
160
+ "path",
161
+ "line",
162
+ "column",
163
+ "score",
164
+ "priority",
165
+ "reasons",
166
+ "owners",
167
+ "owner_source",
168
+ "owner_section"
169
+ ],
170
+ "properties": {
171
+ "path": string_schema(),
172
+ "line": positive_integer_schema(),
173
+ "column": nonnegative_integer_schema(),
174
+ "score": nonnegative_integer_schema(),
175
+ "priority": nonnegative_integer_schema(),
176
+ "reasons": string_array_schema(),
177
+ "owners": string_array_schema(),
178
+ "owner_source": nullable_string_schema(),
179
+ "owner_section": nullable_string_schema()
180
+ }
181
+ })
182
+ }
183
+
184
+ pub(super) fn feature_flag_schema() -> Value {
185
+ json!({
186
+ "type": "object",
187
+ "additionalProperties": false,
188
+ "required": ["name", "source", "provider", "confidence", "occurrences"],
189
+ "properties": {
190
+ "name": string_schema(),
191
+ "source": { "type": "string", "enum": ["compile-time-environment", "process-environment", "sdk-call"] },
192
+ "provider": string_schema(),
193
+ "confidence": confidence_schema(),
194
+ "occurrences": array_ref_schema("feature_flag_occurrence")
195
+ }
196
+ })
197
+ }
198
+
199
+ pub(super) fn feature_flag_occurrence_schema() -> Value {
200
+ json!({
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "required": ["path", "line", "column", "expression"],
204
+ "properties": location_expression_properties()
205
+ })
206
+ }
207
+
208
+ pub(super) fn security_candidate_schema() -> Value {
209
+ json!({
210
+ "type": "object",
211
+ "additionalProperties": false,
212
+ "required": [
213
+ "rule_id",
214
+ "finding_id",
215
+ "fingerprint",
216
+ "category",
217
+ "cwe",
218
+ "severity",
219
+ "candidate",
220
+ "sink",
221
+ "confidence",
222
+ "occurrences",
223
+ "evidence",
224
+ "trace"
225
+ ],
226
+ "properties": {
227
+ "rule_id": string_schema(),
228
+ "finding_id": string_schema(),
229
+ "fingerprint": string_schema(),
230
+ "category": security_category_schema(),
231
+ "cwe": string_array_schema(),
232
+ "severity": severity_schema(),
233
+ "candidate": {
234
+ "type": "object",
235
+ "additionalProperties": false,
236
+ "required": ["source", "sink", "boundary"],
237
+ "properties": {
238
+ "source": string_schema(),
239
+ "sink": string_schema(),
240
+ "boundary": string_schema()
241
+ }
242
+ },
243
+ "sink": string_schema(),
244
+ "confidence": confidence_schema(),
245
+ "occurrences": array_ref_schema("security_occurrence"),
246
+ "reachability": security_reachability_schema(),
247
+ "evidence": {
248
+ "type": "object",
249
+ "additionalProperties": false,
250
+ "required": ["occurrences"],
251
+ "properties": {
252
+ "occurrences": array_ref_schema("security_occurrence")
253
+ }
254
+ },
255
+ "trace": {
256
+ "type": "array",
257
+ "items": security_trace_step_schema()
258
+ }
259
+ }
260
+ })
261
+ }
262
+
263
+ pub(super) fn security_occurrence_schema() -> Value {
264
+ let mut properties = location_expression_properties();
265
+ if let Some(object) = properties.as_object_mut() {
266
+ object.insert("evidence".to_owned(), string_schema());
267
+ object.insert("reachability".to_owned(), security_reachability_schema());
268
+ }
269
+ json!({
270
+ "type": "object",
271
+ "additionalProperties": false,
272
+ "required": ["path", "line", "column", "expression", "evidence"],
273
+ "properties": properties
274
+ })
275
+ }
276
+
277
+ fn security_reachability_schema() -> Value {
278
+ json!({
279
+ "type": "object",
280
+ "additionalProperties": false,
281
+ "required": [
282
+ "reachable_from_entrypoint",
283
+ "taint_confidence",
284
+ "entry_points",
285
+ "reachable_occurrences"
286
+ ],
287
+ "properties": {
288
+ "reachable_from_entrypoint": { "type": "boolean" },
289
+ "taint_confidence": { "type": "string", "enum": ["module-level"] },
290
+ "entry_points": string_array_schema(),
291
+ "reachable_occurrences": nonnegative_integer_schema()
292
+ }
293
+ })
294
+ }
295
+
296
+ fn security_trace_step_schema() -> Value {
297
+ let mut properties = location_expression_properties();
298
+ if let Some(object) = properties.as_object_mut() {
299
+ object.insert(
300
+ "role".to_owned(),
301
+ json!({ "type": "string", "enum": ["source", "sink", "boundary"] }),
302
+ );
303
+ object.insert("evidence".to_owned(), string_schema());
304
+ }
305
+ json!({
306
+ "type": "object",
307
+ "additionalProperties": false,
308
+ "required": ["role", "path", "line", "column", "expression", "evidence"],
309
+ "properties": properties
310
+ })
311
+ }
312
+
313
+ pub(super) fn attack_surface_schema() -> Value {
314
+ json!({
315
+ "type": "object",
316
+ "additionalProperties": false,
317
+ "required": ["category", "path", "line", "column", "surface", "verification_prompt"],
318
+ "properties": {
319
+ "category": security_category_schema(),
320
+ "path": string_schema(),
321
+ "line": positive_integer_schema(),
322
+ "column": nonnegative_integer_schema(),
323
+ "surface": string_schema(),
324
+ "verification_prompt": string_schema()
325
+ }
326
+ })
327
+ }
328
+
329
+ fn health_location_score_schema(required: &[&str]) -> Value {
330
+ json!({
331
+ "type": "object",
332
+ "additionalProperties": false,
333
+ "required": required.to_vec(),
334
+ "properties": {
335
+ "path": string_schema(),
336
+ "line": positive_integer_schema(),
337
+ "column": nonnegative_integer_schema(),
338
+ "score": nonnegative_integer_schema(),
339
+ "reasons": string_array_schema(),
340
+ "owners": string_array_schema(),
341
+ "owner_source": nullable_string_schema(),
342
+ "owner_section": nullable_string_schema()
343
+ }
344
+ })
345
+ }
346
+
347
+ fn location_expression_properties() -> Value {
348
+ json!({
349
+ "path": string_schema(),
350
+ "line": positive_integer_schema(),
351
+ "column": nonnegative_integer_schema(),
352
+ "expression": string_schema()
353
+ })
354
+ }
355
+
356
+ fn security_category_schema() -> Value {
357
+ json!({
358
+ "type": "string",
359
+ "enum": [
360
+ "hardcoded-secret",
361
+ "insecure-transport",
362
+ "tls-bypass",
363
+ "web-view-risk",
364
+ "process-execution",
365
+ "raw-sql",
366
+ "plain-secret-storage"
367
+ ]
368
+ })
369
+ }
370
+
371
+ fn coverage_status_schema() -> Value {
372
+ json!({
373
+ "type": "string",
374
+ "enum": ["not-requested", "missing", "no-executable-lines", "uncovered", "covered"]
375
+ })
376
+ }
377
+
378
+ fn confidence_schema() -> Value {
379
+ json!({ "type": "string", "enum": ["low", "medium", "high"] })
380
+ }
381
+
382
+ fn severity_schema() -> Value {
383
+ json!({ "type": "string", "enum": ["error", "warning"] })
384
+ }
385
+
386
+ fn array_ref_schema(definition: &str) -> Value {
387
+ json!({
388
+ "type": "array",
389
+ "items": { "$ref": format!("#/$defs/{definition}") }
390
+ })
391
+ }
392
+
393
+ fn string_schema() -> Value {
394
+ json!({ "type": "string" })
395
+ }
396
+
397
+ fn nullable_string_schema() -> Value {
398
+ json!({ "type": ["string", "null"] })
399
+ }
400
+
401
+ fn positive_integer_schema() -> Value {
402
+ json!({ "type": "integer", "minimum": 1 })
403
+ }
404
+
405
+ fn nonnegative_integer_schema() -> Value {
406
+ json!({ "type": "integer", "minimum": 0 })
407
+ }
408
+
409
+ fn nullable_nonnegative_integer_schema() -> Value {
410
+ json!({ "type": ["integer", "null"], "minimum": 0 })
411
+ }
412
+
413
+ fn string_array_schema() -> Value {
414
+ json!({
415
+ "type": "array",
416
+ "items": { "type": "string" }
417
+ })
418
+ }