dart-decimate 0.0.11 → 0.0.13

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 CHANGED
@@ -77,9 +77,9 @@ dependencies = [
77
77
 
78
78
  [[package]]
79
79
  name = "crossbeam-epoch"
80
- version = "0.9.18"
80
+ version = "0.9.20"
81
81
  source = "registry+https://github.com/rust-lang/crates.io-index"
82
- checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
82
+ checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f"
83
83
  dependencies = [
84
84
  "crossbeam-utils",
85
85
  ]
@@ -92,7 +92,7 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
92
92
 
93
93
  [[package]]
94
94
  name = "dart-decimate"
95
- version = "0.0.11"
95
+ version = "0.0.13"
96
96
  dependencies = [
97
97
  "clap",
98
98
  "glob",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "dart-decimate"
3
- version = "0.0.11"
3
+ version = "0.0.13"
4
4
  edition = "2024"
5
5
  rust-version = "1.85"
6
6
  description = "Rust-native codebase intelligence for Dart and Flutter module graphs."
package/README.md CHANGED
@@ -91,7 +91,7 @@ Add this to `package.json` if you want a short project command:
91
91
  "dart-decimate": "dart-decimate json ."
92
92
  },
93
93
  "devDependencies": {
94
- "dart-decimate": "^0.0.11"
94
+ "dart-decimate": "^0.0.13"
95
95
  }
96
96
  }
97
97
  ```
@@ -282,9 +282,10 @@ Dart Decimate finds:
282
282
  - import/export/part/augment targets that do not resolve
283
283
  - invalid `part` / `part of` relationships
284
284
 
285
- Generated typed GoRouter route registries that only cycle through real
286
- typed-route navigation helpers are warning-level; unrelated imports in the cycle
287
- stay error-level.
285
+ Generated typed GoRouter route registry back-edges are warning-level only when
286
+ the importing file uses real typed-route navigation helpers. Mixed cycles still
287
+ emit error-level residual findings for unrelated edges, registry-to-registry
288
+ imports, exports, or non-route registry API usage.
288
289
 
289
290
  Useful commands:
290
291
 
@@ -461,7 +462,7 @@ Plain English:
461
462
  - `files`: Dart files Dart Decimate parsed
462
463
  - `edges`: imports, exports, parts, and augments it resolved
463
464
  - `quality_score`: project health from `0` to `100`
464
- - `cycles`: circular dependency groups
465
+ - `cycles`: emitted circular dependency findings after policy classification
465
466
  - `code_duplications`: duplicated code groups
466
467
  - `complex_functions`: functions over the complexity limits
467
468
  - `dead_files`: files Dart Decimate thinks are unreachable
@@ -485,6 +486,7 @@ Every finding includes:
485
486
  - `column`
486
487
  - `safe_to_delete`
487
488
  - related `files`
489
+ - related dependency `edge`, when available
488
490
  - suggested `actions`
489
491
 
490
492
  Example shape:
@@ -650,21 +652,27 @@ dart-decimate license status --format json
650
652
  ## Development
651
653
 
652
654
  ```bash
655
+ git diff --check
656
+ npm run lint
657
+ npm run version:bump:check -- origin/main
658
+ npm run release:check
653
659
  cargo fmt --check
654
660
  cargo clippy --all-targets -- -D warnings
661
+ npm ci --ignore-scripts
662
+ npx fallow audit --base origin/main --quiet
655
663
  cargo test --all-targets
656
- npm run version:check
657
- npm run version:bump:check -- origin/main
658
- npm run release:check
659
- npm run migration:check
660
664
  npm run pack:check
