dart-decimate 0.0.74 → 0.0.76
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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +11 -10
- package/package.json +2 -2
- package/src/baseline.rs +5 -16
- package/src/cli/issue_filter_args.rs +10 -0
- package/src/config/rule_aliases.rs +6 -0
- package/src/config/rules.rs +3 -6
- package/src/dependencies/analyze.rs +14 -3
- package/src/dependencies/overrides.rs +9 -1
- package/src/dependencies/package_cycles.rs +69 -0
- package/src/dependencies/package_graph.rs +53 -0
- package/src/dependencies/usage.rs +9 -0
- package/src/dependencies.rs +63 -8
- package/src/explain.rs +21 -9
- package/src/extract/members.rs +159 -6
- package/src/extract/tests.rs +35 -0
- package/src/extract.rs +48 -51
- package/src/generated.rs +10 -1
- package/src/graph/augment_tests.rs +1 -0
- package/src/graph/package_config_tests.rs +3 -0
- package/src/graph/pubspec_tests.rs +1 -0
- package/src/graph/tests.rs +3 -0
- package/src/graph/uri_tests.rs +1 -0
- package/src/health/coverage.rs +1 -1
- package/src/health/tests.rs +54 -0
- package/src/health/thresholds.rs +1 -1
- package/src/health/types.rs +2 -2
- package/src/intelligence/tests.rs +2 -0
- package/src/lib.rs +5 -10
- package/src/manifest.rs +3 -2
- package/src/mcp/cli_args/value_args.rs +1 -0
- package/src/output/dependency_findings.rs +41 -2
- package/src/output/human_details.rs +8 -0
- package/src/output/suppressions.rs +1 -0
- package/src/output/symbol_findings.rs +6 -2
- package/src/output/types.rs +10 -6
- package/src/output.rs +2 -0
- package/src/report_schema.rs +2 -0
- package/src/security_gate.rs +3 -6
- package/src/symbols/duplicate_declarations.rs +237 -0
- package/src/symbols/tests.rs +1 -0
- package/src/symbols.rs +354 -10
- package/src/widgets/resolution.rs +6 -6
- package/src/widgets.rs +1 -4
package/src/health/tests.rs
CHANGED
|
@@ -186,6 +186,60 @@ end_of_record
|
|
|
186
186
|
Ok(())
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
#[test]
|
|
190
|
+
fn crap_score_equal_to_the_limit_is_reported() -> Result<(), Box<dyn std::error::Error>> {
|
|
191
|
+
let fixture = tempfile::tempdir()?;
|
|
192
|
+
write_coverage_source(&fixture)?;
|
|
193
|
+
write(
|
|
194
|
+
&fixture,
|
|
195
|
+
"coverage/lcov.info",
|
|
196
|
+
"SF:lib/main.dart
|
|
197
|
+
DA:2,0
|
|
198
|
+
DA:3,0
|
|
199
|
+
DA:4,0
|
|
200
|
+
DA:5,0
|
|
201
|
+
end_of_record
|
|
202
|
+
",
|
|
203
|
+
)?;
|
|
204
|
+
let project = scan_project(fixture.path())?;
|
|
205
|
+
let report_at = |max_crap: usize, threshold_overrides: Vec<HealthThresholdOverride>| {
|
|
206
|
+
analyze_health(
|
|
207
|
+
&project,
|
|
208
|
+
&HealthOptions {
|
|
209
|
+
coverage_path: Some("coverage/lcov.info".into()),
|
|
210
|
+
max_crap: Some(max_crap),
|
|
211
|
+
threshold_overrides,
|
|
212
|
+
..HealthOptions::default()
|
|
213
|
+
},
|
|
214
|
+
)
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
let at_limit = report_at(20, Vec::new())?;
|
|
218
|
+
let above_limit = report_at(21, Vec::new())?;
|
|
219
|
+
let override_at_limit = report_at(
|
|
220
|
+
100,
|
|
221
|
+
vec![HealthThresholdOverride {
|
|
222
|
+
files: vec!["lib/main.dart".to_owned()],
|
|
223
|
+
functions: vec!["uncovered".to_owned()],
|
|
224
|
+
max_cyclomatic: None,
|
|
225
|
+
max_cognitive: None,
|
|
226
|
+
max_crap: Some(20),
|
|
227
|
+
max_unit_size: None,
|
|
228
|
+
reason: None,
|
|
229
|
+
}],
|
|
230
|
+
)?;
|
|
231
|
+
|
|
232
|
+
assert_eq!(at_limit.crap.len(), 1);
|
|
233
|
+
assert_eq!(at_limit.crap[0].crap_score, 20);
|
|
234
|
+
assert_eq!(above_limit.crap, []);
|
|
235
|
+
assert_eq!(
|
|
236
|
+
override_at_limit.threshold_overrides[0].status,
|
|
237
|
+
HealthThresholdOverrideStatus::Active
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
Ok(())
|
|
241
|
+
}
|
|
242
|
+
|
|
189
243
|
#[test]
|
|
190
244
|
fn covered_lcov_lines_do_not_emit_coverage_findings() -> Result<(), Box<dyn std::error::Error>> {
|
|
191
245
|
let fixture = tempfile::tempdir()?;
|
package/src/health/thresholds.rs
CHANGED
|
@@ -208,7 +208,7 @@ impl ThresholdContext {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
fn crap_active(&self, crap_score: usize, max_crap: usize) -> bool {
|
|
211
|
-
self.max_crap.is_some_and(|global| crap_score
|
|
211
|
+
self.max_crap.is_some_and(|global| crap_score >= global) || crap_score >= max_crap
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
fn mark_matched(&mut self, index: usize, function: &FunctionMetrics) {
|
package/src/health/types.rs
CHANGED
|
@@ -215,7 +215,7 @@ pub struct HealthReport {
|
|
|
215
215
|
pub flutter_style: Option<crate::FlutterStyleReport>,
|
|
216
216
|
/// Source files with no covered executable lines.
|
|
217
217
|
pub coverage_gaps: Vec<CoverageGapFinding>,
|
|
218
|
-
/// Functions
|
|
218
|
+
/// Functions at or above the configured CRAP threshold.
|
|
219
219
|
pub crap: Vec<CrapFinding>,
|
|
220
220
|
/// Configured threshold override statuses.
|
|
221
221
|
pub threshold_overrides: Vec<HealthThresholdOverrideReport>,
|
|
@@ -400,7 +400,7 @@ pub enum CoverageGapReason {
|
|
|
400
400
|
ZeroCoveredLines,
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
/// One function-like declaration
|
|
403
|
+
/// One function-like declaration at or above the configured CRAP threshold.
|
|
404
404
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
405
405
|
pub struct CrapFinding {
|
|
406
406
|
/// Dart file path.
|
|
@@ -186,6 +186,7 @@ impl Fixture {
|
|
|
186
186
|
members: vec![],
|
|
187
187
|
references: vec![],
|
|
188
188
|
signature_references: vec![],
|
|
189
|
+
class_supertypes: vec![],
|
|
189
190
|
routes: vec![],
|
|
190
191
|
}
|
|
191
192
|
}
|
|
@@ -202,6 +203,7 @@ impl Fixture {
|
|
|
202
203
|
members: vec![],
|
|
203
204
|
references: vec![],
|
|
204
205
|
signature_references: vec![],
|
|
206
|
+
class_supertypes: vec![],
|
|
205
207
|
routes: vec![],
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/lib.rs
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
//! Dart Decimate analyzes Dart and Flutter repositories as module graphs.
|
|
2
|
-
//!
|
|
3
|
-
//! Phase 1 exposes a fast Tree-Sitter based extractor for imports, exports, and
|
|
4
|
-
//! top-level declarations. Phase 2 builds a directed module graph from those
|
|
5
|
-
//! syntax facts. Phase 3 runs graph traversals without evaluating variables,
|
|
6
|
-
//! types, or function bodies. Phase 4 exposes the CLI and JSON output contract.
|
|
7
2
|
|
|
8
3
|
/// Version compiled into the CLI and release artifacts.
|
|
9
4
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
@@ -90,7 +85,7 @@ pub use decision_surface::{
|
|
|
90
85
|
pub use dependencies::{
|
|
91
86
|
DeclaredPackageDependency, DependencyHygieneError, DependencyHygieneReport, DependencyIssue,
|
|
92
87
|
DependencyOverrideMisconfigReason, DependencySection, LocalPubPackage,
|
|
93
|
-
MisconfiguredDependencyOverride, PrivateSrcImport, UnlistedPackageDependency,
|
|
88
|
+
MisconfiguredDependencyOverride, PackageCycle, PrivateSrcImport, UnlistedPackageDependency,
|
|
94
89
|
UnusedPackageDependency, analyze_dependency_hygiene, declared_package_dependencies,
|
|
95
90
|
local_pub_packages,
|
|
96
91
|
};
|
|
@@ -103,10 +98,10 @@ pub use explain::{
|
|
|
103
98
|
EXPLAIN_SCHEMA_VERSION, ExplainError, ExplainReport, explain_issue, render_explain_report,
|
|
104
99
|
};
|
|
105
100
|
pub use extract::{
|
|
106
|
-
DartCombinator, DartCombinatorKind, DartExport, DartFile, DartImport,
|
|
107
|
-
DartPartOf, DartRouteDeclaration, DartUriCondition, DeclarationKind,
|
|
108
|
-
IdentifierReference, Location, MemberDeclaration, MemberKind, SignatureReference,
|
|
109
|
-
TopLevelDeclaration, extract_dart_file, extract_dart_source,
|
|
101
|
+
ClassSupertypes, DartCombinator, DartCombinatorKind, DartExport, DartFile, DartImport,
|
|
102
|
+
DartLibrary, DartPart, DartPartOf, DartRouteDeclaration, DartUriCondition, DeclarationKind,
|
|
103
|
+
ExtractError, IdentifierReference, Location, MemberDeclaration, MemberKind, SignatureReference,
|
|
104
|
+
SourceRange, TopLevelDeclaration, extract_dart_file, extract_dart_source,
|
|
110
105
|
};
|
|
111
106
|
pub use feature_flags::{
|
|
112
107
|
FeatureFlag, FeatureFlagConfidence, FeatureFlagError, FeatureFlagOccurrence,
|
package/src/manifest.rs
CHANGED
|
@@ -147,7 +147,7 @@ fn analysis_commands() -> Value {
|
|
|
147
147
|
"kind": "combined",
|
|
148
148
|
"description": "Run all enabled graph, symbol, dependency, duplicate, health, flag, and security checks.",
|
|
149
149
|
"schema": SCHEMA_VERSION,
|
|
150
|
-
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
150
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides", "--package-cycles"]
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"name": "audit",
|
|
@@ -175,7 +175,7 @@ fn analysis_commands() -> Value {
|
|
|
175
175
|
"kind": "dead-code",
|
|
176
176
|
"description": "Find unreachable Dart files and conservative symbol-level dead code.",
|
|
177
177
|
"schema": SCHEMA_VERSION,
|
|
178
|
-
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
178
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides", "--package-cycles"]
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
"name": "cycles",
|
|
@@ -482,6 +482,7 @@ fn issue_types() -> Value {
|
|
|
482
482
|
"test-only-dependency",
|
|
483
483
|
"unused-dependency-override",
|
|
484
484
|
"misconfigured-dependency-override",
|
|
485
|
+
"package-cycle",
|
|
485
486
|
"unlisted-dependency",
|
|
486
487
|
"private-src-import",
|
|
487
488
|
"code-duplication",
|
|
@@ -169,6 +169,7 @@ pub(super) fn issue_filter_flag(issue_type: &str) -> Result<String, String> {
|
|
|
169
169
|
"misconfigured-dependency-overrides" | "misconfigured-dependency-override" => {
|
|
170
170
|
Ok("--misconfigured-dependency-overrides".to_owned())
|
|
171
171
|
}
|
|
172
|
+
"package-cycles" | "package-cycle" => Ok("--package-cycles".to_owned()),
|
|
172
173
|
"private-type-leak" | "private-type-leaks" => Ok("--private-type-leaks".to_owned()),
|
|
173
174
|
_ => Err(format!("unsupported issue_type {issue_type}")),
|
|
174
175
|
}
|
|
@@ -4,7 +4,7 @@ use super::format::{dependency_kind, display_path};
|
|
|
4
4
|
use super::{Finding, FindingAction, FindingEdge, FindingKind, Severity};
|
|
5
5
|
use crate::{
|
|
6
6
|
DependencyHygieneReport, DependencyIssue, DependencyOverrideMisconfigReason, DependencySection,
|
|
7
|
-
MisconfiguredDependencyOverride, PrivateSrcImport, UnlistedPackageDependency,
|
|
7
|
+
MisconfiguredDependencyOverride, PackageCycle, PrivateSrcImport, UnlistedPackageDependency,
|
|
8
8
|
UnusedPackageDependency,
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -25,6 +25,12 @@ pub(super) fn add_dependency_hygiene_findings(
|
|
|
25
25
|
.iter()
|
|
26
26
|
.map(|dependency| misconfigured_override_finding(root, dependency)),
|
|
27
27
|
);
|
|
28
|
+
findings.extend(
|
|
29
|
+
report
|
|
30
|
+
.package_cycles
|
|
31
|
+
.iter()
|
|
32
|
+
.map(|cycle| package_cycle_finding(root, cycle)),
|
|
33
|
+
);
|
|
28
34
|
findings.extend(
|
|
29
35
|
report
|
|
30
36
|
.unlisted_dependencies
|
|
@@ -121,7 +127,7 @@ fn message(dependency: &UnusedPackageDependency) -> String {
|
|
|
121
127
|
dependency.package, dependency.dependency
|
|
122
128
|
),
|
|
123
129
|
DependencyIssue::UnusedDependencyOverride => format!(
|
|
124
|
-
"{} declares unused dependency override {} that is absent from pubspec.lock
|
|
130
|
+
"{} declares unused dependency override {} that is absent from pubspec.lock or not reached by the dependency graph",
|
|
125
131
|
dependency.package, dependency.dependency
|
|
126
132
|
),
|
|
127
133
|
}
|
|
@@ -200,6 +206,39 @@ fn misconfigured_override_finding(
|
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
|
|
209
|
+
fn package_cycle_finding(root: &Path, cycle: &PackageCycle) -> Finding {
|
|
210
|
+
let files = cycle
|
|
211
|
+
.pubspec_paths
|
|
212
|
+
.iter()
|
|
213
|
+
.map(|path| display_path(root, path))
|
|
214
|
+
.collect::<Vec<_>>();
|
|
215
|
+
let path = files.first().cloned().unwrap_or_default();
|
|
216
|
+
Finding {
|
|
217
|
+
rule_id: "dart-decimate/package-cycle".to_owned(),
|
|
218
|
+
fingerprint: None,
|
|
219
|
+
kind: FindingKind::PackageCycle,
|
|
220
|
+
severity: Severity::Error,
|
|
221
|
+
message: format!(
|
|
222
|
+
"Packages {} depend on each other",
|
|
223
|
+
cycle.packages.join(", ")
|
|
224
|
+
),
|
|
225
|
+
path: path.clone(),
|
|
226
|
+
line: 1,
|
|
227
|
+
column: 0,
|
|
228
|
+
safe_to_delete: false,
|
|
229
|
+
files,
|
|
230
|
+
edge: None,
|
|
231
|
+
actions: vec![
|
|
232
|
+
FindingAction::new(
|
|
233
|
+
"break-package-cycle",
|
|
234
|
+
"Move the shared code into a third package or remove one pubspec dependency",
|
|
235
|
+
false,
|
|
236
|
+
)
|
|
237
|
+
.with_target_path(path),
|
|
238
|
+
],
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
203
242
|
fn misconfigured_override_message(dependency: &MisconfiguredDependencyOverride) -> String {
|
|
204
243
|
let reason = match dependency.reason {
|
|
205
244
|
DependencyOverrideMisconfigReason::UnparsableKey => "has an invalid package name",
|
|
@@ -41,6 +41,12 @@ fn architecture_items(summary: &ReportSummary) -> Vec<String> {
|
|
|
41
41
|
"re-export cycle",
|
|
42
42
|
"re-export cycles",
|
|
43
43
|
);
|
|
44
|
+
push_count(
|
|
45
|
+
&mut items,
|
|
46
|
+
summary.package_cycles,
|
|
47
|
+
"package cycle",
|
|
48
|
+
"package cycles",
|
|
49
|
+
);
|
|
44
50
|
push_count(
|
|
45
51
|
&mut items,
|
|
46
52
|
summary.boundary_violations,
|
|
@@ -365,6 +371,7 @@ pub(super) const fn kind_label(kind: FindingKind) -> &'static str {
|
|
|
365
371
|
FindingKind::TestOnlyDependency => "Test-only production dependency",
|
|
366
372
|
FindingKind::UnusedDependencyOverride => "Unused dependency override",
|
|
367
373
|
FindingKind::MisconfiguredDependencyOverride => "Misconfigured dependency override",
|
|
374
|
+
FindingKind::PackageCycle => "Package cycle",
|
|
368
375
|
FindingKind::UnlistedDependency => "Unlisted dependency",
|
|
369
376
|
FindingKind::PrivateSrcImport => "Private lib/src import",
|
|
370
377
|
FindingKind::CodeDuplication => "Code duplication",
|
|
@@ -426,6 +433,7 @@ pub(super) const fn why_text(kind: FindingKind) -> &'static str {
|
|
|
426
433
|
| FindingKind::TestOnlyDependency
|
|
427
434
|
| FindingKind::UnusedDependencyOverride
|
|
428
435
|
| FindingKind::MisconfiguredDependencyOverride
|
|
436
|
+
| FindingKind::PackageCycle
|
|
429
437
|
| FindingKind::UnlistedDependency => {
|
|
430
438
|
"The pubspec dependency graph and the Dart import graph do not agree."
|
|
431
439
|
}
|
|
@@ -364,6 +364,7 @@ const fn kind_key(kind: FindingKind) -> &'static str {
|
|
|
364
364
|
FindingKind::TestOnlyDependency => "test-only-dependency",
|
|
365
365
|
FindingKind::UnusedDependencyOverride => "unused-dependency-override",
|
|
366
366
|
FindingKind::MisconfiguredDependencyOverride => "misconfigured-dependency-override",
|
|
367
|
+
FindingKind::PackageCycle => "package-cycle",
|
|
367
368
|
FindingKind::UnlistedDependency => "unlisted-dependency",
|
|
368
369
|
FindingKind::PrivateSrcImport => "private-src-import",
|
|
369
370
|
FindingKind::CodeDuplication => "code-duplication",
|
|
@@ -168,7 +168,7 @@ fn duplicate_export_finding(root: &Path, duplicate: &DuplicateExport) -> Finding
|
|
|
168
168
|
kind: FindingKind::DuplicateExport,
|
|
169
169
|
severity: Severity::Error,
|
|
170
170
|
message: format!(
|
|
171
|
-
"
|
|
171
|
+
"Multiple library files declare or export a public name {}",
|
|
172
172
|
duplicate.name
|
|
173
173
|
),
|
|
174
174
|
path: path.clone(),
|
|
@@ -208,7 +208,11 @@ fn unused_member_finding(root: &Path, unused: &UnusedMember) -> Finding {
|
|
|
208
208
|
_ => (
|
|
209
209
|
"dart-decimate/unused-class-member",
|
|
210
210
|
FindingKind::UnusedClassMember,
|
|
211
|
-
|
|
211
|
+
if unused.name.starts_with('_') {
|
|
212
|
+
"private class-like member"
|
|
213
|
+
} else {
|
|
214
|
+
"public class-like member"
|
|
215
|
+
},
|
|
212
216
|
),
|
|
213
217
|
};
|
|
214
218
|
Finding {
|
package/src/output/types.rs
CHANGED
|
@@ -208,10 +208,12 @@ pub struct ReportSummary {
|
|
|
208
208
|
pub test_only_dependencies: usize,
|
|
209
209
|
/// Dependency override findings across all override hygiene classes.
|
|
210
210
|
pub dependency_overrides: usize,
|
|
211
|
-
/// Dependency overrides absent from the resolved
|
|
211
|
+
/// Dependency overrides absent from the lockfile or not reached by the resolved package graph.
|
|
212
212
|
pub unused_dependency_overrides: usize,
|
|
213
213
|
/// Dependency override entries Pub cannot honor.
|
|
214
214
|
pub misconfigured_dependency_overrides: usize,
|
|
215
|
+
/// Local packages that depend on each other through their pubspecs.
|
|
216
|
+
pub package_cycles: usize,
|
|
215
217
|
/// Imported pub packages absent from pubspec dependencies.
|
|
216
218
|
pub unlisted_dependencies: usize,
|
|
217
219
|
/// Imports into another package's private `lib/src` implementation tree.
|
|
@@ -226,7 +228,7 @@ pub struct ReportSummary {
|
|
|
226
228
|
pub private_type_leaks: usize,
|
|
227
229
|
/// Unused enum constants.
|
|
228
230
|
pub unused_enum_members: usize,
|
|
229
|
-
/// Unused
|
|
231
|
+
/// Unused class-like members.
|
|
230
232
|
pub unused_class_members: usize,
|
|
231
233
|
/// Public API symbols exported from multiple declarations.
|
|
232
234
|
pub duplicate_exports: usize,
|
|
@@ -285,7 +287,7 @@ pub struct ReportSummary {
|
|
|
285
287
|
pub coverage_files: usize,
|
|
286
288
|
/// Dart files with no observed covered executable lines.
|
|
287
289
|
pub coverage_gaps: usize,
|
|
288
|
-
/// Functions
|
|
290
|
+
/// Functions at or above the CRAP threshold.
|
|
289
291
|
pub crap_functions: usize,
|
|
290
292
|
/// Highest CRAP score.
|
|
291
293
|
pub max_crap_score: usize,
|
|
@@ -379,7 +381,7 @@ pub enum FindingKind {
|
|
|
379
381
|
PrivateTypeLeak,
|
|
380
382
|
/// Unused enum constant.
|
|
381
383
|
UnusedEnumMember,
|
|
382
|
-
/// Unused
|
|
384
|
+
/// Unused class-like member.
|
|
383
385
|
UnusedClassMember,
|
|
384
386
|
/// Public API entry exposes multiple declarations with the same name.
|
|
385
387
|
DuplicateExport,
|
|
@@ -423,10 +425,12 @@ pub enum FindingKind {
|
|
|
423
425
|
DevDependencyInProduction,
|
|
424
426
|
/// Runtime dependency is imported only from dev/test files.
|
|
425
427
|
TestOnlyDependency,
|
|
426
|
-
/// Dependency override is absent from the resolved
|
|
428
|
+
/// Dependency override is absent from the lockfile or not reached by the resolved package graph.
|
|
427
429
|
UnusedDependencyOverride,
|
|
428
430
|
/// Dependency override key or value cannot be honored by Pub.
|
|
429
431
|
MisconfiguredDependencyOverride,
|
|
432
|
+
/// Local packages depend on each other through their pubspecs.
|
|
433
|
+
PackageCycle,
|
|
430
434
|
/// Imported pub package is missing from pubspec.
|
|
431
435
|
UnlistedDependency,
|
|
432
436
|
/// Import reaches into another package's private `lib/src` implementation tree.
|
|
@@ -441,7 +445,7 @@ pub enum FindingKind {
|
|
|
441
445
|
HighComplexity,
|
|
442
446
|
/// Dart file has no observed covered executable lines.
|
|
443
447
|
CoverageGap,
|
|
444
|
-
/// Function
|
|
448
|
+
/// Function reached the CRAP threshold.
|
|
445
449
|
HighCrapScore,
|
|
446
450
|
/// File is a low-scoring health hotspot.
|
|
447
451
|
HealthHotspot,
|
package/src/output.rs
CHANGED
|
@@ -448,6 +448,7 @@ fn apply_dependency_summary(
|
|
|
448
448
|
kind_count(findings, FindingKind::UnusedDependencyOverride);
|
|
449
449
|
summary.misconfigured_dependency_overrides =
|
|
450
450
|
kind_count(findings, FindingKind::MisconfiguredDependencyOverride);
|
|
451
|
+
summary.package_cycles = kind_count(findings, FindingKind::PackageCycle);
|
|
451
452
|
summary.unlisted_dependencies = results
|
|
452
453
|
.dependency_hygiene
|
|
453
454
|
.as_ref()
|
|
@@ -627,6 +628,7 @@ fn apply_scoped_counts(summary: &mut ReportSummary, findings: &[Finding]) {
|
|
|
627
628
|
kind_count(findings, FindingKind::UnusedDependencyOverride);
|
|
628
629
|
summary.misconfigured_dependency_overrides =
|
|
629
630
|
kind_count(findings, FindingKind::MisconfiguredDependencyOverride);
|
|
631
|
+
summary.package_cycles = kind_count(findings, FindingKind::PackageCycle);
|
|
630
632
|
summary.unlisted_dependencies = kind_count(findings, FindingKind::UnlistedDependency);
|
|
631
633
|
summary.private_src_imports = kind_count(findings, FindingKind::PrivateSrcImport);
|
|
632
634
|
summary.dead_files = kind_count(findings, FindingKind::DeadFile);
|
package/src/report_schema.rs
CHANGED
|
@@ -141,6 +141,7 @@ const SUMMARY_INTEGER_FIELDS: &[&str] = &[
|
|
|
141
141
|
"dependency_overrides",
|
|
142
142
|
"unused_dependency_overrides",
|
|
143
143
|
"misconfigured_dependency_overrides",
|
|
144
|
+
"package_cycles",
|
|
144
145
|
"unlisted_dependencies",
|
|
145
146
|
"private_src_imports",
|
|
146
147
|
"dead_files",
|
|
@@ -352,6 +353,7 @@ fn finding_kind_values() -> Value {
|
|
|
352
353
|
"test-only-dependency",
|
|
353
354
|
"unused-dependency-override",
|
|
354
355
|
"misconfigured-dependency-override",
|
|
356
|
+
"package-cycle",
|
|
355
357
|
"unlisted-dependency",
|
|
356
358
|
"private-src-import",
|
|
357
359
|
"code-duplication",
|
package/src/security_gate.rs
CHANGED
|
@@ -92,11 +92,9 @@ impl ChangedLineScope {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/// Load changed-line scope from a unified diff file.
|
|
95
|
+
/// Load changed-line scope from a unified diff file, failing when the diff cannot be read.
|
|
96
96
|
///
|
|
97
97
|
/// # Errors
|
|
98
|
-
///
|
|
99
|
-
/// Returns [`SecurityGateError`] if the diff cannot be read.
|
|
100
98
|
pub(crate) fn changed_lines_from_diff_file(
|
|
101
99
|
root: &Path,
|
|
102
100
|
path: &Path,
|
|
@@ -113,11 +111,9 @@ pub(crate) fn changed_lines_from_diff(root: &Path, source: &str) -> ChangedLineS
|
|
|
113
111
|
changed_lines_from_unified_diff(root, source)
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
/// Load changed-line scope from Git changes since `base
|
|
114
|
+
/// Load changed-line scope from Git changes since `base`, failing when Git or a file read fails.
|
|
117
115
|
///
|
|
118
116
|
/// # Errors
|
|
119
|
-
///
|
|
120
|
-
/// Returns [`SecurityGateError`] if Git fails or an untracked file cannot be read.
|
|
121
117
|
pub(crate) fn changed_lines_from_git(
|
|
122
118
|
root: &Path,
|
|
123
119
|
base: &str,
|
|
@@ -416,6 +412,7 @@ fn recompute_summary(report: &mut JsonReport) {
|
|
|
416
412
|
kind_count(report, FindingKind::UnusedDependencyOverride);
|
|
417
413
|
report.summary.misconfigured_dependency_overrides =
|
|
418
414
|
kind_count(report, FindingKind::MisconfiguredDependencyOverride);
|
|
415
|
+
report.summary.package_cycles = kind_count(report, FindingKind::PackageCycle);
|
|
419
416
|
report.summary.unlisted_dependencies = kind_count(report, FindingKind::UnlistedDependency);
|
|
420
417
|
report.summary.private_src_imports = kind_count(report, FindingKind::PrivateSrcImport);
|
|
421
418
|
report.summary.dead_files = kind_count(report, FindingKind::DeadFile);
|