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,339 @@
1
+ use std::collections::BTreeMap;
2
+
3
+ use serde::{Deserialize, Serialize};
4
+
5
+ use crate::SecurityCategory;
6
+ use crate::output::{Finding, FindingKind, JsonAttackSurfaceEntry, JsonReport, Severity, Verdict};
7
+
8
+ use super::rule_aliases::{
9
+ aliases, known_rule, missing_suppression_reason_aliases, private_type_leak_aliases,
10
+ };
11
+
12
+ /// Per-rule configured severity.
13
+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
14
+ #[serde(rename_all = "kebab-case")]
15
+ pub enum RuleLevel {
16
+ Error,
17
+ Warn,
18
+ /// Remove the finding from reports and gates.
19
+ Off,
20
+ }
21
+
22
+ /// Rule severity configuration keyed by rule id or alias.
23
+ pub type RuleConfig = BTreeMap<String, RuleLevel>;
24
+
25
+ /// Validate all configured rule names.
26
+ ///
27
+ /// # Errors
28
+ ///
29
+ /// Returns [`RuleError`] when a rule key is not supported by Dart Decimate.
30
+ pub fn validate_rules(rules: &RuleConfig) -> Result<(), RuleError> {
31
+ let _ = RuleMatcher::new(rules)?;
32
+ Ok(())
33
+ }
34
+
35
+ /// Whether the opt-in private-type-leak rule was explicitly enabled.
36
+ #[must_use]
37
+ pub fn private_type_leaks_enabled(rules: &RuleConfig) -> bool {
38
+ private_type_leak_aliases().into_iter().any(|alias| {
39
+ rules
40
+ .get(alias)
41
+ .is_some_and(|level| *level != RuleLevel::Off)
42
+ })
43
+ }
44
+
45
+ /// Whether suppression comments must include a reason.
46
+ #[must_use]
47
+ pub fn missing_suppression_reasons_enabled(rules: &RuleConfig) -> bool {
48
+ missing_suppression_reason_aliases()
49
+ .into_iter()
50
+ .any(|alias| {
51
+ rules
52
+ .get(alias)
53
+ .is_some_and(|level| *level != RuleLevel::Off)
54
+ })
55
+ }
56
+
57
+ /// Apply configured rule severities to an already-built report.
58
+ ///
59
+ /// # Errors
60
+ ///
61
+ /// Returns [`RuleError`] when a rule key is not supported by Dart Decimate.
62
+ pub fn apply_rules_to_report(report: &mut JsonReport, rules: &RuleConfig) -> Result<(), RuleError> {
63
+ let rules = RuleMatcher::new(rules)?;
64
+ if rules.is_empty() {
65
+ report
66
+ .findings
67
+ .retain(|finding| default_rule_level(finding.kind) != RuleLevel::Off);
68
+ recompute_summary(report);
69
+ return Ok(());
70
+ }
71
+
72
+ report
73
+ .findings
74
+ .retain_mut(|finding| apply_finding_level(finding, &rules) != RuleLevel::Off);
75
+ report.clone_groups.retain(|_| {
76
+ rules.level(
77
+ "dart-decimate/code-duplication",
78
+ FindingKind::CodeDuplication,
79
+ ) != RuleLevel::Off
80
+ });
81
+ report.complexity.retain(|finding| {
82
+ rules.level(&finding.rule_id, complexity_kind(&finding.rule_id)) != RuleLevel::Off
83
+ });
84
+ report.hotspots.retain(|_| {
85
+ rules.level("dart-decimate/health-hotspot", FindingKind::HealthHotspot) != RuleLevel::Off
86
+ });
87
+ report.refactoring_targets.retain(|_| {
88
+ rules.level(
89
+ "dart-decimate/refactoring-target",
90
+ FindingKind::RefactoringTarget,
91
+ ) != RuleLevel::Off
92
+ });
93
+ report.feature_flags.retain(|_| {
94
+ rules.level("dart-decimate/feature-flag", FindingKind::FeatureFlag) != RuleLevel::Off
95
+ });
96
+ report.security_candidates.retain(|candidate| {
97
+ rules.level(&candidate.rule_id, FindingKind::SecurityCandidate) != RuleLevel::Off
98
+ });
99
+ report
100
+ .attack_surface
101
+ .retain(|entry| security_surface_enabled(entry, &rules));
102
+ report
103
+ .next_steps
104
+ .retain(|step| next_step_enabled(&step.id, &report.findings));
105
+
106
+ recompute_summary(report);
107
+ report.verdict = if report
108
+ .findings
109
+ .iter()
110
+ .any(|finding| finding.severity == Severity::Error)
111
+ {
112
+ Verdict::Fail
113
+ } else {
114
+ Verdict::Pass
115
+ };
116
+ Ok(())
117
+ }
118
+
119
+ /// Error returned for invalid rule names.
120
+ #[derive(Debug, thiserror::Error)]
121
+ pub enum RuleError {
122
+ /// A configured rule key is not supported.
123
+ #[error("unknown config rule {rule:?}")]
124
+ UnknownRule {
125
+ /// Unknown rule key.
126
+ rule: String,
127
+ },
128
+ }
129
+
130
+ fn apply_finding_level(finding: &mut Finding, rules: &RuleMatcher) -> RuleLevel {
131
+ let level = rules.level(&finding.rule_id, finding.kind);
132
+ finding.severity = match level {
133
+ RuleLevel::Error => Severity::Error,
134
+ RuleLevel::Warn => Severity::Warning,
135
+ RuleLevel::Off => finding.severity,
136
+ };
137
+ level
138
+ }
139
+
140
+ fn recompute_summary(report: &mut JsonReport) {
141
+ let summary = &mut report.summary;
142
+ let previous_feature_flags = summary.feature_flags;
143
+ let previous_feature_flag_occurrences = summary.feature_flag_occurrences;
144
+ let previous_security_candidates = summary.security_candidates;
145
+ let previous_security_candidate_occurrences = summary.security_candidate_occurrences;
146
+ summary.unresolved_dependencies =
147
+ kind_count(&report.findings, FindingKind::UnresolvedDependency);
148
+ summary.part_of_violations = kind_count(&report.findings, FindingKind::PartOfViolation);
149
+ summary.unused_dependencies = dependency_count(&report.findings);
150
+ summary.unused_dev_dependencies =
151
+ kind_count(&report.findings, FindingKind::UnusedDevDependency);
152
+ summary.test_only_dependencies = kind_count(&report.findings, FindingKind::TestOnlyDependency);
153
+ summary.dependency_overrides = dependency_override_count(&report.findings);
154
+ summary.unused_dependency_overrides =
155
+ kind_count(&report.findings, FindingKind::UnusedDependencyOverride);
156
+ summary.misconfigured_dependency_overrides = kind_count(
157
+ &report.findings,
158
+ FindingKind::MisconfiguredDependencyOverride,
159
+ );
160
+ summary.unlisted_dependencies = kind_count(&report.findings, FindingKind::UnlistedDependency);
161
+ summary.private_src_imports = kind_count(&report.findings, FindingKind::PrivateSrcImport);
162
+ summary.dead_files = kind_count(&report.findings, FindingKind::DeadFile);
163
+ summary.unused_exports = kind_count(&report.findings, FindingKind::UnusedExport);
164
+ summary.unused_types = kind_count(&report.findings, FindingKind::UnusedType);
165
+ summary.private_type_leaks = kind_count(&report.findings, FindingKind::PrivateTypeLeak);
166
+ summary.unused_enum_members = kind_count(&report.findings, FindingKind::UnusedEnumMember);
167
+ summary.unused_class_members = kind_count(&report.findings, FindingKind::UnusedClassMember);
168
+ summary.duplicate_exports = kind_count(&report.findings, FindingKind::DuplicateExport);
169
+ summary.route_collisions = kind_count(&report.findings, FindingKind::RouteCollision);
170
+ summary.private_widget_classes = kind_count(&report.findings, FindingKind::PrivateWidgetClass);
171
+ summary.widget_top_level_functions = kind_count(
172
+ &report.findings,
173
+ FindingKind::WidgetTopLevelFunctionBoundary,
174
+ );
175
+ summary.unused_widget_params = kind_count(&report.findings, FindingKind::UnusedWidgetParam);
176
+ summary.unrendered_widgets = kind_count(&report.findings, FindingKind::UnrenderedWidget);
177
+ summary.missing_context_mounted_after_await = kind_count(
178
+ &report.findings,
179
+ FindingKind::MissingContextMountedAfterAwait,
180
+ );
181
+ summary.code_duplications = report.clone_groups.len();
182
+ summary.complex_functions = report.complexity.len();
183
+ summary.coverage_gaps = kind_count(&report.findings, FindingKind::CoverageGap);
184
+ summary.crap_functions = kind_count(&report.findings, FindingKind::HighCrapScore);
185
+ summary.file_scores = report.file_scores.len();
186
+ summary.hotspots = report.hotspots.len();
187
+ summary.refactoring_targets = report.refactoring_targets.len();
188
+ summary.feature_flags = report.feature_flags.len();
189
+ summary.feature_flag_occurrences = if previous_feature_flags == report.feature_flags.len() {
190
+ previous_feature_flag_occurrences
191
+ } else {
192
+ report
193
+ .feature_flags
194
+ .iter()
195
+ .map(|flag| flag.occurrences.len())
196
+ .sum()
197
+ };
198
+ summary.security_candidates = report.security_candidates.len();
199
+ summary.security_candidate_occurrences =
200
+ if previous_security_candidates == report.security_candidates.len() {
201
+ previous_security_candidate_occurrences
202
+ } else {
203
+ report
204
+ .security_candidates
205
+ .iter()
206
+ .map(|candidate| candidate.occurrences.len())
207
+ .sum()
208
+ };
209
+ summary.attack_surface = report.attack_surface.len();
210
+ summary.missing_entry_points = kind_count(&report.findings, FindingKind::MissingEntryPoint);
211
+ summary.cycles = kind_count(&report.findings, FindingKind::CircularDependency);
212
+ summary.re_export_cycles = kind_count(&report.findings, FindingKind::ReExportCycle);
213
+ summary.boundary_violations = kind_count(&report.findings, FindingKind::BoundaryViolation);
214
+ summary.boundary_coverage = kind_count(&report.findings, FindingKind::BoundaryCoverage);
215
+ summary.boundary_call_violations =
216
+ kind_count(&report.findings, FindingKind::BoundaryCallViolation);
217
+ summary.policy_violations = kind_count(&report.findings, FindingKind::PolicyViolation);
218
+ summary.missing_suppression_reasons =
219
+ kind_count(&report.findings, FindingKind::MissingSuppressionReason);
220
+ summary.findings = report.findings.len();
221
+ }
222
+
223
+ fn kind_count(findings: &[Finding], kind: FindingKind) -> usize {
224
+ findings
225
+ .iter()
226
+ .filter(|finding| finding.kind == kind)
227
+ .count()
228
+ }
229
+
230
+ fn dependency_count(findings: &[Finding]) -> usize {
231
+ findings
232
+ .iter()
233
+ .filter(|finding| is_dependency_hygiene_kind(finding.kind))
234
+ .count()
235
+ }
236
+
237
+ fn complexity_kind(rule_id: &str) -> FindingKind {
238
+ match rule_id.rsplit('/').next() {
239
+ Some("high-cyclomatic-complexity") => FindingKind::HighCyclomaticComplexity,
240
+ Some("high-cognitive-complexity") => FindingKind::HighCognitiveComplexity,
241
+ Some("high-crap-score") => FindingKind::HighCrapScore,
242
+ _ => FindingKind::HighComplexity,
243
+ }
244
+ }
245
+
246
+ fn security_surface_enabled(entry: &JsonAttackSurfaceEntry, rules: &RuleMatcher) -> bool {
247
+ let rule_id = match entry.category {
248
+ SecurityCategory::HardcodedSecret => "dart-decimate/security-hardcoded-secret",
249
+ SecurityCategory::InsecureTransport => "dart-decimate/security-insecure-transport",
250
+ SecurityCategory::TlsBypass => "dart-decimate/security-tls-bypass",
251
+ SecurityCategory::WebViewRisk => "dart-decimate/security-webview-risk",
252
+ SecurityCategory::ProcessExecution => "dart-decimate/security-process-execution",
253
+ SecurityCategory::RawSql => "dart-decimate/security-raw-sql",
254
+ SecurityCategory::PlainSecretStorage => "dart-decimate/security-plain-secret-storage",
255
+ };
256
+ rules.level(rule_id, FindingKind::SecurityCandidate) != RuleLevel::Off
257
+ }
258
+
259
+ fn next_step_enabled(id: &str, findings: &[Finding]) -> bool {
260
+ match id {
261
+ "trace-unused-export" => has_kind(findings, FindingKind::UnusedExport),
262
+ "trace-unused-type" => has_kind(findings, FindingKind::UnusedType),
263
+ "trace-unused-dependency" => findings
264
+ .iter()
265
+ .any(|finding| is_dependency_hygiene_kind(finding.kind)),
266
+ "trace-code-duplication" => has_kind(findings, FindingKind::CodeDuplication),
267
+ "complexity-breakdown" => findings.iter().any(|finding| {
268
+ matches!(
269
+ finding.kind,
270
+ FindingKind::HighCyclomaticComplexity
271
+ | FindingKind::HighCognitiveComplexity
272
+ | FindingKind::HighComplexity
273
+ | FindingKind::HighCrapScore
274
+ )
275
+ }),
276
+ _ => true,
277
+ }
278
+ }
279
+
280
+ fn has_kind(findings: &[Finding], kind: FindingKind) -> bool {
281
+ findings.iter().any(|finding| finding.kind == kind)
282
+ }
283
+
284
+ struct RuleMatcher<'a> {
285
+ rules: &'a RuleConfig,
286
+ }
287
+
288
+ impl<'a> RuleMatcher<'a> {
289
+ fn new(rules: &'a RuleConfig) -> Result<Self, RuleError> {
290
+ for key in rules.keys() {
291
+ if !known_rule(key) {
292
+ return Err(RuleError::UnknownRule { rule: key.clone() });
293
+ }
294
+ }
295
+ Ok(Self { rules })
296
+ }
297
+
298
+ fn is_empty(&self) -> bool {
299
+ self.rules.is_empty()
300
+ }
301
+
302
+ fn level(&self, rule_id: &str, kind: FindingKind) -> RuleLevel {
303
+ if let Some(level) = self.rules.get(rule_id).copied() {
304
+ return level;
305
+ }
306
+ aliases(rule_id, kind)
307
+ .into_iter()
308
+ .find_map(|alias| self.rules.get(alias).copied())
309
+ .unwrap_or_else(|| default_rule_level(kind))
310
+ }
311
+ }
312
+
313
+ const fn default_rule_level(kind: FindingKind) -> RuleLevel {
314
+ match kind {
315
+ FindingKind::UnusedDependencyOverride
316
+ | FindingKind::CodeDuplication
317
+ | FindingKind::UnusedWidgetParam
318
+ | FindingKind::UnrenderedWidget => RuleLevel::Warn,
319
+ FindingKind::PrivateWidgetClass
320
+ | FindingKind::WidgetTopLevelFunctionBoundary
321
+ | FindingKind::MissingContextMountedAfterAwait => RuleLevel::Off,
322
+ _ => RuleLevel::Error,
323
+ }
324
+ }
325
+
326
+ fn dependency_override_count(findings: &[Finding]) -> usize {
327
+ kind_count(findings, FindingKind::UnusedDependencyOverride)
328
+ + kind_count(findings, FindingKind::MisconfiguredDependencyOverride)
329
+ }
330
+
331
+ const fn is_dependency_hygiene_kind(kind: FindingKind) -> bool {
332
+ matches!(
333
+ kind,
334
+ FindingKind::UnusedDependency
335
+ | FindingKind::UnusedDevDependency
336
+ | FindingKind::TestOnlyDependency
337
+ | FindingKind::UnusedDependencyOverride
338
+ )
339
+ }