665
+ npm run test:postinstall:prebuilt
666
+ npm run test:npx:prebuilt
667
+ npm run test:npx:local
668
+ npm run test:npx:mcp:local
661
669
  ```
662
670
 
663
671
  This repository forbids `unsafe_code`.
664
672
 
665
673
  ## Release Flow
666
674
 
667
- Current version: `0.0.11`.
675
+ Current version: `0.0.13`.
668
676
 
669
677
  After the first public release, changes should go through pull requests. Every
670
678
  PR to `main` must bump both `Cargo.toml` and `package.json` above the base
@@ -683,8 +691,9 @@ Release reruns for the same commit may update GitHub release assets. If the npm
683
691
  package already exists for that commit, the publish step is skipped; a reused tag
684
692
  or npm version from another commit fails.
685
693
 
686
- Local hooks block stale package names, mismatched versions, reused npm versions,
687
- and direct pushes to `main`.
694
+ Local hooks block direct pushes to `main`, fetch the configured base ref when
695
+ needed, and run the same version, release, lint, Fallow, package, and test gates
696
+ as the local no-mistakes configuration.
688
697
 
689
698
  ## License
690
699
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dart-decimate",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -28,6 +28,7 @@
28
28
  "scripts": {
29
29
  "postinstall": "node npm/scripts/postinstall.js",
30
30
  "version:check": "node scripts/check-version-sync.mjs",
31
+ "lint": "npm run version:check && npm run migration:check",
31
32
  "version:bump:check": "node scripts/check-pr-version-bump.mjs",
32
33
  "release:check": "node scripts/check-release-version.mjs",
33
34
  "migration:check": "node scripts/check-dart-decimate-migration.mjs",
@@ -44,5 +45,8 @@
44
45
  },
45
46
  "publishConfig": {
46
47
  "access": "public"
48
+ },
49
+ "devDependencies": {
50
+ "fallow": "3.2.0"
47
51
  }
48
52
  }
@@ -1,10 +1,12 @@
1
+ use std::path::{Path, PathBuf};
2
+
1
3
  use super::format::{dependency_kind, display_path};
2
- use super::route_cycle::is_typed_go_router_registry_cycle;
4
+ use super::route_cycle::{ResidualCycle, TypedGoRouterCycle, decompose_typed_go_router_cycle};
3
5
  use super::{Finding, FindingAction, FindingEdge, FindingKind, Severity};
4
6
  use crate::{
5
7
  BoundaryCallViolation, BoundaryCoverageGap, BoundaryViolation, DeadCodeReport, DependencyCycle,
6
8
  InvalidPartReason, InvalidPartRelationship, PolicySeverity, PolicyViolation, ReExportCycle,
7
- UnresolvedDependency, scan::ScannedProject,
9
+ ResolvedDependency, UnresolvedDependency, scan::ScannedProject,
8
10
  };
9
11
 
10
12
  pub(super) fn add_dead_code_findings(
@@ -76,37 +78,17 @@ pub(super) fn add_cycle_findings(
76
78
  findings: &mut Vec<Finding>,
77
79
  ) {
78
80
  for cycle in cycles {
79
- let classification = cycle_classification(project, cycle);
80
- let files = cycle
81
- .files
82
- .iter()
83
- .map(|path| display_path(&project.root, path))
84
- .collect::<Vec<_>>();
85
- let path = files.first().cloned().unwrap_or_default();
86
- findings.push(Finding {
87
- rule_id: "dart-decimate/circular-dependency".to_owned(),
88
- fingerprint: None,
89
- kind: FindingKind::CircularDependency,
90
- severity: classification.severity,
91
- message: classification.message(files.len()),
92
- path: path.clone(),
93
- line: 1,
94
- column: 0,
95
- safe_to_delete: false,
96
- files,
97
- edge: None,
98
- actions: vec![
99
- FindingAction::new(classification.action, classification.description, false)
100
- .with_target_path(path.clone())
101
- .with_dart_decimate_args([
102
- "inspect",
103
- "--format",
104
- "json",
105
- "--file",
106
- path.as_str(),
107
- ]),
108
- ],
109
- });
81
+ if let Some(typed_cycle) = decompose_typed_go_router_cycle(project, cycle) {
82
+ add_typed_go_router_cycle_findings(project, &typed_cycle, findings);
83
+ } else {
84
+ push_cycle_finding(
85
+ project,
86
+ &cycle.files,
87
+ CycleClassification::error(),
88
+ None,
89
+ findings,
90
+ );
91
+ }
110
92
  }
111
93
  }
112
94
 
@@ -116,33 +98,125 @@ struct CycleClassification {
116
98
  action: &'static str,
117
99
  description: &'static str,
118
100
  route_registry: bool,
101
+ typed_route_residual: bool,
119
102
  }
120
103
 
121
104
  impl CycleClassification {
122
105
  fn message(self, file_count: usize) -> String {
123
106
  if self.route_registry {
124
107
  format!("Typed GoRouter route registry cycle spans {file_count} Dart files")
108
+ } else if self.typed_route_residual {
109
+ format!(
110
+ "Circular dependency spans {file_count} Dart files after typed GoRouter helper imports are excluded"
111
+ )
125
112
  } else {
126
113
  format!("Circular dependency spans {file_count} Dart files")
127
114
  }
128
115
  }
129
- }
130
116
 
131
- fn cycle_classification(project: &ScannedProject, cycle: &DependencyCycle) -> CycleClassification {
132
- if is_typed_go_router_registry_cycle(project, cycle) {
133
- return CycleClassification {
117
+ const fn error() -> Self {
118
+ Self {
119
+ severity: Severity::Error,
120
+ action: "break-cycle",
121
+ description: "Inspect the cycle edge; split barrels or move shared ownership before expanding imports",
122
+ route_registry: false,
123
+ typed_route_residual: false,
124
+ }
125
+ }
126
+
127
+ const fn typed_route_warning() -> Self {
128
+ Self {
134
129
  severity: Severity::Warning,
135
130
  action: "review-typed-route-cycle",
136
131
  description: "Keep typed routes if this is only the route registry to screen navigation helper cycle; split unrelated imports out of the cycle",
137
132
  route_registry: true,
138
- };
133
+ typed_route_residual: false,
134
+ }
139
135
  }
140
136
 
141
- CycleClassification {
142
- severity: Severity::Error,
143
- action: "break-cycle",
144
- description: "Inspect the cycle edge; split barrels or move shared ownership before expanding imports",
145
- route_registry: false,
137
+ const fn typed_route_residual_error() -> Self {
138
+ Self {
139
+ severity: Severity::Error,
140
+ action: "break-cycle",
141
+ description: "Inspect the non-route cycle edge after excluding typed GoRouter helper imports",
142
+ route_registry: false,
143
+ typed_route_residual: true,
144
+ }
145
+ }
146
+ }
147
+
148
+ fn add_typed_go_router_cycle_findings(
149
+ project: &ScannedProject,
150
+ typed_cycle: &TypedGoRouterCycle,
151
+ findings: &mut Vec<Finding>,
152
+ ) {
153
+ for residual in &typed_cycle.residual_cycles {
154
+ push_residual_cycle_finding(project, residual, findings);
155
+ }
156
+ push_cycle_finding(
157
+ project,
158
+ &typed_cycle.typed_route_files,
159
+ CycleClassification::typed_route_warning(),
160
+ None,
161
+ findings,
162
+ );
163
+ }
164
+
165
+ fn push_residual_cycle_finding(
166
+ project: &ScannedProject,
167
+ residual: &ResidualCycle,
168
+ findings: &mut Vec<Finding>,
169
+ ) {
170
+ push_cycle_finding(
171
+ project,
172
+ &residual.files,
173
+ CycleClassification::typed_route_residual_error(),
174
+ residual.edge.as_ref(),
175
+ findings,
176
+ );
177
+ }
178
+
179
+ fn push_cycle_finding(
180
+ project: &ScannedProject,
181
+ paths: &[PathBuf],
182
+ classification: CycleClassification,
183
+ dependency: Option<&ResolvedDependency>,
184
+ findings: &mut Vec<Finding>,
185
+ ) {
186
+ let files = paths
187
+ .iter()
188
+ .map(|path| display_path(&project.root, path))
189
+ .collect::<Vec<_>>();
190
+ let path = dependency.map_or_else(
191
+ || files.first().cloned().unwrap_or_default(),
192
+ |dependency| display_path(&project.root, &dependency.from_path),
193
+ );
194
+ findings.push(Finding {
195
+ rule_id: "dart-decimate/circular-dependency".to_owned(),
196
+ fingerprint: None,
197
+ kind: FindingKind::CircularDependency,
198
+ severity: classification.severity,
199
+ message: classification.message(files.len()),
200
+ path: path.clone(),
201
+ line: dependency.map_or(1, |dependency| dependency.location.line),
202
+ column: dependency.map_or(0, |dependency| dependency.location.column),
203
+ safe_to_delete: false,
204
+ files,
205
+ edge: dependency.map(|dependency| finding_edge(&project.root, dependency)),
206
+ actions: vec![
207
+ FindingAction::new(classification.action, classification.description, false)
208
+ .with_target_path(path.clone())
209
+ .with_dart_decimate_args(["inspect", "--format", "json", "--file", path.as_str()]),
210
+ ],
211
+ });
212
+ }
213
+
214
+ fn finding_edge(root: &Path, dependency: &ResolvedDependency) -> FindingEdge {
215
+ FindingEdge {
216
+ from: display_path(root, &dependency.from_path),
217
+ to: display_path(root, &dependency.to_path),
218
+ specifier: dependency.specifier.clone(),
219
+ kind: dependency_kind(dependency.kind),
146
220
  }
147
221
  }
148
222