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.
- package/Cargo.lock +572 -0
- package/Cargo.toml +41 -0
- package/LICENSE +21 -0
- package/README.md +617 -0
- package/assets/dart-decimate-banner.png +0 -0
- package/npm/bin/dart-decimate-mcp.js +48 -0
- package/npm/bin/dart-decimate.js +48 -0
- package/npm/scripts/postinstall.js +46 -0
- package/npm/scripts/test-npx-local.js +54 -0
- package/npm/scripts/test-npx-mcp-local.js +56 -0
- package/package.json +45 -0
- package/src/baseline.rs +643 -0
- package/src/bin/dart-decimate-mcp.rs +11 -0
- package/src/boundaries/tests.rs +60 -0
- package/src/boundaries.rs +317 -0
- package/src/changed_scope.rs +117 -0
- package/src/ci_template.rs +399 -0
- package/src/cli/analyze.rs +462 -0
- package/src/cli/analyzer_options.rs +82 -0
- package/src/cli/audit_run.rs +327 -0
- package/src/cli/boundary_args.rs +44 -0
- package/src/cli/ci_template_run.rs +196 -0
- package/src/cli/command_name.rs +20 -0
- package/src/cli/common_args.rs +167 -0
- package/src/cli/config_run.rs +78 -0
- package/src/cli/coverage_run.rs +393 -0
- package/src/cli/decision_surface_run.rs +99 -0
- package/src/cli/default_command.rs +69 -0
- package/src/cli/dupes_args.rs +150 -0
- package/src/cli/entry_points.rs +121 -0
- package/src/cli/error.rs +149 -0
- package/src/cli/error_output.rs +68 -0
- package/src/cli/explain_run.rs +72 -0
- package/src/cli/fix_run.rs +162 -0
- package/src/cli/flags_args.rs +23 -0
- package/src/cli/health_args.rs +200 -0
- package/src/cli/hooks_run.rs +191 -0
- package/src/cli/impact_run.rs +95 -0
- package/src/cli/init_run.rs +49 -0
- package/src/cli/inspect_args.rs +20 -0
- package/src/cli/inspect_run.rs +66 -0
- package/src/cli/issue_filter_args.rs +240 -0
- package/src/cli/list_run.rs +311 -0
- package/src/cli/mode_args.rs +72 -0
- package/src/cli/output_format.rs +62 -0
- package/src/cli/regression_args.rs +156 -0
- package/src/cli/request_args.rs +175 -0
- package/src/cli/schema_commands.rs +72 -0
- package/src/cli/scope_args.rs +174 -0
- package/src/cli/security_args.rs +175 -0
- package/src/cli/security_gate_run.rs +66 -0
- package/src/cli/security_summary_run.rs +43 -0
- package/src/cli/summary_args.rs +12 -0
- package/src/cli/tests.rs +516 -0
- package/src/cli/trace_args.rs +67 -0
- package/src/cli/trace_run.rs +131 -0
- package/src/cli/trace_tests.rs +235 -0
- package/src/cli/unsupported_run.rs +116 -0
- package/src/cli/watch_run.rs +153 -0
- package/src/cli.rs +603 -0
- package/src/config/boundary_config.rs +235 -0
- package/src/config/cache.rs +25 -0
- package/src/config/dependencies.rs +114 -0
- package/src/config/health.rs +237 -0
- package/src/config/jsonc.rs +66 -0
- package/src/config/policy.rs +91 -0
- package/src/config/rule_aliases.rs +487 -0
- package/src/config/rules.rs +339 -0
- package/src/config.rs +635 -0
- package/src/coverage.rs +469 -0
- package/src/dart_parser.rs +673 -0
- package/src/decision_surface.rs +405 -0
- package/src/dependencies/analyze.rs +218 -0
- package/src/dependencies/codegen.rs +118 -0
- package/src/dependencies/discovery.rs +60 -0
- package/src/dependencies/overrides.rs +76 -0
- package/src/dependencies/private_src_imports.rs +32 -0
- package/src/dependencies/pubspec_document.rs +86 -0
- package/src/dependencies/pubspec_entry.rs +96 -0
- package/src/dependencies/tests.rs +544 -0
- package/src/dependencies/usage.rs +33 -0
- package/src/dependencies.rs +553 -0
- package/src/dependency_scripts.rs +91 -0
- package/src/dupes/lex.rs +236 -0
- package/src/dupes/tests.rs +119 -0
- package/src/dupes.rs +625 -0
- package/src/explain.rs +692 -0
- package/src/extract/directives.rs +252 -0
- package/src/extract/error_tests.rs +25 -0
- package/src/extract/members.rs +210 -0
- package/src/extract/primary_constructors.rs +421 -0
- package/src/extract/references.rs +151 -0
- package/src/extract/routes.rs +691 -0
- package/src/extract/signatures.rs +266 -0
- package/src/extract/string_tests.rs +18 -0
- package/src/extract/strings.rs +107 -0
- package/src/extract/tests.rs +697 -0
- package/src/extract.rs +680 -0
- package/src/feature_flags/tests.rs +76 -0
- package/src/feature_flags.rs +453 -0
- package/src/finding_identity.rs +60 -0
- package/src/fix.rs +551 -0
- package/src/generated.rs +53 -0
- package/src/graph/augment_tests.rs +212 -0
- package/src/graph/conditionals.rs +74 -0
- package/src/graph/package_config_tests.rs +100 -0
- package/src/graph/parts.rs +248 -0
- package/src/graph/pubspec_tests.rs +119 -0
- package/src/graph/tests.rs +837 -0
- package/src/graph/uri_tests.rs +102 -0
- package/src/graph.rs +644 -0
- package/src/health/coverage.rs +309 -0
- package/src/health/ownership.rs +175 -0
- package/src/health/runtime_coverage.rs +616 -0
- package/src/health/runtime_intelligence.rs +511 -0
- package/src/health/scores.rs +296 -0
- package/src/health/tests.rs +240 -0
- package/src/health/threshold_types.rs +163 -0
- package/src/health/thresholds.rs +229 -0
- package/src/health/types.rs +636 -0
- package/src/health.rs +597 -0
- package/src/hooks/agent_settings.rs +175 -0
- package/src/hooks/templates.rs +51 -0
- package/src/hooks.rs +569 -0
- package/src/impact.rs +287 -0
- package/src/init.rs +237 -0
- package/src/inspect.rs +142 -0
- package/src/intelligence/tests.rs +232 -0
- package/src/intelligence.rs +305 -0
- package/src/lib.rs +198 -0
- package/src/main.rs +5 -0
- package/src/manifest/mcp.rs +565 -0
- package/src/manifest.rs +552 -0
- package/src/mcp/cli_args/value_args.rs +175 -0
- package/src/mcp/cli_args.rs +658 -0
- package/src/mcp/cli_args_tests.rs +522 -0
- package/src/mcp/code_execute.rs +671 -0
- package/src/mcp/tools.rs +660 -0
- package/src/mcp.rs +325 -0
- package/src/output/audit_risk.rs +135 -0
- package/src/output/dependency_findings.rs +327 -0
- package/src/output/duplication_findings.rs +114 -0
- package/src/output/feature_flag_findings.rs +122 -0
- package/src/output/format.rs +31 -0
- package/src/output/graph_findings.rs +461 -0
- package/src/output/health_findings.rs +612 -0
- package/src/output/human.rs +27 -0
- package/src/output/next_steps.rs +92 -0
- package/src/output/route_findings.rs +76 -0
- package/src/output/runtime_coverage.rs +515 -0
- package/src/output/scope.rs +183 -0
- package/src/output/security_findings.rs +390 -0
- package/src/output/security_sarif.rs +150 -0
- package/src/output/suppressions.rs +323 -0
- package/src/output/symbol_findings.rs +257 -0
- package/src/output/tests.rs +114 -0
- package/src/output/types.rs +604 -0
- package/src/output/widget_findings.rs +213 -0
- package/src/output.rs +682 -0
- package/src/package_map.rs +495 -0
- package/src/policy/packs.rs +232 -0
- package/src/policy/tests.rs +134 -0
- package/src/policy.rs +640 -0
- package/src/project_list.rs +376 -0
- package/src/report_schema/inventory.rs +418 -0
- package/src/report_schema.rs +488 -0
- package/src/routes.rs +354 -0
- package/src/scan/tests.rs +250 -0
- package/src/scan.rs +275 -0
- package/src/security/detect.rs +639 -0
- package/src/security/tests.rs +178 -0
- package/src/security.rs +373 -0
- package/src/security_gate.rs +555 -0
- package/src/symbols/path_filters.rs +27 -0
- package/src/symbols/private_type_leaks.rs +125 -0
- package/src/symbols/riverpod.rs +113 -0
- package/src/symbols/tests.rs +692 -0
- package/src/symbols.rs +693 -0
- package/src/trace/tests.rs +225 -0
- package/src/trace.rs +690 -0
- package/src/unsupported.rs +47 -0
- package/src/widgets/lifecycle.rs +484 -0
- package/src/widgets/params.rs +236 -0
- package/src/widgets/tests.rs +430 -0
- package/src/widgets/top_level.rs +110 -0
- package/src/widgets/unrendered.rs +374 -0
- package/src/widgets.rs +590 -0
- package/src/workspace_scope.rs +358 -0
package/src/output.rs
ADDED
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
use std::collections::BTreeSet;
|
|
2
|
+
|
|
3
|
+
mod audit_risk;
|
|
4
|
+
mod dependency_findings;
|
|
5
|
+
mod duplication_findings;
|
|
6
|
+
mod feature_flag_findings;
|
|
7
|
+
mod format;
|
|
8
|
+
mod graph_findings;
|
|
9
|
+
mod health_findings;
|
|
10
|
+
mod human;
|
|
11
|
+
mod next_steps;
|
|
12
|
+
mod route_findings;
|
|
13
|
+
mod runtime_coverage;
|
|
14
|
+
mod scope;
|
|
15
|
+
mod security_findings;
|
|
16
|
+
mod security_sarif;
|
|
17
|
+
mod suppressions;
|
|
18
|
+
mod symbol_findings;
|
|
19
|
+
mod types;
|
|
20
|
+
mod widget_findings;
|
|
21
|
+
|
|
22
|
+
use crate::{
|
|
23
|
+
BoundaryCallViolation, BoundaryCoverageGap, BoundaryViolation, DeadCodeReport, DependencyCycle,
|
|
24
|
+
DependencyHygieneReport, DuplicateCodeReport, FeatureFlagReport, HealthReport, PolicyViolation,
|
|
25
|
+
ReExportCycle, RouteCollisionReport, SecurityReport, SymbolReport, WidgetReport,
|
|
26
|
+
scan::ScannedProject,
|
|
27
|
+
};
|
|
28
|
+
pub use audit_risk::apply_audit_risk;
|
|
29
|
+
use dependency_findings::add_dependency_hygiene_findings;
|
|
30
|
+
pub use duplication_findings::{JsonCloneGroup, JsonCloneInstance};
|
|
31
|
+
use duplication_findings::{add_duplication_findings, json_clone_groups};
|
|
32
|
+
pub use feature_flag_findings::{JsonFeatureFlag, JsonFeatureFlagOccurrence};
|
|
33
|
+
use feature_flag_findings::{add_feature_flag_findings, json_feature_flags};
|
|
34
|
+
use graph_findings::{
|
|
35
|
+
add_boundary_call_findings, add_boundary_findings, add_cycle_findings, add_dead_code_findings,
|
|
36
|
+
add_part_of_findings, add_policy_findings, add_re_export_cycle_findings,
|
|
37
|
+
add_unresolved_findings, project_part_of_violation_count, project_unresolved_count,
|
|
38
|
+
};
|
|
39
|
+
pub use health_findings::{
|
|
40
|
+
JsonComplexityContribution, JsonComplexityFinding, JsonEffectiveThresholds,
|
|
41
|
+
JsonFileHealthScore, JsonHealthHotspot, JsonRefactoringTarget, JsonThresholdOverride,
|
|
42
|
+
};
|
|
43
|
+
use health_findings::{
|
|
44
|
+
add_health_findings, json_complexity, json_file_scores, json_hotspots,
|
|
45
|
+
json_refactoring_targets, json_threshold_overrides,
|
|
46
|
+
};
|
|
47
|
+
pub use human::render_human_report;
|
|
48
|
+
use next_steps::next_steps;
|
|
49
|
+
use route_findings::add_route_findings;
|
|
50
|
+
pub use runtime_coverage::{
|
|
51
|
+
JsonRuntimeBlastRadius, JsonRuntimeCoverage, JsonRuntimeCoverageActionable,
|
|
52
|
+
JsonRuntimeCoverageFinding, JsonRuntimeCoverageIntelligence, JsonRuntimeCoverageProvenance,
|
|
53
|
+
JsonRuntimeCoverageSummary, JsonRuntimeCoverageWatermark, JsonRuntimeHotPath,
|
|
54
|
+
JsonRuntimeImportance, json_runtime_coverage,
|
|
55
|
+
};
|
|
56
|
+
use scope::{
|
|
57
|
+
file_scope, finding_in_scope, health_file_score_count, project_file_scope_count,
|
|
58
|
+
scope_attack_surface, scope_clone_groups, scope_complexity, scope_feature_flags,
|
|
59
|
+
scope_file_scores, scope_hotspots, scope_refactoring_targets, scope_security_candidates,
|
|
60
|
+
scoped_quality_score,
|
|
61
|
+
};
|
|
62
|
+
pub use security_findings::{
|
|
63
|
+
JsonAttackSurfaceEntry, JsonSecurityCandidate, JsonSecurityOccurrence, JsonSecurityReachability,
|
|
64
|
+
};
|
|
65
|
+
use security_findings::{add_security_findings, json_attack_surface, json_security_candidates};
|
|
66
|
+
pub(crate) use security_sarif::render_sarif_report;
|
|
67
|
+
use suppressions::filter_suppressed_findings;
|
|
68
|
+
use symbol_findings::add_symbol_findings;
|
|
69
|
+
pub use types::{
|
|
70
|
+
AuditAttribution, AuditAttributionCounts, AuditRiskLevel, Finding, FindingAction, FindingEdge,
|
|
71
|
+
FindingKind, JsonReport, NextStep, ReportCommand, ReportSummary, Severity, Verdict,
|
|
72
|
+
};
|
|
73
|
+
use widget_findings::add_widget_findings;
|
|
74
|
+
|
|
75
|
+
/// Stable JSON schema version for agent consumers.
|
|
76
|
+
pub const SCHEMA_VERSION: &str = "dart-decimate.report.v1";
|
|
77
|
+
pub const TRACE_SCHEMA_VERSION: &str = "dart-decimate.trace.v1";
|
|
78
|
+
|
|
79
|
+
/// Analysis values to serialize.
|
|
80
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
81
|
+
pub struct AnalysisResults {
|
|
82
|
+
/// Command that produced these values.
|
|
83
|
+
pub command: ReportCommand,
|
|
84
|
+
/// Dead-code reachability report, when run.
|
|
85
|
+
pub dead_code: Option<DeadCodeReport>,
|
|
86
|
+
/// Symbol-level dead-code report, when run.
|
|
87
|
+
pub symbols: Option<SymbolReport>,
|
|
88
|
+
/// Circular dependencies.
|
|
89
|
+
pub cycles: Vec<DependencyCycle>,
|
|
90
|
+
/// Export-only circular dependencies.
|
|
91
|
+
pub re_export_cycles: Vec<ReExportCycle>,
|
|
92
|
+
/// Architecture boundary violations.
|
|
93
|
+
pub boundary_violations: Vec<BoundaryViolation>,
|
|
94
|
+
/// Files not covered by any configured architecture boundary zone.
|
|
95
|
+
pub boundary_coverage: Vec<BoundaryCoverageGap>,
|
|
96
|
+
/// Forbidden calls from configured architecture zones.
|
|
97
|
+
pub boundary_call_violations: Vec<BoundaryCallViolation>,
|
|
98
|
+
/// Declarative policy pack violations.
|
|
99
|
+
pub policy_violations: Vec<PolicyViolation>,
|
|
100
|
+
/// Pub dependency hygiene report, when run.
|
|
101
|
+
pub dependency_hygiene: Option<DependencyHygieneReport>,
|
|
102
|
+
/// Code duplication report, when run.
|
|
103
|
+
pub duplicates: Option<DuplicateCodeReport>,
|
|
104
|
+
pub health: Option<HealthReport>,
|
|
105
|
+
pub feature_flags: Option<FeatureFlagReport>,
|
|
106
|
+
pub security: Option<SecurityReport>,
|
|
107
|
+
pub routes: Option<RouteCollisionReport>,
|
|
108
|
+
pub widgets: Option<WidgetReport>,
|
|
109
|
+
pub file_scope: Option<Vec<std::path::PathBuf>>,
|
|
110
|
+
pub require_suppression_reasons: bool,
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// Build the stable JSON report for a project analysis.
|
|
114
|
+
#[must_use]
|
|
115
|
+
pub fn build_json_report(project: &ScannedProject, results: &AnalysisResults) -> JsonReport {
|
|
116
|
+
let scope = file_scope(project, results.file_scope.as_ref());
|
|
117
|
+
let findings = report_findings(project, results, scope.as_ref());
|
|
118
|
+
let mut summary = report_summary(project, results, &findings, scope.as_ref());
|
|
119
|
+
let clone_groups = scope_clone_groups(
|
|
120
|
+
results
|
|
121
|
+
.duplicates
|
|
122
|
+
.as_ref()
|
|
123
|
+
.map_or_else(Vec::new, |report| json_clone_groups(&project.root, report)),
|
|
124
|
+
scope.as_ref(),
|
|
125
|
+
);
|
|
126
|
+
let complexity = scope_complexity(
|
|
127
|
+
results
|
|
128
|
+
.health
|
|
129
|
+
.as_ref()
|
|
130
|
+
.map_or_else(Vec::new, |report| json_complexity(&project.root, report)),
|
|
131
|
+
scope.as_ref(),
|
|
132
|
+
);
|
|
133
|
+
let file_scores = scope_file_scores(
|
|
134
|
+
results
|
|
135
|
+
.health
|
|
136
|
+
.as_ref()
|
|
137
|
+
.map_or_else(Vec::new, |report| json_file_scores(&project.root, report)),
|
|
138
|
+
scope.as_ref(),
|
|
139
|
+
);
|
|
140
|
+
let hotspots = scope_hotspots(
|
|
141
|
+
results
|
|
142
|
+
.health
|
|
143
|
+
.as_ref()
|
|
144
|
+
.map_or_else(Vec::new, |report| json_hotspots(&project.root, report)),
|
|
145
|
+
scope.as_ref(),
|
|
146
|
+
);
|
|
147
|
+
let refactoring_targets = scope_refactoring_targets(
|
|
148
|
+
results.health.as_ref().map_or_else(Vec::new, |report| {
|
|
149
|
+
json_refactoring_targets(&project.root, report)
|
|
150
|
+
}),
|
|
151
|
+
scope.as_ref(),
|
|
152
|
+
);
|
|
153
|
+
let threshold_overrides = json_threshold_overrides_for(results);
|
|
154
|
+
let runtime_coverage = json_runtime_coverage_for(project, results);
|
|
155
|
+
let feature_flags = scope_feature_flags(
|
|
156
|
+
results
|
|
157
|
+
.feature_flags
|
|
158
|
+
.as_ref()
|
|
159
|
+
.map_or_else(Vec::new, |report| json_feature_flags(&project.root, report)),
|
|
160
|
+
scope.as_ref(),
|
|
161
|
+
);
|
|
162
|
+
let security_candidates = scope_security_candidates(
|
|
163
|
+
results.security.as_ref().map_or_else(Vec::new, |report| {
|
|
164
|
+
json_security_candidates(&project.root, report)
|
|
165
|
+
}),
|
|
166
|
+
scope.as_ref(),
|
|
167
|
+
);
|
|
168
|
+
let attack_surface = scope_attack_surface(
|
|
169
|
+
results.security.as_ref().map_or_else(Vec::new, |report| {
|
|
170
|
+
json_attack_surface(&project.root, report)
|
|
171
|
+
}),
|
|
172
|
+
scope.as_ref(),
|
|
173
|
+
);
|
|
174
|
+
let next_steps = if scope.is_some() {
|
|
175
|
+
Vec::new()
|
|
176
|
+
} else {
|
|
177
|
+
next_steps(&project.root, results)
|
|
178
|
+
};
|
|
179
|
+
if scope.is_some() {
|
|
180
|
+
summary.code_duplications = clone_groups.len();
|
|
181
|
+
summary.file_scores = file_scores.len();
|
|
182
|
+
summary.hotspots = hotspots.len();
|
|
183
|
+
summary.refactoring_targets = refactoring_targets.len();
|
|
184
|
+
summary.feature_flags = feature_flags.len();
|
|
185
|
+
summary.feature_flag_occurrences = feature_flags
|
|
186
|
+
.iter()
|
|
187
|
+
.map(|flag| flag.occurrences.len())
|
|
188
|
+
.sum();
|
|
189
|
+
summary.security_candidates = security_candidates.len();
|
|
190
|
+
summary.security_candidate_occurrences = security_candidates
|
|
191
|
+
.iter()
|
|
192
|
+
.map(|candidate| candidate.occurrences.len())
|
|
193
|
+
.sum();
|
|
194
|
+
summary.attack_surface = attack_surface.len();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
JsonReport {
|
|
198
|
+
schema_version: SCHEMA_VERSION.to_owned(),
|
|
199
|
+
kind: results.command.kind().to_owned(),
|
|
200
|
+
tool: "dart-decimate".to_owned(),
|
|
201
|
+
command: results.command,
|
|
202
|
+
verdict: report_verdict(&findings),
|
|
203
|
+
summary,
|
|
204
|
+
findings,
|
|
205
|
+
clone_groups,
|
|
206
|
+
complexity,
|
|
207
|
+
file_scores,
|
|
208
|
+
hotspots,
|
|
209
|
+
refactoring_targets,
|
|
210
|
+
threshold_overrides,
|
|
211
|
+
feature_flags,
|
|
212
|
+
security_candidates,
|
|
213
|
+
attack_surface,
|
|
214
|
+
runtime_coverage,
|
|
215
|
+
next_steps,
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/// Keep only selected finding kinds and recompute visible report counts.
|
|
220
|
+
pub fn filter_report_findings(report: &mut JsonReport, allowed: &[FindingKind]) {
|
|
221
|
+
if allowed.is_empty() {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
report
|
|
225
|
+
.findings
|
|
226
|
+
.retain(|finding| allowed.contains(&finding.kind));
|
|
227
|
+
if !allowed.contains(&FindingKind::CodeDuplication) {
|
|
228
|
+
report.clone_groups.clear();
|
|
229
|
+
}
|
|
230
|
+
if !allowed.iter().any(|kind| is_complexity_kind(*kind)) {
|
|
231
|
+
report.complexity.clear();
|
|
232
|
+
report.file_scores.clear();
|
|
233
|
+
report.hotspots.clear();
|
|
234
|
+
report.refactoring_targets.clear();
|
|
235
|
+
report.threshold_overrides.clear();
|
|
236
|
+
report.runtime_coverage = None;
|
|
237
|
+
}
|
|
238
|
+
if !allowed.contains(&FindingKind::FeatureFlag) {
|
|
239
|
+
report.feature_flags.clear();
|
|
240
|
+
}
|
|
241
|
+
if !allowed.contains(&FindingKind::SecurityCandidate) {
|
|
242
|
+
report.security_candidates.clear();
|
|
243
|
+
report.attack_surface.clear();
|
|
244
|
+
}
|
|
245
|
+
report.next_steps.clear();
|
|
246
|
+
report.summary.findings = report.findings.len();
|
|
247
|
+
apply_scoped_counts(&mut report.summary, &report.findings);
|
|
248
|
+
report.verdict = report_verdict(&report.findings);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
fn json_runtime_coverage_for(
|
|
252
|
+
project: &ScannedProject,
|
|
253
|
+
results: &AnalysisResults,
|
|
254
|
+
) -> Option<JsonRuntimeCoverage> {
|
|
255
|
+
results.health.as_ref().and_then(|report| {
|
|
256
|
+
report
|
|
257
|
+
.runtime_coverage
|
|
258
|
+
.as_ref()
|
|
259
|
+
.map(|runtime| json_runtime_coverage(&project.root, runtime))
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
fn json_threshold_overrides_for(results: &AnalysisResults) -> Vec<JsonThresholdOverride> {
|
|
264
|
+
results
|
|
265
|
+
.health
|
|
266
|
+
.as_ref()
|
|
267
|
+
.map_or_else(Vec::new, json_threshold_overrides)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
fn report_verdict(findings: &[Finding]) -> Verdict {
|
|
271
|
+
if findings
|
|
272
|
+
.iter()
|
|
273
|
+
.any(|finding| finding.severity == Severity::Error)
|
|
274
|
+
{
|
|
275
|
+
Verdict::Fail
|
|
276
|
+
} else {
|
|
277
|
+
Verdict::Pass
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
fn report_findings(
|
|
282
|
+
project: &ScannedProject,
|
|
283
|
+
results: &AnalysisResults,
|
|
284
|
+
scope: Option<&BTreeSet<String>>,
|
|
285
|
+
) -> Vec<Finding> {
|
|
286
|
+
let mut findings = Vec::new();
|
|
287
|
+
add_unresolved_findings(project, &mut findings);
|
|
288
|
+
add_part_of_findings(project, &mut findings);
|
|
289
|
+
|
|
290
|
+
if let Some(dead_code) = &results.dead_code {
|
|
291
|
+
add_dead_code_findings(&project.root, dead_code, &mut findings);
|
|
292
|
+
}
|
|
293
|
+
if let Some(symbols) = &results.symbols {
|
|
294
|
+
add_symbol_findings(&project.root, symbols, &mut findings);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
add_cycle_findings(&project.root, &results.cycles, &mut findings);
|
|
298
|
+
add_re_export_cycle_findings(&project.root, &results.re_export_cycles, &mut findings);
|
|
299
|
+
add_boundary_findings(&project.root, &results.boundary_violations, &mut findings);
|
|
300
|
+
graph_findings::add_boundary_coverage_findings(
|
|
301
|
+
&project.root,
|
|
302
|
+
&results.boundary_coverage,
|
|
303
|
+
&mut findings,
|
|
304
|
+
);
|
|
305
|
+
add_boundary_call_findings(
|
|
306
|
+
&project.root,
|
|
307
|
+
&results.boundary_call_violations,
|
|
308
|
+
&mut findings,
|
|
309
|
+
);
|
|
310
|
+
add_policy_findings(&project.root, &results.policy_violations, &mut findings);
|
|
311
|
+
if let Some(dependency_hygiene) = &results.dependency_hygiene {
|
|
312
|
+
add_dependency_hygiene_findings(&project.root, dependency_hygiene, &mut findings);
|
|
313
|
+
}
|
|
314
|
+
if let Some(duplicates) = &results.duplicates {
|
|
315
|
+
add_duplication_findings(&project.root, duplicates, &mut findings);
|
|
316
|
+
}
|
|
317
|
+
if let Some(health) = &results.health {
|
|
318
|
+
add_health_findings(&project.root, health, &mut findings);
|
|
319
|
+
}
|
|
320
|
+
if let Some(feature_flags) = &results.feature_flags {
|
|
321
|
+
add_feature_flag_findings(&project.root, feature_flags, &mut findings);
|
|
322
|
+
}
|
|
323
|
+
if let Some(security) = &results.security {
|
|
324
|
+
add_security_findings(&project.root, security, &mut findings);
|
|
325
|
+
}
|
|
326
|
+
if let Some(routes) = &results.routes {
|
|
327
|
+
add_route_findings(&project.root, routes, &mut findings);
|
|
328
|
+
}
|
|
329
|
+
if let Some(widgets) = &results.widgets {
|
|
330
|
+
add_widget_findings(&project.root, widgets, &mut findings);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
let mut findings = filter_suppressed_findings(
|
|
334
|
+
&project.root,
|
|
335
|
+
&project.files,
|
|
336
|
+
findings,
|
|
337
|
+
results.require_suppression_reasons,
|
|
338
|
+
)
|
|
339
|
+
.into_iter()
|
|
340
|
+
.filter(|finding| finding_in_scope(finding, scope))
|
|
341
|
+
.collect::<Vec<_>>();
|
|
342
|
+
findings.sort_by(|left, right| {
|
|
343
|
+
(
|
|
344
|
+
&left.rule_id,
|
|
345
|
+
&left.path,
|
|
346
|
+
left.line,
|
|
347
|
+
left.column,
|
|
348
|
+
&left.message,
|
|
349
|
+
)
|
|
350
|
+
.cmp(&(
|
|
351
|
+
&right.rule_id,
|
|
352
|
+
&right.path,
|
|
353
|
+
right.line,
|
|
354
|
+
right.column,
|
|
355
|
+
&right.message,
|
|
356
|
+
))
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
findings
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fn report_summary(
|
|
363
|
+
project: &ScannedProject,
|
|
364
|
+
results: &AnalysisResults,
|
|
365
|
+
findings: &[Finding],
|
|
366
|
+
scope: Option<&BTreeSet<String>>,
|
|
367
|
+
) -> ReportSummary {
|
|
368
|
+
let mut summary = ReportSummary {
|
|
369
|
+
findings: findings.len(),
|
|
370
|
+
..ReportSummary::default()
|
|
371
|
+
};
|
|
372
|
+
let scoped = results.file_scope.is_some();
|
|
373
|
+
apply_project_summary(&mut summary, project);
|
|
374
|
+
apply_dependency_summary(&mut summary, results, findings);
|
|
375
|
+
apply_cleanup_summary(&mut summary, results, findings);
|
|
376
|
+
apply_widget_summary(&mut summary, findings);
|
|
377
|
+
apply_quality_summary(&mut summary, project, results, findings, scope);
|
|
378
|
+
apply_feature_flag_summary(&mut summary, results);
|
|
379
|
+
apply_security_summary(&mut summary, results);
|
|
380
|
+
apply_graph_policy_summary(&mut summary, results, findings);
|
|
381
|
+
|
|
382
|
+
if scoped {
|
|
383
|
+
if let Some(scope) = scope {
|
|
384
|
+
summary.files = project_file_scope_count(project, scope);
|
|
385
|
+
}
|
|
386
|
+
apply_scoped_counts(&mut summary, findings);
|
|
387
|
+
}
|
|
388
|
+
summary
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
fn apply_project_summary(summary: &mut ReportSummary, project: &ScannedProject) {
|
|
392
|
+
summary.files = project.files.len();
|
|
393
|
+
summary.edges = project.graph.edge_count();
|
|
394
|
+
summary.unresolved_dependencies = project_unresolved_count(project);
|
|
395
|
+
summary.part_of_violations = project_part_of_violation_count(project);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
fn apply_dependency_summary(
|
|
399
|
+
summary: &mut ReportSummary,
|
|
400
|
+
results: &AnalysisResults,
|
|
401
|
+
findings: &[Finding],
|
|
402
|
+
) {
|
|
403
|
+
summary.unused_dependencies = results
|
|
404
|
+
.dependency_hygiene
|
|
405
|
+
.as_ref()
|
|
406
|
+
.map_or(0, |report| report.unused_dependencies.len());
|
|
407
|
+
summary.unused_dev_dependencies = kind_count(findings, FindingKind::UnusedDevDependency);
|
|
408
|
+
summary.test_only_dependencies = kind_count(findings, FindingKind::TestOnlyDependency);
|
|
409
|
+
summary.dependency_overrides = dependency_override_count(findings);
|
|
410
|
+
summary.unused_dependency_overrides =
|
|
411
|
+
kind_count(findings, FindingKind::UnusedDependencyOverride);
|
|
412
|
+
summary.misconfigured_dependency_overrides =
|
|
413
|
+
kind_count(findings, FindingKind::MisconfiguredDependencyOverride);
|
|
414
|
+
summary.unlisted_dependencies = results
|
|
415
|
+
.dependency_hygiene
|
|
416
|
+
.as_ref()
|
|
417
|
+
.map_or(0, |report| report.unlisted_dependencies.len());
|
|
418
|
+
summary.private_src_imports = results
|
|
419
|
+
.dependency_hygiene
|
|
420
|
+
.as_ref()
|
|
421
|
+
.map_or(0, |report| report.private_src_imports.len());
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
fn apply_cleanup_summary(
|
|
425
|
+
summary: &mut ReportSummary,
|
|
426
|
+
results: &AnalysisResults,
|
|
427
|
+
findings: &[Finding],
|
|
428
|
+
) {
|
|
429
|
+
summary.dead_files = results
|
|
430
|
+
.dead_code
|
|
431
|
+
.as_ref()
|
|
432
|
+
.map_or(0, |dead_code| dead_code.dead_files.len());
|
|
433
|
+
summary.unused_exports = kind_count(findings, FindingKind::UnusedExport);
|
|
434
|
+
summary.unused_types = kind_count(findings, FindingKind::UnusedType);
|
|
435
|
+
summary.private_type_leaks = kind_count(findings, FindingKind::PrivateTypeLeak);
|
|
436
|
+
summary.unused_enum_members = kind_count(findings, FindingKind::UnusedEnumMember);
|
|
437
|
+
summary.unused_class_members = kind_count(findings, FindingKind::UnusedClassMember);
|
|
438
|
+
summary.duplicate_exports = kind_count(findings, FindingKind::DuplicateExport);
|
|
439
|
+
summary.route_collisions = kind_count(findings, FindingKind::RouteCollision);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
fn apply_widget_summary(summary: &mut ReportSummary, findings: &[Finding]) {
|
|
443
|
+
summary.private_widget_classes = kind_count(findings, FindingKind::PrivateWidgetClass);
|
|
444
|
+
summary.widget_top_level_functions =
|
|
445
|
+
kind_count(findings, FindingKind::WidgetTopLevelFunctionBoundary);
|
|
446
|
+
summary.unused_widget_params = kind_count(findings, FindingKind::UnusedWidgetParam);
|
|
447
|
+
summary.unrendered_widgets = kind_count(findings, FindingKind::UnrenderedWidget);
|
|
448
|
+
summary.missing_context_mounted_after_await =
|
|
449
|
+
kind_count(findings, FindingKind::MissingContextMountedAfterAwait);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
fn apply_quality_summary(
|
|
453
|
+
summary: &mut ReportSummary,
|
|
454
|
+
project: &ScannedProject,
|
|
455
|
+
results: &AnalysisResults,
|
|
456
|
+
findings: &[Finding],
|
|
457
|
+
scope: Option<&BTreeSet<String>>,
|
|
458
|
+
) {
|
|
459
|
+
let health = health_summary_counts(project, results, scope);
|
|
460
|
+
if let Some(report) = &results.duplicates {
|
|
461
|
+
summary.code_duplications = report.clone_groups.len();
|
|
462
|
+
summary.duplication_analyzed_lines = report.stats.analyzed_lines;
|
|
463
|
+
summary.duplicated_lines = report.stats.duplicated_lines;
|
|
464
|
+
summary.duplication_percentage_basis_points =
|
|
465
|
+
report.stats.duplication_percentage_basis_points;
|
|
466
|
+
summary.duplication_threshold_basis_points = report
|
|
467
|
+
.options
|
|
468
|
+
.threshold
|
|
469
|
+
.map(crate::DuplicationThreshold::basis_points);
|
|
470
|
+
summary.duplication_threshold_exceeded = report.stats.threshold_exceeded;
|
|
471
|
+
}
|
|
472
|
+
summary.quality_score = health.quality_score;
|
|
473
|
+
summary.health_files = health.files;
|
|
474
|
+
summary.functions = health.functions;
|
|
475
|
+
summary.complex_functions = health.complex_functions;
|
|
476
|
+
summary.max_cyclomatic_complexity = health.max_cyclomatic_complexity;
|
|
477
|
+
summary.max_cognitive_complexity = health.max_cognitive_complexity;
|
|
478
|
+
summary.coverage_files = health.coverage_files;
|
|
479
|
+
summary.coverage_gaps = kind_count(findings, FindingKind::CoverageGap);
|
|
480
|
+
summary.crap_functions = kind_count(findings, FindingKind::HighCrapScore);
|
|
481
|
+
summary.max_crap_score = health.max_crap_score;
|
|
482
|
+
summary.file_scores = health.file_scores;
|
|
483
|
+
summary.hotspots = kind_count(findings, FindingKind::HealthHotspot);
|
|
484
|
+
summary.refactoring_targets = kind_count(findings, FindingKind::RefactoringTarget);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
fn apply_feature_flag_summary(summary: &mut ReportSummary, results: &AnalysisResults) {
|
|
488
|
+
summary.feature_flags = results
|
|
489
|
+
.feature_flags
|
|
490
|
+
.as_ref()
|
|
491
|
+
.map_or(0, |report| report.flags.len());
|
|
492
|
+
summary.feature_flag_occurrences = results
|
|
493
|
+
.feature_flags
|
|
494
|
+
.as_ref()
|
|
495
|
+
.map_or(0, |report| report.total_occurrences);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
fn apply_security_summary(summary: &mut ReportSummary, results: &AnalysisResults) {
|
|
499
|
+
summary.security_candidates = results
|
|
500
|
+
.security
|
|
501
|
+
.as_ref()
|
|
502
|
+
.map_or(0, |report| report.candidates.len());
|
|
503
|
+
summary.security_candidate_occurrences = results
|
|
504
|
+
.security
|
|
505
|
+
.as_ref()
|
|
506
|
+
.map_or(0, |report| report.total_occurrences);
|
|
507
|
+
summary.attack_surface = results
|
|
508
|
+
.security
|
|
509
|
+
.as_ref()
|
|
510
|
+
.map_or(0, |report| report.attack_surface.len());
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
fn apply_graph_policy_summary(
|
|
514
|
+
summary: &mut ReportSummary,
|
|
515
|
+
results: &AnalysisResults,
|
|
516
|
+
findings: &[Finding],
|
|
517
|
+
) {
|
|
518
|
+
summary.missing_entry_points = results
|
|
519
|
+
.dead_code
|
|
520
|
+
.as_ref()
|
|
521
|
+
.map_or(0, |dead_code| dead_code.missing_entry_points.len());
|
|
522
|
+
summary.cycles = results.cycles.len();
|
|
523
|
+
summary.re_export_cycles = results.re_export_cycles.len();
|
|
524
|
+
summary.boundary_violations = results.boundary_violations.len();
|
|
525
|
+
summary.boundary_coverage = kind_count(findings, FindingKind::BoundaryCoverage);
|
|
526
|
+
summary.boundary_call_violations = kind_count(findings, FindingKind::BoundaryCallViolation);
|
|
527
|
+
summary.policy_violations = kind_count(findings, FindingKind::PolicyViolation);
|
|
528
|
+
summary.missing_suppression_reasons =
|
|
529
|
+
kind_count(findings, FindingKind::MissingSuppressionReason);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
533
|
+
struct HealthSummaryCounts {
|
|
534
|
+
quality_score: usize,
|
|
535
|
+
files: usize,
|
|
536
|
+
functions: usize,
|
|
537
|
+
complex_functions: usize,
|
|
538
|
+
max_cyclomatic_complexity: usize,
|
|
539
|
+
max_cognitive_complexity: usize,
|
|
540
|
+
coverage_files: usize,
|
|
541
|
+
max_crap_score: usize,
|
|
542
|
+
file_scores: usize,
|
|
543
|
+
}
|
|
544
|
+
fn health_summary_counts(
|
|
545
|
+
project: &ScannedProject,
|
|
546
|
+
results: &AnalysisResults,
|
|
547
|
+
scope: Option<&BTreeSet<String>>,
|
|
548
|
+
) -> HealthSummaryCounts {
|
|
549
|
+
results.health.as_ref().map_or(
|
|
550
|
+
HealthSummaryCounts {
|
|
551
|
+
files: 0,
|
|
552
|
+
quality_score: 0,
|
|
553
|
+
functions: 0,
|
|
554
|
+
complex_functions: 0,
|
|
555
|
+
max_cyclomatic_complexity: 0,
|
|
556
|
+
max_cognitive_complexity: 0,
|
|
557
|
+
coverage_files: 0,
|
|
558
|
+
max_crap_score: 0,
|
|
559
|
+
file_scores: 0,
|
|
560
|
+
},
|
|
561
|
+
|report| HealthSummaryCounts {
|
|
562
|
+
quality_score: scoped_quality_score(project, report, scope),
|
|
563
|
+
files: report.analyzed_files,
|
|
564
|
+
functions: report.functions,
|
|
565
|
+
complex_functions: report.complexity.len() + report.crap.len(),
|
|
566
|
+
max_cyclomatic_complexity: report.max_cyclomatic_complexity,
|
|
567
|
+
max_cognitive_complexity: report.max_cognitive_complexity,
|
|
568
|
+
coverage_files: report.coverage_files,
|
|
569
|
+
max_crap_score: report.max_crap_score,
|
|
570
|
+
file_scores: health_file_score_count(project, &report.file_scores, scope),
|
|
571
|
+
},
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
fn apply_scoped_counts(summary: &mut ReportSummary, findings: &[Finding]) {
|
|
576
|
+
summary.unresolved_dependencies = kind_count(findings, FindingKind::UnresolvedDependency);
|
|
577
|
+
summary.part_of_violations = kind_count(findings, FindingKind::PartOfViolation);
|
|
578
|
+
summary.unused_dependencies = dependency_count(findings);
|
|
579
|
+
summary.unused_dev_dependencies = kind_count(findings, FindingKind::UnusedDevDependency);
|
|
580
|
+
summary.test_only_dependencies = kind_count(findings, FindingKind::TestOnlyDependency);
|
|
581
|
+
summary.dependency_overrides = dependency_override_count(findings);
|
|
582
|
+
summary.unused_dependency_overrides =
|
|
583
|
+
kind_count(findings, FindingKind::UnusedDependencyOverride);
|
|
584
|
+
summary.misconfigured_dependency_overrides =
|
|
585
|
+
kind_count(findings, FindingKind::MisconfiguredDependencyOverride);
|
|
586
|
+
summary.unlisted_dependencies = kind_count(findings, FindingKind::UnlistedDependency);
|
|
587
|
+
summary.private_src_imports = kind_count(findings, FindingKind::PrivateSrcImport);
|
|
588
|
+
summary.dead_files = kind_count(findings, FindingKind::DeadFile);
|
|
589
|
+
summary.unused_exports = kind_count(findings, FindingKind::UnusedExport);
|
|
590
|
+
summary.unused_types = kind_count(findings, FindingKind::UnusedType);
|
|
591
|
+
summary.private_type_leaks = kind_count(findings, FindingKind::PrivateTypeLeak);
|
|
592
|
+
summary.unused_enum_members = kind_count(findings, FindingKind::UnusedEnumMember);
|
|
593
|
+
summary.unused_class_members = kind_count(findings, FindingKind::UnusedClassMember);
|
|
594
|
+
summary.duplicate_exports = kind_count(findings, FindingKind::DuplicateExport);
|
|
595
|
+
summary.route_collisions = kind_count(findings, FindingKind::RouteCollision);
|
|
596
|
+
summary.private_widget_classes = kind_count(findings, FindingKind::PrivateWidgetClass);
|
|
597
|
+
summary.widget_top_level_functions =
|
|
598
|
+
kind_count(findings, FindingKind::WidgetTopLevelFunctionBoundary);
|
|
599
|
+
summary.unused_widget_params = kind_count(findings, FindingKind::UnusedWidgetParam);
|
|
600
|
+
summary.unrendered_widgets = kind_count(findings, FindingKind::UnrenderedWidget);
|
|
601
|
+
summary.missing_context_mounted_after_await =
|
|
602
|
+
kind_count(findings, FindingKind::MissingContextMountedAfterAwait);
|
|
603
|
+
summary.code_duplications = kind_count(findings, FindingKind::CodeDuplication);
|
|
604
|
+
summary.complex_functions = complexity_count(findings);
|
|
605
|
+
summary.coverage_gaps = kind_count(findings, FindingKind::CoverageGap);
|
|
606
|
+
summary.crap_functions = kind_count(findings, FindingKind::HighCrapScore);
|
|
607
|
+
summary.hotspots = kind_count(findings, FindingKind::HealthHotspot);
|
|
608
|
+
summary.refactoring_targets = kind_count(findings, FindingKind::RefactoringTarget);
|
|
609
|
+
summary.feature_flags = kind_count(findings, FindingKind::FeatureFlag);
|
|
610
|
+
summary.feature_flag_occurrences = summary.feature_flags;
|
|
611
|
+
summary.security_candidates = kind_count(findings, FindingKind::SecurityCandidate);
|
|
612
|
+
summary.security_candidate_occurrences = summary.security_candidates;
|
|
613
|
+
summary.attack_surface = 0;
|
|
614
|
+
summary.missing_entry_points = kind_count(findings, FindingKind::MissingEntryPoint);
|
|
615
|
+
summary.cycles = kind_count(findings, FindingKind::CircularDependency);
|
|
616
|
+
summary.re_export_cycles = kind_count(findings, FindingKind::ReExportCycle);
|
|
617
|
+
summary.boundary_violations = kind_count(findings, FindingKind::BoundaryViolation);
|
|
618
|
+
summary.boundary_coverage = kind_count(findings, FindingKind::BoundaryCoverage);
|
|
619
|
+
summary.boundary_call_violations = kind_count(findings, FindingKind::BoundaryCallViolation);
|
|
620
|
+
summary.policy_violations = kind_count(findings, FindingKind::PolicyViolation);
|
|
621
|
+
summary.missing_suppression_reasons =
|
|
622
|
+
kind_count(findings, FindingKind::MissingSuppressionReason);
|
|
623
|
+
}
|
|
624
|
+
fn kind_count(findings: &[Finding], kind: FindingKind) -> usize {
|
|
625
|
+
findings
|
|
626
|
+
.iter()
|
|
627
|
+
.filter(|finding| finding.kind == kind)
|
|
628
|
+
.count()
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
fn dependency_count(findings: &[Finding]) -> usize {
|
|
632
|
+
findings
|
|
633
|
+
.iter()
|
|
634
|
+
.filter(|finding| is_dependency_hygiene_kind(finding.kind))
|
|
635
|
+
.count()
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
fn dependency_override_count(findings: &[Finding]) -> usize {
|
|
639
|
+
kind_count(findings, FindingKind::UnusedDependencyOverride)
|
|
640
|
+
+ kind_count(findings, FindingKind::MisconfiguredDependencyOverride)
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const fn is_dependency_hygiene_kind(kind: FindingKind) -> bool {
|
|
644
|
+
matches!(
|
|
645
|
+
kind,
|
|
646
|
+
FindingKind::UnusedDependency
|
|
647
|
+
| FindingKind::UnusedDevDependency
|
|
648
|
+
| FindingKind::TestOnlyDependency
|
|
649
|
+
| FindingKind::UnusedDependencyOverride
|
|
650
|
+
)
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
const fn is_complexity_kind(kind: FindingKind) -> bool {
|
|
654
|
+
matches!(
|
|
655
|
+
kind,
|
|
656
|
+
FindingKind::HighCyclomaticComplexity
|
|
657
|
+
| FindingKind::HighCognitiveComplexity
|
|
658
|
+
| FindingKind::HighComplexity
|
|
659
|
+
| FindingKind::HighCrapScore
|
|
660
|
+
| FindingKind::CoverageGap
|
|
661
|
+
| FindingKind::HealthHotspot
|
|
662
|
+
| FindingKind::RefactoringTarget
|
|
663
|
+
)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
fn complexity_count(findings: &[Finding]) -> usize {
|
|
667
|
+
findings
|
|
668
|
+
.iter()
|
|
669
|
+
.filter(|finding| {
|
|
670
|
+
matches!(
|
|
671
|
+
finding.kind,
|
|
672
|
+
FindingKind::HighCyclomaticComplexity
|
|
673
|
+
| FindingKind::HighCognitiveComplexity
|
|
674
|
+
| FindingKind::HighComplexity
|
|
675
|
+
| FindingKind::HighCrapScore
|
|
676
|
+
)
|
|
677
|
+
})
|
|
678
|
+
.count()
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
#[cfg(test)]
|
|
682
|
+
mod tests;
|