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
package/src/explain.rs ADDED
@@ -0,0 +1,692 @@
1
+ use serde::{Deserialize, Serialize};
2
+ pub const EXPLAIN_SCHEMA_VERSION: &str = "dart-decimate.explain.v1";
3
+
4
+ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5
+ pub struct ExplainReport {
6
+ pub schema_version: String,
7
+ pub kind: String,
8
+ pub id: String,
9
+ pub name: String,
10
+ pub issue_type: String,
11
+ pub aliases: Vec<String>,
12
+ pub summary: String,
13
+ pub rationale: String,
14
+ pub example: String,
15
+ pub how_to_fix: String,
16
+ pub suppressions: Vec<String>,
17
+ pub related_commands: Vec<String>,
18
+ pub docs: String,
19
+ }
20
+
21
+ #[derive(Debug, thiserror::Error)]
22
+ pub enum ExplainError {
23
+ #[error("unknown issue type {issue_type:?}")]
24
+ UnknownIssueType { issue_type: String },
25
+ }
26
+
27
+ /// # Errors
28
+ /// Returns [`ExplainError`] when `issue_type` is not supported.
29
+ pub fn explain_issue(issue_type: &str) -> Result<ExplainReport, ExplainError> {
30
+ let normalized = normalize_issue_type(issue_type);
31
+ let Some(issue) = ISSUES
32
+ .iter()
33
+ .copied()
34
+ .find(|issue| issue.aliases.iter().any(|alias| *alias == normalized))
35
+ else {
36
+ return Err(ExplainError::UnknownIssueType {
37
+ issue_type: issue_type.to_owned(),
38
+ });
39
+ };
40
+
41
+ Ok(ExplainReport {
42
+ schema_version: EXPLAIN_SCHEMA_VERSION.to_owned(),
43
+ kind: "explain".to_owned(),
44
+ id: issue.rule_id.to_owned(),
45
+ name: issue.title.to_owned(),
46
+ issue_type: issue.issue_type.to_owned(),
47
+ aliases: issue.aliases.iter().map(ToString::to_string).collect(),
48
+ summary: issue.summary.to_owned(),
49
+ rationale: issue.rationale.to_owned(),
50
+ example: issue.example.to_owned(),
51
+ how_to_fix: issue.fix_guidance.to_owned(),
52
+ suppressions: issue.suppressions.iter().map(ToString::to_string).collect(),
53
+ related_commands: issue
54
+ .related_commands
55
+ .iter()
56
+ .map(ToString::to_string)
57
+ .collect(),
58
+ docs: issue.docs_url.to_owned(),
59
+ })
60
+ }
61
+
62
+ #[must_use]
63
+ pub fn render_explain_report(report: &ExplainReport) -> String {
64
+ format!(
65
+ "{}\n{}\n\n{}\n\nWhy it matters\n{}\n\nExample\n{}\n\nHow to fix\n{}\n\nDocs: {}\n",
66
+ report.name,
67
+ report.id,
68
+ report.summary,
69
+ report.rationale,
70
+ report.example,
71
+ report.how_to_fix,
72
+ report.docs
73
+ )
74
+ }
75
+
76
+ fn normalize_issue_type(issue_type: &str) -> String {
77
+ let trimmed = issue_type.trim().to_ascii_lowercase();
78
+ let stripped = trimmed
79
+ .strip_prefix("dart-decimate/")
80
+ .or_else(|| trimmed.strip_prefix("fallow/"))
81
+ .unwrap_or(&trimmed);
82
+ stripped
83
+ .chars()
84
+ .map(|ch| match ch {
85
+ '_' | ' ' => '-',
86
+ _ => ch,
87
+ })
88
+ .collect()
89
+ }
90
+
91
+ #[derive(Debug, Clone, Copy)]
92
+ struct IssueExplanation {
93
+ issue_type: &'static str,
94
+ rule_id: &'static str,
95
+ aliases: &'static [&'static str],
96
+ title: &'static str,
97
+ summary: &'static str,
98
+ rationale: &'static str,
99
+ example: &'static str,
100
+ fix_guidance: &'static str,
101
+ suppressions: &'static [&'static str],
102
+ related_commands: &'static [&'static str],
103
+ docs_url: &'static str,
104
+ }
105
+
106
+ macro_rules! issue {
107
+ (
108
+ $issue_type:expr,
109
+ $rule_id:expr,
110
+ $aliases:expr,
111
+ $title:expr,
112
+ $summary:expr,
113
+ $rationale:expr,
114
+ $example:expr,
115
+ $fix_guidance:expr,
116
+ $suppressions:expr,
117
+ $related_commands:expr $(,)?
118
+ ) => {
119
+ IssueExplanation {
120
+ issue_type: $issue_type,
121
+ rule_id: $rule_id,
122
+ aliases: $aliases,
123
+ title: $title,
124
+ summary: $summary,
125
+ rationale: $rationale,
126
+ example: $example,
127
+ fix_guidance: $fix_guidance,
128
+ suppressions: $suppressions,
129
+ related_commands: $related_commands,
130
+ docs_url: "https://github.com/sgaabdu4/dart-decimate#readme",
131
+ }
132
+ };
133
+ }
134
+
135
+ macro_rules! next_line_suppressions {
136
+ ($rule:literal) => {
137
+ &[concat!("// dart-decimate-ignore-next-line ", $rule)]
138
+ };
139
+ }
140
+
141
+ macro_rules! file_suppressions {
142
+ ($rule:literal) => {
143
+ &[concat!("// dart-decimate-ignore-file ", $rule)]
144
+ };
145
+ }
146
+
147
+ const ISSUES: &[IssueExplanation] = &[
148
+ issue!(
149
+ "unused-file",
150
+ "dart-decimate/dead-file",
151
+ &["unused-file", "unused-files", "dead-file", "dead-files"],
152
+ "Unused file",
153
+ "A Dart file is unreachable from the configured or inferred entry points.",
154
+ "Dart Decimate follows import/export/part/augment edges and reports files outside that graph.",
155
+ "lib/old_screen.dart is not imported by any reachable library.",
156
+ "Trace the file before deletion; generated or externally loaded files should be configured as entry points or ignored.",
157
+ next_line_suppressions!("unused-file"),
158
+ &["dart-decimate trace-file --format json --file <path>"],
159
+ ),
160
+ issue!(
161
+ "unused-export",
162
+ "dart-decimate/unused-export",
163
+ &["unused-export", "unused-exports"],
164
+ "Unused export",
165
+ "A public top-level Dart declaration in reachable code has no reachable syntactic references.",
166
+ "Dart library privacy is based on leading underscores, so public declarations are candidates for API cleanup.",
167
+ "class LegacyApi {} is public but never referenced or re-exported from live code.",
168
+ "Run `dart-decimate trace-symbol` before editing; do not delete public API without a fix preview.",
169
+ next_line_suppressions!("unused-export"),
170
+ &["dart-decimate trace-symbol --format json --symbol <file>:<symbol>"],
171
+ ),
172
+ issue!(
173
+ "unused-type",
174
+ "dart-decimate/unused-type",
175
+ &["unused-type", "unused-types", "type-alias", "type-aliases"],
176
+ "Unused type",
177
+ "A public Dart typedef in reachable code has no reachable syntactic references.",
178
+ "Dart typedef declarations are public API when not private, but stale aliases hide real type ownership and migration cleanup.",
179
+ "typedef LegacyId = String; is declared in live code but no reachable file uses LegacyId.",
180
+ "Run `dart-decimate trace-symbol` before editing; aliases used by external APIs should be exported intentionally or suppressed.",
181
+ next_line_suppressions!("unused-type"),
182
+ &["dart-decimate trace-symbol --format json --symbol <file>:<type-alias>"],
183
+ ),
184
+ issue!(
185
+ "private-type-leak",
186
+ "dart-decimate/private-type-leak",
187
+ &["private-type-leak", "private-type-leaks"],
188
+ "Private type leak",
189
+ "An exported Dart declaration signature references a same-library private type.",
190
+ "Dart identifiers starting with `_` are private to their library, including `part` files, so exposing them through public API signatures makes downstream use impossible or misleading.",
191
+ "class Api extends _Hidden {} is public while _Hidden is a private class in the same Dart library.",
192
+ "Rename the private type, hide the declaration from the public surface, or change the signature to a public type. This rule is opt-in with `--private-type-leaks` or `rules.private-type-leak`.",
193
+ next_line_suppressions!("private-type-leak"),
194
+ &["dart-decimate check --format json --private-type-leaks"],
195
+ ),
196
+ issue!(
197
+ "unused-enum-member",
198
+ "dart-decimate/unused-enum-member",
199
+ &["unused-enum-member", "unused-enum-members"],
200
+ "Unused enum member",
201
+ "A non-public-API enum constant is never referenced from reachable Dart code.",
202
+ "Enum constants are declarations and can become stale after feature or state cleanup.",
203
+ "enum Mode { live, legacy } where legacy is never read.",
204
+ "Review serialization and external contracts before removing the member.",
205
+ next_line_suppressions!("unused-enum-member"),
206
+ &["dart-decimate trace-symbol --format json --symbol <file>:<enum>"],
207
+ ),
208
+ issue!(
209
+ "unused-class-member",
210
+ "dart-decimate/unused-class-member",
211
+ &["unused-class-member", "unused-class-members"],
212
+ "Unused class member",
213
+ "A private class-like field, getter, setter, or method is not referenced in its Dart library.",
214
+ "Dart private names are library-scoped, including `part` files, so unused private members are cleanup candidates.",
215
+ "void _legacyHandler() {} is never called in the library.",
216
+ "Check reflection, generated bindings, and framework callbacks before removal.",
217
+ next_line_suppressions!("unused-class-member"),
218
+ &["dart-decimate trace-symbol --format json --symbol <file>:<class>"],
219
+ ),
220
+ issue!(
221
+ "duplicate-export",
222
+ "dart-decimate/duplicate-export",
223
+ &["duplicate-export", "duplicate-exports"],
224
+ "Duplicate export",
225
+ "A public barrel exports the same symbol name from multiple Dart files.",
226
+ "Importers may receive an ambiguous API surface when barrels expose duplicate declarations.",
227
+ "lib/app.dart exports src/a.dart and src/b.dart, both declaring Api.",
228
+ "Rename, hide, or narrow one export path after reviewing the public API.",
229
+ file_suppressions!("duplicate-export"),
230
+ &["dart-decimate trace-symbol --format json --symbol <file>:<symbol>"],
231
+ ),
232
+ issue!(
233
+ "route-collision",
234
+ "dart-decimate/route-collision",
235
+ &["route-collision"],
236
+ "Route collision",
237
+ "Two GoRouter route declarations resolve to the same path pattern or route name.",
238
+ "GoRouter route trees require unique identities, so duplicate paths or names can make navigation ambiguous or fail generated route tables.",
239
+ "GoRoute(path: '/users/:id') and @TypedGoRoute<MemberRoute>(path: '/users/:userId') describe the same path shape.",
240
+ "Rename one route or change one path segment after checking deep-link compatibility.",
241
+ &["// dart-decimate-ignore-next-line route-collision"],
242
+ &["dart-decimate inspect --format json --file <path>"],
243
+ ),
244
+ issue!(
245
+ "private-widget-class",
246
+ "dart-decimate/private-widget-class",
247
+ &["private-widget-class", "flutter-private-widget-class"],
248
+ "Private widget class",
249
+ "A private Dart class extends a Flutter widget base class.",
250
+ "Extracted widgets should be public classes so widget boundaries stay reusable, testable, and discoverable; private State subclasses remain exempt.",
251
+ "class _Header extends StatelessWidget {}",
252
+ "Rename the widget class to a public name or add an explicit suppression when the private widget is intentional.",
253
+ &["// dart-decimate-ignore-next-line private-widget-class"],
254
+ &["dart-decimate check --format json"],
255
+ ),
256
+ issue!(
257
+ "widget-top-level-function-boundary",
258
+ "dart-decimate/widget-top-level-function-boundary",
259
+ &[
260
+ "widget-top-level-function-boundary",
261
+ "top-level-widget-helper"
262
+ ],
263
+ "Widget top-level function boundary",
264
+ "A top-level Dart function returns Flutter UI from a widget or screen file.",
265
+ "Flutter UI helpers should live in widget classes or explicit owning boundaries so dependencies, tests, and reuse stay discoverable.",
266
+ "Widget _buildHeader(BuildContext context) => const SizedBox();",
267
+ "Extract the helper to a public widget class or move it behind another explicit owner.",
268
+ &["// dart-decimate-ignore-next-line widget-top-level-function-boundary"],
269
+ &["dart-decimate check --format json"],
270
+ ),
271
+ issue!(
272
+ "unused-widget-param",
273
+ "dart-decimate/unused-widget-param",
274
+ &[
275
+ "unused-widget-param",
276
+ "unused-widget-params",
277
+ "unused-component-prop"
278
+ ],
279
+ "Unused widget parameter",
280
+ "A Flutter widget constructor parameter is never read by the widget or paired State class.",
281
+ "Stale widget inputs make call sites harder to trust and mirror Fallow's unused component prop cleanup signal.",
282
+ "const UserCard({required String subtitle}) : _subtitle = subtitle; where _subtitle is never read in UserCard or _UserCardState.",
283
+ "Review callers before removing the parameter; Dart Decimate reports this as a warning by default.",
284
+ &["// dart-decimate-ignore-next-line unused-widget-param"],
285
+ &["dart-decimate check --format json"],
286
+ ),
287
+ issue!(
288
+ "missing-context-mounted-after-await",
289
+ "dart-decimate/missing-context-mounted-after-await",
290
+ &["missing-context-mounted-after-await"],
291
+ "Missing context.mounted guard",
292
+ "A Flutter widget or State method awaits and then uses BuildContext without first checking context.mounted.",
293
+ "Async UI callbacks can resume after the widget is disposed; guarding after await prevents stale-context navigation, dialogs, and state access.",
294
+ "await save(); Navigator.of(context).pop(); without `if (!context.mounted) return;` after the await.",
295
+ "Add `if (!context.mounted) return;` immediately after the await before using context.",
296
+ &["// dart-decimate-ignore-next-line missing-context-mounted-after-await"],
297
+ &["dart-decimate check --format json"],
298
+ ),
299
+ issue!(
300
+ "missing-entry-point",
301
+ "dart-decimate/missing-entry-point",
302
+ &["missing-entry-point", "missing-entry-points"],
303
+ "Missing entry point",
304
+ "A configured entry point does not exist in the parsed module graph.",
305
+ "Reachability is only meaningful when entry files can be resolved.",
306
+ "--entry lib/mian.dart points at a typo instead of lib/main.dart.",
307
+ "Fix the entry path or add the missing Dart file.",
308
+ &[],
309
+ &["dart-decimate list --entry-points --format json"],
310
+ ),
311
+ issue!(
312
+ "circular-dependency",
313
+ "dart-decimate/circular-dependency",
314
+ &[
315
+ "circular-dependency",
316
+ "circular-dependencies",
317
+ "circular-deps"
318
+ ],
319
+ "Circular dependency",
320
+ "Two or more Dart files import or export each other in a dependency cycle.",
321
+ "Cycles make ownership and initialization order harder to reason about.",
322
+ "lib/a.dart imports lib/b.dart while lib/b.dart imports lib/a.dart.",
323
+ "Move shared contracts behind a lower-level module or invert the dependency.",
324
+ next_line_suppressions!("circular-dependency"),
325
+ &["dart-decimate trace-file --format json --file <path>"],
326
+ ),
327
+ issue!(
328
+ "re-export-cycle",
329
+ "dart-decimate/re-export-cycle",
330
+ &["re-export-cycle", "re-export-cycles"],
331
+ "Re-export cycle",
332
+ "Barrel files re-export each other without adding useful ownership direction.",
333
+ "Re-export loops can silently confuse API exposure and duplicate-export analysis.",
334
+ "lib/a.dart exports b.dart and lib/b.dart exports a.dart.",
335
+ "Break the barrel loop and expose symbols from a single public owner.",
336
+ file_suppressions!("re-export-cycle"),
337
+ &["dart-decimate cycles --format json"],
338
+ ),
339
+ issue!(
340
+ "boundary-violation",
341
+ "dart-decimate/boundary-violation",
342
+ &["boundary-violation", "boundary-violations"],
343
+ "Boundary violation",
344
+ "A resolved dependency edge crosses a configured forbidden architecture boundary.",
345
+ "Dart Decimate treats imports and exports as ownership edges between Dart files.",
346
+ "lib/domain/order.dart imports lib/ui/order_card.dart.",
347
+ "Move the dependency behind an allowed boundary or invert the ownership.",
348
+ next_line_suppressions!("boundary-violation"),
349
+ &["dart-decimate trace-file --format json --file <path>"],
350
+ ),
351
+ issue!(
352
+ "boundary-coverage",
353
+ "dart-decimate/boundary-coverage",
354
+ &["boundary-coverage", "boundary-coverages"],
355
+ "Boundary coverage",
356
+ "A Dart library file is outside every configured architecture boundary zone.",
357
+ "Coverage checks catch architecture drift where new files land outside the intended layer or feature map.",
358
+ "lib/data/cache.dart exists while only lib/domain and lib/ui are configured boundary zones.",
359
+ "Move the file into a configured zone or add an intentional boundary rule. Use `dart-decimate list --boundaries` to inspect zones before changing code.",
360
+ &[
361
+ "// dart-decimate-ignore-next-line boundary-violation",
362
+ "// dart-decimate-ignore-file boundary-violation"
363
+ ],
364
+ &[
365
+ "dart-decimate list --boundaries --format json",
366
+ "dart-decimate check --format json --boundary-coverage"
367
+ ],
368
+ ),
369
+ issue!(
370
+ "boundary-call-violation",
371
+ "dart-decimate/boundary-violation",
372
+ &[
373
+ "boundary-call-violation",
374
+ "boundary-call-violations",
375
+ "boundary-violation",
376
+ "boundary-violations"
377
+ ],
378
+ "Boundary call violation",
379
+ "A Dart file inside a configured architecture zone calls a forbidden direct callee pattern.",
380
+ "Boundary call checks catch ownership leaks that happen through platform, framework, or service calls instead of imports alone.",
381
+ "lib/ui/page.dart calls SystemChrome.setPreferredOrientations while lib/ui forbids SystemChrome.*.",
382
+ "Move the call into the owning boundary or expose a smaller allowed abstraction.",
383
+ next_line_suppressions!("boundary-call-violation"),
384
+ &["dart-decimate check --format json --boundary-call lib/ui:SystemChrome.*"],
385
+ ),
386
+ issue!(
387
+ "policy-violation",
388
+ "dart-decimate/policy-violation",
389
+ &["policy-violation", "policy-violations"],
390
+ "Policy violation",
391
+ "A Dart import/export URI or direct call matches a declarative policy rule pack.",
392
+ "Rule packs let teams enforce project-specific ownership rules without embedding project code in Dart Decimate.",
393
+ "A policy pack bans dart:io imports or Process.* calls from app code.",
394
+ "Change the import or call to comply with the pack, or suppress the exact scoped rule after owner review.",
395
+ next_line_suppressions!("policy-violation"),
396
+ &[
397
+ "dart-decimate check --format json --policy-pack policy.jsonc",
398
+ "dart-decimate config-schema --format json"
399
+ ],
400
+ ),
401
+ issue!(
402
+ "unresolved-dependency",
403
+ "dart-decimate/unresolved-dependency",
404
+ &[
405
+ "unresolved-dependency",
406
+ "unresolved-import",
407
+ "unresolved-imports",
408
+ "unresolved-augment"
409
+ ],
410
+ "Unresolved dependency",
411
+ "A local import, export, part, or library augment directive did not resolve to a parsed Dart file.",
412
+ "Broken graph edges hide real reachability and cleanup evidence.",
413
+ "import 'src/missing.dart'; points at no file.",
414
+ "Fix the URI, add the file, or adjust package resolution.",
415
+ next_line_suppressions!("unresolved-import"),
416
+ &["dart-decimate trace-file --format json --file <path>"],
417
+ ),
418
+ issue!(
419
+ "part-of-violation",
420
+ "dart-decimate/part-of-violation",
421
+ &["part-of-violation", "part-of-violations", "invalid-part-of"],
422
+ "Part of violation",
423
+ "A Dart part file and its owning library disagree about their reciprocal part relationship.",
424
+ "Invalid library membership corrupts reachability and private-library symbol analysis.",
425
+ "part 'src/model.g.dart'; resolves, but the target says part of app.other; or has no part of directive.",
426
+ "Update either the library's part directive or the part file's part of directive.",
427
+ next_line_suppressions!("part-of-violation"),
428
+ &["dart-decimate inspect --format json --file <part-file>"],
429
+ ),
430
+ issue!(
431
+ "unused-dependency",
432
+ "dart-decimate/unused-dependency",
433
+ &["unused-dependency", "unused-dependencies", "unused-deps"],
434
+ "Unused pub dependency",
435
+ "A declared runtime pub dependency has no matching Dart import/export usage evidence.",
436
+ "Pubspec dependencies drift as imports are removed or packages move between runtime and test code.",
437
+ "dependencies: path is declared but no Dart file imports package:path/...",
438
+ "Run `dart-decimate trace-dependency` before editing pubspec entries.",
439
+ &[],
440
+ &["dart-decimate trace-dependency --format json --dependency <package>"],
441
+ ),
442
+ issue!(
443
+ "unused-dev-dependency",
444
+ "dart-decimate/unused-dev-dependency",
445
+ &[
446
+ "unused-dev-dependency",
447
+ "unused-dev-dependencies",
448
+ "unused-dev-deps"
449
+ ],
450
+ "Unused dev dependency",
451
+ "A declared Dart dev dependency has no matching Dart import/export usage evidence.",
452
+ "Build, test, and generator dependencies can drift after tooling or test cleanup.",
453
+ "dev_dependencies: mockito is declared but no reachable dev/test Dart file imports package:mockito/...",
454
+ "Run `dart-decimate trace-dependency` and check non-Dart tool usage before editing pubspec.yaml.",
455
+ &[],
456
+ &["dart-decimate trace-dependency --format json --dependency <package>"],
457
+ ),
458
+ issue!(
459
+ "test-only-dependency",
460
+ "dart-decimate/test-only-dependency",
461
+ &[
462
+ "test-only-dependency",
463
+ "test-only-dependencies",
464
+ "test-only-deps"
465
+ ],
466
+ "Test-only dependency",
467
+ "A runtime dependency is imported only from test or development paths.",
468
+ "Dart packages should keep test-only imports in `dev_dependencies` when possible.",
469
+ "dependencies: mocktail is declared but only imported under test/.",
470
+ "Move the package to `dev_dependencies` after confirming no runtime imports exist.",
471
+ &[],
472
+ &["dart-decimate trace-dependency --format json --dependency <package>"],
473
+ ),
474
+ issue!(
475
+ "unused-dependency-override",
476
+ "dart-decimate/unused-dependency-override",
477
+ &[
478
+ "unused-dependency-override",
479
+ "unused-dependency-overrides",
480
+ "dependency-override",
481
+ "dependency-overrides"
482
+ ],
483
+ "Unused dependency override",
484
+ "A Dart dependency override is absent from the resolved pubspec.lock package graph.",
485
+ "Overrides are temporary build policy and should not linger after the resolver stops using them.",
486
+ "dependency_overrides: stale is declared but pubspec.lock does not contain stale.",
487
+ "Compare the override with pubspec.lock and active Pub resolution before removing it.",
488
+ &[],
489
+ &["dart-decimate trace-dependency --format json --dependency <package>"],
490
+ ),
491
+ issue!(
492
+ "misconfigured-dependency-override",
493
+ "dart-decimate/misconfigured-dependency-override",
494
+ &[
495
+ "misconfigured-dependency-override",
496
+ "misconfigured-dependency-overrides"
497
+ ],
498
+ "Misconfigured dependency override",
499
+ "A Dart dependency override key or value cannot be honored by Pub.",
500
+ "Overrides should use a valid package name and a non-empty hosted, path, git, sdk, or version value.",
501
+ "dependency_overrides: Bad-Name or dependency_overrides: stale with no value.",
502
+ "Fix the override key or value before relying on the resolved dependency graph.",
503
+ &[],
504
+ &[],
505
+ ),
506
+ issue!(
507
+ "unlisted-dependency",
508
+ "dart-decimate/unlisted-dependency",
509
+ &[
510
+ "unlisted-dependency",
511
+ "unlisted-dependencies",
512
+ "unlisted-deps"
513
+ ],
514
+ "Unlisted pub dependency",
515
+ "A Dart file imports a package that is not declared in its owning pubspec section.",
516
+ "Package imports should be backed by pubspec dependencies for reproducible builds.",
517
+ "import 'package:http/http.dart'; appears without http in pubspec.yaml.",
518
+ "Add the package to the correct pubspec section or remove the import.",
519
+ &[],
520
+ &["dart-decimate trace-dependency --format json --dependency <package>"],
521
+ ),
522
+ issue!(
523
+ "private-src-import",
524
+ "dart-decimate/private-src-import",
525
+ &["private-src-import", "private-src-imports"],
526
+ "Private src import",
527
+ "A Dart file imports or exports another package's private `lib/src` implementation library.",
528
+ "Dart package `lib/src` directories are implementation details; importing them couples code to APIs the dependency does not publish.",
529
+ "import 'package:shared/src/internal.dart'; reaches into shared's private implementation tree.",
530
+ "Import a public library from the package or ask the dependency owner to expose a supported API.",
531
+ next_line_suppressions!("private-src-import"),
532
+ &["dart-decimate check --format json --private-src-imports"],
533
+ ),
534
+ issue!(
535
+ "code-duplication",
536
+ "dart-decimate/code-duplication",
537
+ &[
538
+ "code-duplication",
539
+ "code-duplications",
540
+ "duplication",
541
+ "dupes"
542
+ ],
543
+ "Code duplication",
544
+ "Two or more Dart code blocks are structurally duplicated.",
545
+ "Duplicated blocks increase maintenance cost and can drift during fixes.",
546
+ "Two widgets contain the same validation branch block.",
547
+ "Trace the clone group and extract shared behavior only when the abstraction has a real owner.",
548
+ next_line_suppressions!("code-duplication"),
549
+ &["dart-decimate trace-clone --format json --fingerprint dup:<id>"],
550
+ ),
551
+ issue!(
552
+ "complexity",
553
+ "dart-decimate/high-complexity",
554
+ &[
555
+ "complexity",
556
+ "high-complexity",
557
+ "high-cyclomatic-complexity",
558
+ "high-cognitive-complexity"
559
+ ],
560
+ "High complexity",
561
+ "A function exceeds configured cyclomatic, cognitive, or combined complexity thresholds.",
562
+ "Branch-heavy Dart functions are harder to test, review, and safely change.",
563
+ "A route builder nests loops and conditionals in one function.",
564
+ "Run health with `--complexity-breakdown`, then split branches into named policy or helper owners.",
565
+ next_line_suppressions!("complexity"),
566
+ &["dart-decimate health --format json --complexity-breakdown"],
567
+ ),
568
+ issue!(
569
+ "coverage-gap",
570
+ "dart-decimate/coverage-gap",
571
+ &[
572
+ "coverage-gap",
573
+ "coverage-gaps",
574
+ "untested-file",
575
+ "untested-files"
576
+ ],
577
+ "Coverage gap",
578
+ "A Dart file has no observed covered executable LCOV lines.",
579
+ "LCOV-backed gaps identify code that is reachable to static analysis but unexercised by tests.",
580
+ "lib/src/parser.dart appears in LCOV with DA lines all at zero hits.",
581
+ "Add or run tests that execute the file, then refresh LCOV.",
582
+ file_suppressions!("coverage-gaps"),
583
+ &["dart-decimate health --format json --coverage-gaps --coverage coverage/lcov.info"],
584
+ ),
585
+ issue!(
586
+ "high-crap-score",
587
+ "dart-decimate/high-crap-score",
588
+ &["high-crap-score", "crap-score", "crap"],
589
+ "High CRAP score",
590
+ "A complex function also has weak line coverage.",
591
+ "CRAP combines complexity and coverage to find functions that are risky to modify.",
592
+ "route() has several branches and 0% LCOV line coverage.",
593
+ "Reduce branching or add targeted tests covering the function.",
594
+ next_line_suppressions!("complexity"),
595
+ &["dart-decimate health --format json --coverage coverage/lcov.info --max-crap 30"],
596
+ ),
597
+ issue!(
598
+ "health-hotspot",
599
+ "dart-decimate/health-hotspot",
600
+ &["health-hotspot", "health-hotspots", "hotspot", "hotspots"],
601
+ "Health hotspot",
602
+ "A Dart file has a low aggregate health score.",
603
+ "File scores combine complexity, CRAP, and coverage status into one prioritization signal.",
604
+ "lib/checkout_flow.dart scores below the configured minimum.",
605
+ "Review score reasons before refactoring; prefer small, owner-preserving changes.",
606
+ &[],
607
+ &["dart-decimate health --format json --file-scores --hotspots"],
608
+ ),
609
+ issue!(
610
+ "refactoring-target",
611
+ "dart-decimate/refactoring-target",
612
+ &[
613
+ "refactoring-target",
614
+ "refactoring-targets",
615
+ "target",
616
+ "targets"
617
+ ],
618
+ "Refactoring target",
619
+ "A low-scoring file is ranked as a high-priority refactoring candidate.",
620
+ "Targets combine health score with complex-function and coverage risk signals.",
621
+ "lib/billing_state.dart has low score and multiple complex functions.",
622
+ "Refactor around the highest-ranked reasons, then rerun health.",
623
+ &[],
624
+ &["dart-decimate health --format json --targets"],
625
+ ),
626
+ issue!(
627
+ "feature-flag",
628
+ "dart-decimate/feature-flag",
629
+ &["feature-flag", "feature-flags", "flags"],
630
+ "Feature flag",
631
+ "A Dart or Flutter feature flag pattern was detected.",
632
+ "Flag inventories help find stale rollout logic and risky config gates.",
633
+ "bool.fromEnvironment('NEW_FLOW') gates production behavior.",
634
+ "Review owner, rollout state, and dead-code traces before deleting flag branches.",
635
+ next_line_suppressions!("feature-flag"),
636
+ &["dart-decimate flags --format json"],
637
+ ),
638
+ issue!(
639
+ "security-candidate",
640
+ "dart-decimate/security-candidate",
641
+ &[
642
+ "security",
643
+ "security-candidate",
644
+ "security-candidates",
645
+ "security-sink",
646
+ "hardcoded-secret",
647
+ "insecure-transport",
648
+ "tls-bypass",
649
+ "webview-risk",
650
+ "process-execution",
651
+ "process-exec",
652
+ "raw-sql",
653
+ "plain-secret-storage",
654
+ ],
655
+ "Security candidate",
656
+ "A deterministic local security review candidate was detected.",
657
+ "Dart Decimate surfaces candidates for agent verification; it does not prove exploitability.",
658
+ "HttpClient.badCertificateCallback or an http:// URL appears in reachable code.",
659
+ "Verify source, sink, reachability, and product intent before changing code.",
660
+ next_line_suppressions!("security-sink"),
661
+ &["dart-decimate security --format json --surface"],
662
+ ),
663
+ issue!(
664
+ "stale-suppression",
665
+ "dart-decimate/stale-suppression",
666
+ &[
667
+ "stale-suppression",
668
+ "stale-suppressions",
669
+ "unused-suppression",
670
+ "unused-suppressions"
671
+ ],
672
+ "Stale suppression",
673
+ "A Dart Decimate or Fallow inline suppression no longer suppresses any finding.",
674
+ "Stale suppressions hide historical context and can mask future findings accidentally.",
675
+ "// dart-decimate-ignore-next-line unused-export remains above live code with no finding.",
676
+ "Remove the unused suppression comment.",
677
+ &[],
678
+ &["dart-decimate check --format json"],
679
+ ),
680
+ issue!(
681
+ "missing-suppression-reason",
682
+ "dart-decimate/missing-suppression-reason",
683
+ &["missing-suppression-reason", "missing-suppression-reasons"],
684
+ "Missing suppression reason",
685
+ "A Dart Decimate or Fallow inline suppression is missing required justification text.",
686
+ "Reasoned suppressions make intentional exceptions reviewable and prevent silent cleanup drift.",
687
+ "// dart-decimate-ignore-next-line unused-export omits why the export is intentionally kept.",
688
+ "Add a short reason after `--`, `because`, or `reason:`.",
689
+ &[],
690
+ &["dart-decimate check --format json"],
691
+ ),
692
+ ];