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,488 @@
1
+ use serde_json::{Value, json};
2
+
3
+ use crate::output::SCHEMA_VERSION;
4
+
5
+ mod inventory;
6
+
7
+ /// Return the JSON schema for `dart-decimate.report.v1` CLI reports.
8
+ #[must_use]
9
+ pub fn report_schema() -> Value {
10
+ json!({
11
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
12
+ "schema_version": SCHEMA_VERSION,
13
+ "title": "Dart Decimate report",
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": [
17
+ "schema_version",
18
+ "kind",
19
+ "tool",
20
+ "command",
21
+ "verdict",
22
+ "summary",
23
+ "findings",
24
+ "clone_groups",
25
+ "complexity",
26
+ "file_scores",
27
+ "hotspots",
28
+ "refactoring_targets",
29
+ "threshold_overrides",
30
+ "feature_flags",
31
+ "security_candidates",
32
+ "attack_surface",
33
+ "next_steps"
34
+ ],
35
+ "properties": {
36
+ "schema_version": { "const": SCHEMA_VERSION },
37
+ "kind": { "type": "string", "enum": kind_values() },
38
+ "tool": { "const": "dart-decimate" },
39
+ "command": { "type": "string", "enum": command_values() },
40
+ "verdict": { "type": "string", "enum": ["pass", "fail"] },
41
+ "summary": { "$ref": "#/$defs/summary" },
42
+ "findings": {
43
+ "type": "array",
44
+ "items": { "$ref": "#/$defs/finding" }
45
+ },
46
+ "clone_groups": array_ref_schema("clone_group"),
47
+ "complexity": array_ref_schema("complexity_finding"),
48
+ "file_scores": array_ref_schema("file_health_score"),
49
+ "hotspots": array_ref_schema("health_hotspot"),
50
+ "refactoring_targets": array_ref_schema("refactoring_target"),
51
+ "threshold_overrides": threshold_overrides_schema(),
52
+ "feature_flags": array_ref_schema("feature_flag"),
53
+ "security_candidates": array_ref_schema("security_candidate"),
54
+ "attack_surface": array_ref_schema("attack_surface"),
55
+ "runtime_coverage": { "$ref": "#/$defs/runtime_coverage" },
56
+ "next_steps": {
57
+ "type": "array",
58
+ "items": { "$ref": "#/$defs/next_step" }
59
+ }
60
+ },
61
+ "$defs": {
62
+ "summary": summary_schema(),
63
+ "audit_attribution": audit_attribution_schema(),
64
+ "audit_attribution_counts": audit_attribution_counts_schema(),
65
+ "finding": finding_schema(),
66
+ "finding_edge": finding_edge_schema(),
67
+ "finding_action": finding_action_schema(),
68
+ "clone_group": inventory::clone_group_schema(),
69
+ "clone_instance": inventory::clone_instance_schema(),
70
+ "complexity_finding": inventory::complexity_finding_schema(),
71
+ "complexity_contribution": inventory::complexity_contribution_schema(),
72
+ "effective_thresholds": inventory::effective_thresholds_schema(),
73
+ "file_health_score": inventory::file_health_score_schema(),
74
+ "health_hotspot": inventory::health_hotspot_schema(),
75
+ "refactoring_target": inventory::refactoring_target_schema(),
76
+ "feature_flag": inventory::feature_flag_schema(),
77
+ "feature_flag_occurrence": inventory::feature_flag_occurrence_schema(),
78
+ "security_candidate": inventory::security_candidate_schema(),
79
+ "security_occurrence": inventory::security_occurrence_schema(),
80
+ "attack_surface": inventory::attack_surface_schema(),
81
+ "runtime_coverage": runtime_coverage_schema(),
82
+ "threshold_override": threshold_override_schema(),
83
+ "next_step": next_step_schema()
84
+ }
85
+ })
86
+ }
87
+
88
+ fn command_values() -> Value {
89
+ json!([
90
+ "check",
91
+ "audit",
92
+ "dead-code",
93
+ "cycles",
94
+ "dupes",
95
+ "health",
96
+ "flags",
97
+ "security"
98
+ ])
99
+ }
100
+
101
+ fn kind_values() -> Value {
102
+ json!([
103
+ "combined",
104
+ "audit",
105
+ "dead-code",
106
+ "cycles",
107
+ "dupes",
108
+ "health",
109
+ "flags",
110
+ "security"
111
+ ])
112
+ }
113
+
114
+ fn summary_schema() -> Value {
115
+ let mut properties = serde_json::Map::new();
116
+ for key in [
117
+ "files",
118
+ "edges",
119
+ "unresolved_dependencies",
120
+ "part_of_violations",
121
+ "unused_dependencies",
122
+ "unused_dev_dependencies",
123
+ "test_only_dependencies",
124
+ "dependency_overrides",
125
+ "unused_dependency_overrides",
126
+ "misconfigured_dependency_overrides",
127
+ "unlisted_dependencies",
128
+ "private_src_imports",
129
+ "dead_files",
130
+ "unused_exports",
131
+ "unused_types",
132
+ "private_type_leaks",
133
+ "unused_enum_members",
134
+ "unused_class_members",
135
+ "duplicate_exports",
136
+ "route_collisions",
137
+ "private_widget_classes",
138
+ "widget_top_level_functions",
139
+ "unused_widget_params",
140
+ "unrendered_widgets",
141
+ "missing_context_mounted_after_await",
142
+ "code_duplications",
143
+ "duplication_analyzed_lines",
144
+ "duplicated_lines",
145
+ "duplication_percentage_basis_points",
146
+ "quality_score",
147
+ "health_files",
148
+ "functions",
149
+ "complex_functions",
150
+ "max_cyclomatic_complexity",
151
+ "max_cognitive_complexity",
152
+ "coverage_files",
153
+ "coverage_gaps",
154
+ "crap_functions",
155
+ "max_crap_score",
156
+ "file_scores",
157
+ "hotspots",
158
+ "refactoring_targets",
159
+ "feature_flags",
160
+ "feature_flag_occurrences",
161
+ "security_candidates",
162
+ "security_candidate_occurrences",
163
+ "attack_surface",
164
+ "missing_entry_points",
165
+ "cycles",
166
+ "re_export_cycles",
167
+ "boundary_violations",
168
+ "boundary_coverage",
169
+ "boundary_call_violations",
170
+ "policy_violations",
171
+ "missing_suppression_reasons",
172
+ "findings",
173
+ ] {
174
+ properties.insert(key.to_owned(), json!({ "type": "integer", "minimum": 0 }));
175
+ }
176
+ properties.insert(
177
+ "risk_score".to_owned(),
178
+ json!({ "type": "integer", "minimum": 0, "maximum": 100 }),
179
+ );
180
+ properties.insert(
181
+ "duplication_threshold_basis_points".to_owned(),
182
+ json!({ "type": "integer", "minimum": 0, "maximum": 10000 }),
183
+ );
184
+ properties.insert(
185
+ "duplication_threshold_exceeded".to_owned(),
186
+ json!({ "type": "boolean" }),
187
+ );
188
+ properties.insert(
189
+ "risk_level".to_owned(),
190
+ json!({ "type": "string", "enum": ["pass", "warn", "fail"] }),
191
+ );
192
+ properties.insert(
193
+ "attribution".to_owned(),
194
+ json!({ "$ref": "#/$defs/audit_attribution" }),
195
+ );
196
+
197
+ json!({
198
+ "type": "object",
199
+ "additionalProperties": false,
200
+ "required": properties
201
+ .keys()
202
+ .filter(|key| {
203
+ !matches!(
204
+ key.as_str(),
205
+ "risk_score" | "risk_level" | "attribution" | "duplication_threshold_basis_points"
206
+ )
207
+ })
208
+ .cloned()
209
+ .collect::<Vec<_>>(),
210
+ "properties": properties
211
+ })
212
+ }
213
+
214
+ fn audit_attribution_schema() -> Value {
215
+ json!({
216
+ "type": "object",
217
+ "additionalProperties": false,
218
+ "required": ["introduced", "pre_existing"],
219
+ "properties": {
220
+ "introduced": { "$ref": "#/$defs/audit_attribution_counts" },
221
+ "pre_existing": { "$ref": "#/$defs/audit_attribution_counts" }
222
+ }
223
+ })
224
+ }
225
+
226
+ fn audit_attribution_counts_schema() -> Value {
227
+ let mut properties = serde_json::Map::new();
228
+ for key in [
229
+ "findings",
230
+ "error_findings",
231
+ "warning_findings",
232
+ "safe_to_delete",
233
+ "files",
234
+ ] {
235
+ properties.insert(key.to_owned(), json!({ "type": "integer", "minimum": 0 }));
236
+ }
237
+
238
+ json!({
239
+ "type": "object",
240
+ "additionalProperties": false,
241
+ "required": properties.keys().cloned().collect::<Vec<_>>(),
242
+ "properties": properties
243
+ })
244
+ }
245
+
246
+ fn finding_schema() -> Value {
247
+ json!({
248
+ "type": "object",
249
+ "additionalProperties": false,
250
+ "required": [
251
+ "rule_id",
252
+ "fingerprint",
253
+ "kind",
254
+ "severity",
255
+ "message",
256
+ "path",
257
+ "line",
258
+ "column",
259
+ "safe_to_delete",
260
+ "files",
261
+ "edge",
262
+ "actions"
263
+ ],
264
+ "properties": {
265
+ "rule_id": { "type": "string" },
266
+ "fingerprint": { "type": ["string", "null"] },
267
+ "kind": { "type": "string", "enum": finding_kind_values() },
268
+ "severity": { "type": "string", "enum": ["error", "warning"] },
269
+ "message": { "type": "string" },
270
+ "path": { "type": "string" },
271
+ "line": { "type": "integer", "minimum": 1 },
272
+ "column": { "type": "integer", "minimum": 0 },
273
+ "safe_to_delete": { "type": "boolean" },
274
+ "files": {
275
+ "type": "array",
276
+ "items": { "type": "string" }
277
+ },
278
+ "edge": {
279
+ "oneOf": [
280
+ { "type": "null" },
281
+ { "$ref": "#/$defs/finding_edge" }
282
+ ]
283
+ },
284
+ "actions": {
285
+ "type": "array",
286
+ "items": { "$ref": "#/$defs/finding_action" }
287
+ }
288
+ }
289
+ })
290
+ }
291
+
292
+ fn finding_kind_values() -> Value {
293
+ json!([
294
+ "dead-file",
295
+ "unused-export",
296
+ "unused-type",
297
+ "private-type-leak",
298
+ "unused-enum-member",
299
+ "unused-class-member",
300
+ "duplicate-export",
301
+ "route-collision",
302
+ "private-widget-class",
303
+ "widget-top-level-function-boundary",
304
+ "unused-widget-param",
305
+ "unrendered-widget",
306
+ "missing-context-mounted-after-await",
307
+ "missing-entry-point",
308
+ "circular-dependency",
309
+ "re-export-cycle",
310
+ "boundary-violation",
311
+ "boundary-coverage",
312
+ "boundary-call-violation",
313
+ "policy-violation",
314
+ "unresolved-dependency",
315
+ "part-of-violation",
316
+ "unused-dependency",
317
+ "unused-dev-dependency",
318
+ "test-only-dependency",
319
+ "unused-dependency-override",
320
+ "misconfigured-dependency-override",
321
+ "unlisted-dependency",
322
+ "private-src-import",
323
+ "code-duplication",
324
+ "high-cyclomatic-complexity",
325
+ "high-cognitive-complexity",
326
+ "high-complexity",
327
+ "coverage-gap",
328
+ "high-crap-score",
329
+ "health-hotspot",
330
+ "refactoring-target",
331
+ "feature-flag",
332
+ "security-candidate",
333
+ "stale-suppression",
334
+ "missing-suppression-reason"
335
+ ])
336
+ }
337
+
338
+ fn finding_edge_schema() -> Value {
339
+ json!({
340
+ "type": "object",
341
+ "additionalProperties": false,
342
+ "required": ["from", "to", "specifier", "kind"],
343
+ "properties": {
344
+ "from": { "type": "string" },
345
+ "to": { "type": "string" },
346
+ "specifier": { "type": "string" },
347
+ "kind": { "type": "string", "enum": ["import", "export", "part", "augment"] }
348
+ }
349
+ })
350
+ }
351
+
352
+ fn finding_action_schema() -> Value {
353
+ json!({
354
+ "type": "object",
355
+ "additionalProperties": false,
356
+ "required": ["action", "type", "description", "auto_fixable"],
357
+ "properties": {
358
+ "action": { "type": "string" },
359
+ "type": { "type": "string" },
360
+ "description": { "type": "string" },
361
+ "auto_fixable": { "type": "boolean" },
362
+ "command": { "type": "string" },
363
+ "argv": {
364
+ "type": "array",
365
+ "items": { "type": "string" }
366
+ },
367
+ "target_path": { "type": "string" },
368
+ "target_symbol": { "type": "string" },
369
+ "target_dependency": { "type": "string" },
370
+ "target_end_line": { "type": "integer", "minimum": 1 },
371
+ "suppression_comment": { "type": "string" },
372
+ "config_key": { "type": "string" },
373
+ "value_schema": { "type": "string" }
374
+ }
375
+ })
376
+ }
377
+
378
+ fn next_step_schema() -> Value {
379
+ json!({
380
+ "type": "object",
381
+ "additionalProperties": false,
382
+ "required": ["id", "command", "reason"],
383
+ "properties": {
384
+ "id": { "type": "string" },
385
+ "command": { "type": "string" },
386
+ "reason": { "type": "string" }
387
+ }
388
+ })
389
+ }
390
+
391
+ fn runtime_coverage_schema() -> Value {
392
+ json!({
393
+ "type": "object",
394
+ "additionalProperties": false,
395
+ "required": [
396
+ "verdict",
397
+ "signals",
398
+ "summary",
399
+ "findings",
400
+ "hot_paths",
401
+ "coverage_intelligence",
402
+ "blast_radius",
403
+ "importance",
404
+ "actionable",
405
+ "provenance",
406
+ "watermark",
407
+ "warnings"
408
+ ],
409
+ "properties": {
410
+ "verdict": { "type": "string", "enum": ["pass", "warn"] },
411
+ "signals": string_array_schema(),
412
+ "summary": { "type": "object", "additionalProperties": true },
413
+ "findings": inventory_array_schema(),
414
+ "hot_paths": inventory_array_schema(),
415
+ "coverage_intelligence": inventory_array_schema(),
416
+ "blast_radius": inventory_array_schema(),
417
+ "importance": inventory_array_schema(),
418
+ "actionable": { "type": "object", "additionalProperties": true },
419
+ "provenance": { "type": "object", "additionalProperties": true },
420
+ "watermark": { "type": "object", "additionalProperties": true },
421
+ "warnings": string_array_schema()
422
+ }
423
+ })
424
+ }
425
+
426
+ fn threshold_overrides_schema() -> Value {
427
+ json!({
428
+ "type": "array",
429
+ "items": { "$ref": "#/$defs/threshold_override" }
430
+ })
431
+ }
432
+
433
+ fn threshold_override_schema() -> Value {
434
+ json!({
435
+ "type": "object",
436
+ "additionalProperties": false,
437
+ "required": [
438
+ "index",
439
+ "files",
440
+ "functions",
441
+ "max_cyclomatic",
442
+ "max_cognitive",
443
+ "max_crap",
444
+ "reason",
445
+ "active",
446
+ "stale",
447
+ "no_match",
448
+ "matched_functions"
449
+ ],
450
+ "properties": {
451
+ "index": { "type": "integer", "minimum": 0 },
452
+ "files": string_array_schema(),
453
+ "functions": string_array_schema(),
454
+ "max_cyclomatic": { "type": ["integer", "null"], "minimum": 1 },
455
+ "max_cognitive": { "type": ["integer", "null"], "minimum": 1 },
456
+ "max_crap": { "type": ["integer", "null"], "minimum": 1 },
457
+ "reason": { "type": ["string", "null"] },
458
+ "active": { "type": "boolean" },
459
+ "stale": { "type": "boolean" },
460
+ "no_match": { "type": "boolean" },
461
+ "matched_functions": string_array_schema()
462
+ }
463
+ })
464
+ }
465
+
466
+ fn array_ref_schema(definition: &str) -> Value {
467
+ json!({
468
+ "type": "array",
469
+ "items": { "$ref": format!("#/$defs/{definition}") }
470
+ })
471
+ }
472
+
473
+ fn string_array_schema() -> Value {
474
+ json!({
475
+ "type": "array",
476
+ "items": { "type": "string" }
477
+ })
478
+ }
479
+
480
+ fn inventory_array_schema() -> Value {
481
+ json!({
482
+ "type": "array",
483
+ "items": {
484
+ "type": "object",
485
+ "additionalProperties": true
486
+ }
487
+ })
488
+ }