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 +3 -3
- package/Cargo.toml +1 -1
- package/README.md +21 -12
- package/package.json +5 -1
- package/src/output/graph_findings.rs +117 -43
- package/src/output/route_cycle/classification.rs +862 -0
- package/src/output/route_cycle/navigation.rs +6 -1
- package/src/output/route_cycle/registry_api.rs +268 -0
- package/src/output/route_cycle.rs +28 -162
- package/src/output/types.rs +3 -3
- package/src/output.rs +2 -2
|
@@ -221,7 +221,12 @@ fn unquote_dart_string(text: &str) -> Option<String> {
|
|
|
221
221
|
.map(str::to_owned)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
fn term_identifier_shadowed_at(
|
|
224
|
+
pub(super) fn term_identifier_shadowed_at(
|
|
225
|
+
root: Node<'_>,
|
|
226
|
+
site: Node<'_>,
|
|
227
|
+
name: &str,
|
|
228
|
+
source: &str,
|
|
229
|
+
) -> bool {
|
|
225
230
|
let mut path_child = site;
|
|
226
231
|
let mut parent = site.parent();
|
|
227
232
|
while let Some(scope) = parent {
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
use std::collections::{BTreeMap, BTreeSet};
|
|
2
|
+
use std::path::{Path, PathBuf};
|
|
3
|
+
|
|
4
|
+
use crate::{
|
|
5
|
+
DartCombinator, DartCombinatorKind, DartFile, DeclarationKind, DependencyKind,
|
|
6
|
+
DependencyVisibility, MemberDeclaration, MemberKind, ResolvedDependency,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
|
10
|
+
pub(super) struct VisibleNonRouteRegistryApi {
|
|
11
|
+
pub(super) top_level_names: BTreeSet<String>,
|
|
12
|
+
pub(super) member_names: BTreeSet<String>,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl VisibleNonRouteRegistryApi {
|
|
16
|
+
pub(super) fn is_empty(&self) -> bool {
|
|
17
|
+
self.top_level_names.is_empty() && self.member_names.is_empty()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
pub(super) fn visible_non_route_registry_api(
|
|
22
|
+
dependency: &ResolvedDependency,
|
|
23
|
+
route_file: &DartFile,
|
|
24
|
+
files_by_path: &BTreeMap<PathBuf, &DartFile>,
|
|
25
|
+
dependencies: &[ResolvedDependency],
|
|
26
|
+
) -> VisibleNonRouteRegistryApi {
|
|
27
|
+
let route_classes = route_file
|
|
28
|
+
.routes
|
|
29
|
+
.iter()
|
|
30
|
+
.map(|route| route.route_class.clone())
|
|
31
|
+
.collect::<BTreeSet<_>>();
|
|
32
|
+
let navigation_member_owners = route_registry_navigation_member_owners(
|
|
33
|
+
route_file,
|
|
34
|
+
files_by_path,
|
|
35
|
+
dependencies,
|
|
36
|
+
&route_classes,
|
|
37
|
+
);
|
|
38
|
+
let mut api = VisibleNonRouteRegistryApi::default();
|
|
39
|
+
let collector = ExportApiCollector {
|
|
40
|
+
dependency,
|
|
41
|
+
files_by_path,
|
|
42
|
+
dependencies,
|
|
43
|
+
route_classes: &route_classes,
|
|
44
|
+
navigation_member_owners: &navigation_member_owners,
|
|
45
|
+
};
|
|
46
|
+
collector.collect_library(&route_file.path, &[], &mut api);
|
|
47
|
+
collector.collect_exports(&route_file.path, &[], 0, &mut api);
|
|
48
|
+
api
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
struct ExportApiCollector<'a> {
|
|
52
|
+
dependency: &'a ResolvedDependency,
|
|
53
|
+
files_by_path: &'a BTreeMap<PathBuf, &'a DartFile>,
|
|
54
|
+
dependencies: &'a [ResolvedDependency],
|
|
55
|
+
route_classes: &'a BTreeSet<String>,
|
|
56
|
+
navigation_member_owners: &'a BTreeSet<String>,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
impl ExportApiCollector<'_> {
|
|
60
|
+
fn collect_exports(
|
|
61
|
+
&self,
|
|
62
|
+
from_path: &Path,
|
|
63
|
+
chain: &[DependencyVisibility],
|
|
64
|
+
depth: usize,
|
|
65
|
+
api: &mut VisibleNonRouteRegistryApi,
|
|
66
|
+
) {
|
|
67
|
+
if depth > 8 {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for edge in self
|
|
72
|
+
.dependencies
|
|
73
|
+
.iter()
|
|
74
|
+
.filter(|edge| edge.kind == DependencyKind::Export && edge.from_path == from_path)
|
|
75
|
+
{
|
|
76
|
+
let mut next_chain = chain.to_owned();
|
|
77
|
+
next_chain.push(edge.visibility.clone());
|
|
78
|
+
self.collect_library(&edge.to_path, &next_chain, api);
|
|
79
|
+
self.collect_exports(&edge.to_path, &next_chain, depth + 1, api);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fn collect_library(
|
|
84
|
+
&self,
|
|
85
|
+
library_path: &Path,
|
|
86
|
+
chain: &[DependencyVisibility],
|
|
87
|
+
api: &mut VisibleNonRouteRegistryApi,
|
|
88
|
+
) {
|
|
89
|
+
for path in library_paths(self.dependencies, library_path) {
|
|
90
|
+
let Some(file) = self.files_by_path.get(&path) else {
|
|
91
|
+
continue;
|
|
92
|
+
};
|
|
93
|
+
api.top_level_names.extend(
|
|
94
|
+
file.declarations
|
|
95
|
+
.iter()
|
|
96
|
+
.filter(|declaration| {
|
|
97
|
+
is_non_route_registry_api_name(&declaration.name, self.route_classes)
|
|
98
|
+
&& dependency_imports_name(self.dependency, &declaration.name)
|
|
99
|
+
&& is_visible_through_export_chain(&declaration.name, chain)
|
|
100
|
+
})
|
|
101
|
+
.map(|declaration| declaration.name.clone()),
|
|
102
|
+
);
|
|
103
|
+
api.member_names.extend(
|
|
104
|
+
file.members
|
|
105
|
+
.iter()
|
|
106
|
+
.filter(|member| {
|
|
107
|
+
is_non_route_registry_api_member(member, self.navigation_member_owners)
|
|
108
|
+
&& dependency_imports_name(self.dependency, &member.owner)
|
|
109
|
+
&& is_visible_through_export_chain(&member.owner, chain)
|
|
110
|
+
})
|
|
111
|
+
.map(|member| member.name.clone()),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
fn library_paths(dependencies: &[ResolvedDependency], library_path: &Path) -> Vec<PathBuf> {
|
|
118
|
+
let mut paths = Vec::from([library_path.to_path_buf()]);
|
|
119
|
+
let mut seen = BTreeSet::from([library_path.to_path_buf()]);
|
|
120
|
+
let mut index = 0;
|
|
121
|
+
|
|
122
|
+
while let Some(path) = paths.get(index).cloned() {
|
|
123
|
+
index += 1;
|
|
124
|
+
for edge in dependencies
|
|
125
|
+
.iter()
|
|
126
|
+
.filter(|edge| edge.kind == DependencyKind::Part && edge.from_path == path)
|
|
127
|
+
{
|
|
128
|
+
if seen.insert(edge.to_path.clone()) {
|
|
129
|
+
paths.push(edge.to_path.clone());
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
paths
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fn route_registry_navigation_member_owners(
|
|
138
|
+
route_file: &DartFile,
|
|
139
|
+
files_by_path: &BTreeMap<PathBuf, &DartFile>,
|
|
140
|
+
dependencies: &[ResolvedDependency],
|
|
141
|
+
route_classes: &BTreeSet<String>,
|
|
142
|
+
) -> BTreeSet<String> {
|
|
143
|
+
let mut owners = route_classes.clone();
|
|
144
|
+
for path in library_paths(dependencies, &route_file.path) {
|
|
145
|
+
let Some(file) = files_by_path.get(&path) else {
|
|
146
|
+
continue;
|
|
147
|
+
};
|
|
148
|
+
owners.extend(file.declarations.iter().filter_map(|declaration| {
|
|
149
|
+
matches!(
|
|
150
|
+
declaration.kind,
|
|
151
|
+
DeclarationKind::Extension | DeclarationKind::Mixin
|
|
152
|
+
)
|
|
153
|
+
.then_some(declaration.name.as_str())
|
|
154
|
+
.filter(|name| generated_typed_route_navigation_owner(name, route_classes))
|
|
155
|
+
.map(str::to_owned)
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
owners
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
fn generated_typed_route_navigation_owner(name: &str, route_classes: &BTreeSet<String>) -> bool {
|
|
162
|
+
let Some(generated) = name.strip_prefix('$') else {
|
|
163
|
+
return false;
|
|
164
|
+
};
|
|
165
|
+
route_classes.iter().any(|route_class| {
|
|
166
|
+
generated == route_class
|
|
167
|
+
|| generated
|
|
168
|
+
.strip_suffix("Extension")
|
|
169
|
+
.is_some_and(|owner| owner == route_class)
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fn is_non_route_registry_api_name(name: &str, route_classes: &BTreeSet<String>) -> bool {
|
|
174
|
+
!name.starts_with('_')
|
|
175
|
+
&& !route_classes.contains(name)
|
|
176
|
+
&& !is_route_registry_infrastructure_declaration(name)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fn is_non_route_registry_api_member(
|
|
180
|
+
member: &MemberDeclaration,
|
|
181
|
+
navigation_member_owners: &BTreeSet<String>,
|
|
182
|
+
) -> bool {
|
|
183
|
+
!member.name.starts_with('_')
|
|
184
|
+
&& !member.owner.starts_with('_')
|
|
185
|
+
&& member.kind != MemberKind::Constructor
|
|
186
|
+
&& !is_route_registry_navigation_member(member, navigation_member_owners)
|
|
187
|
+
&& !is_route_registry_infrastructure_declaration(&member.owner)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
fn is_route_registry_navigation_member(
|
|
191
|
+
member: &MemberDeclaration,
|
|
192
|
+
navigation_member_owners: &BTreeSet<String>,
|
|
193
|
+
) -> bool {
|
|
194
|
+
navigation_member_owners.contains(&member.owner)
|
|
195
|
+
&& matches!(
|
|
196
|
+
member.name.as_str(),
|
|
197
|
+
"go" | "push" | "pushReplacement" | "replace" | "location"
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
fn is_route_registry_infrastructure_declaration(name: &str) -> bool {
|
|
202
|
+
matches!(
|
|
203
|
+
name,
|
|
204
|
+
"BuildContext"
|
|
205
|
+
| "ConsumerState"
|
|
206
|
+
| "CustomTransitionPage"
|
|
207
|
+
| "GoRouteData"
|
|
208
|
+
| "GoRouter"
|
|
209
|
+
| "GoRouterState"
|
|
210
|
+
| "MaterialPage"
|
|
211
|
+
| "NoTransitionPage"
|
|
212
|
+
| "Page"
|
|
213
|
+
| "ShellRouteData"
|
|
214
|
+
| "State"
|
|
215
|
+
| "StatefulWidget"
|
|
216
|
+
| "StatefulShellRouteData"
|
|
217
|
+
| "StatelessWidget"
|
|
218
|
+
| "TypedGoRoute"
|
|
219
|
+
| "TypedRelativeGoRoute"
|
|
220
|
+
| "TypedShellRoute"
|
|
221
|
+
| "TypedStatefulShellBranch"
|
|
222
|
+
| "TypedStatefulShellRoute"
|
|
223
|
+
| "Widget"
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
fn dependency_imports_name(dependency: &ResolvedDependency, name: &str) -> bool {
|
|
228
|
+
let mut show_seen = false;
|
|
229
|
+
let mut shown = false;
|
|
230
|
+
for combinator in &dependency.visibility.combinators {
|
|
231
|
+
match combinator.kind {
|
|
232
|
+
DartCombinatorKind::Show => {
|
|
233
|
+
show_seen = true;
|
|
234
|
+
if combinator.names.iter().any(|shown| shown == name) {
|
|
235
|
+
shown = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
DartCombinatorKind::Hide if combinator.names.iter().any(|hidden| hidden == name) => {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
DartCombinatorKind::Hide => {}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
!show_seen || shown
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
fn is_visible_through_export_chain(name: &str, chain: &[DependencyVisibility]) -> bool {
|
|
248
|
+
chain
|
|
249
|
+
.iter()
|
|
250
|
+
.all(|visibility| is_visible_through_combinators(name, &visibility.combinators))
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
fn is_visible_through_combinators(name: &str, combinators: &[DartCombinator]) -> bool {
|
|
254
|
+
let mut visible = true;
|
|
255
|
+
for combinator in combinators {
|
|
256
|
+
match combinator.kind {
|
|
257
|
+
DartCombinatorKind::Show => {
|
|
258
|
+
visible = combinator.names.iter().any(|shown| shown == name);
|
|
259
|
+
}
|
|
260
|
+
DartCombinatorKind::Hide => {
|
|
261
|
+
if combinator.names.iter().any(|hidden| hidden == name) {
|
|
262
|
+
visible = false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
visible
|
|
268
|
+
}
|
|
@@ -1,148 +1,26 @@
|
|
|
1
|
-
use std::collections::
|
|
2
|
-
use std::fs;
|
|
3
|
-
use std::path::PathBuf;
|
|
1
|
+
use std::collections::BTreeSet;
|
|
4
2
|
|
|
5
3
|
use tree_sitter::Node;
|
|
6
4
|
|
|
7
|
-
use crate::{DartFile, DependencyCycle, DependencyKind, ResolvedDependency, scan::ScannedProject};
|
|
8
|
-
|
|
9
5
|
mod aliases;
|
|
6
|
+
mod classification;
|
|
10
7
|
mod navigation;
|
|
11
8
|
mod receivers;
|
|
9
|
+
mod registry_api;
|
|
12
10
|
mod state_context;
|
|
13
11
|
#[cfg(test)]
|
|
14
12
|
mod tests;
|
|
15
13
|
|
|
16
14
|
use aliases::{route_alias_receiver_node, route_alias_receiver_text, route_aliases_at};
|
|
15
|
+
pub(super) use classification::{
|
|
16
|
+
ResidualCycle, TypedGoRouterCycle, decompose_typed_go_router_cycle,
|
|
17
|
+
};
|
|
17
18
|
use navigation::{
|
|
18
19
|
navigation_receiver_accepts_route_location, route_extension_navigation_has_context_argument,
|
|
19
20
|
};
|
|
20
21
|
use receivers::route_extension_receiver_node;
|
|
21
22
|
use state_context::class_extends_state;
|
|
22
23
|
|
|
23
|
-
pub(super) fn is_typed_go_router_registry_cycle(
|
|
24
|
-
project: &ScannedProject,
|
|
25
|
-
cycle: &DependencyCycle,
|
|
26
|
-
) -> bool {
|
|
27
|
-
let cycle_files = cycle.files.iter().cloned().collect::<BTreeSet<_>>();
|
|
28
|
-
let route_files = project
|
|
29
|
-
.files
|
|
30
|
-
.iter()
|
|
31
|
-
.filter(|file| cycle_files.contains(&file.path) && is_typed_go_router_registry(file))
|
|
32
|
-
.map(|file| file.path.clone())
|
|
33
|
-
.collect::<BTreeSet<_>>();
|
|
34
|
-
if route_files.is_empty() {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let dependencies = project.graph.dependencies();
|
|
39
|
-
let internal_dependencies = dependencies
|
|
40
|
-
.iter()
|
|
41
|
-
.filter(|dependency| {
|
|
42
|
-
cycle_files.contains(&dependency.from_path)
|
|
43
|
-
&& cycle_files.contains(&dependency.to_path)
|
|
44
|
-
&& dependency.from_path != dependency.to_path
|
|
45
|
-
})
|
|
46
|
-
.collect::<Vec<_>>();
|
|
47
|
-
let files_by_path = project
|
|
48
|
-
.files
|
|
49
|
-
.iter()
|
|
50
|
-
.map(|file| (file.path.clone(), file))
|
|
51
|
-
.collect::<BTreeMap<_, _>>();
|
|
52
|
-
if internal_dependencies.is_empty()
|
|
53
|
-
|| internal_dependencies.iter().any(|dependency| {
|
|
54
|
-
!is_typed_go_router_registry_edge(dependency, &route_files, &files_by_path)
|
|
55
|
-
})
|
|
56
|
-
{
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let mut route_helpers = BTreeMap::<PathBuf, BTreeSet<PathBuf>>::new();
|
|
61
|
-
for dependency in &internal_dependencies {
|
|
62
|
-
if route_files.contains(&dependency.from_path) {
|
|
63
|
-
route_helpers
|
|
64
|
-
.entry(dependency.from_path.clone())
|
|
65
|
-
.or_default()
|
|
66
|
-
.insert(dependency.to_path.clone());
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let helper_files = cycle_files
|
|
71
|
-
.difference(&route_files)
|
|
72
|
-
.cloned()
|
|
73
|
-
.collect::<BTreeSet<_>>();
|
|
74
|
-
!helper_files.is_empty()
|
|
75
|
-
&& route_files.iter().all(|route_file| {
|
|
76
|
-
route_helpers
|
|
77
|
-
.get(route_file)
|
|
78
|
-
.is_some_and(|helpers| !helpers.is_empty())
|
|
79
|
-
})
|
|
80
|
-
&& helper_files.iter().all(|helper_file| {
|
|
81
|
-
route_files.iter().any(|route_file| {
|
|
82
|
-
route_helpers
|
|
83
|
-
.get(route_file)
|
|
84
|
-
.is_some_and(|helpers| helpers.contains(helper_file))
|
|
85
|
-
&& internal_dependencies.iter().any(|dependency| {
|
|
86
|
-
dependency.from_path == *helper_file && dependency.to_path == *route_file
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
fn is_typed_go_router_registry_edge(
|
|
93
|
-
dependency: &ResolvedDependency,
|
|
94
|
-
route_files: &BTreeSet<PathBuf>,
|
|
95
|
-
files_by_path: &BTreeMap<PathBuf, &DartFile>,
|
|
96
|
-
) -> bool {
|
|
97
|
-
if dependency.kind != DependencyKind::Import {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
let from_is_route = route_files.contains(&dependency.from_path);
|
|
101
|
-
let to_is_route = route_files.contains(&dependency.to_path);
|
|
102
|
-
if from_is_route == to_is_route {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
let route_path = if from_is_route {
|
|
106
|
-
&dependency.from_path
|
|
107
|
-
} else {
|
|
108
|
-
&dependency.to_path
|
|
109
|
-
};
|
|
110
|
-
let helper_path = if from_is_route {
|
|
111
|
-
&dependency.to_path
|
|
112
|
-
} else {
|
|
113
|
-
&dependency.from_path
|
|
114
|
-
};
|
|
115
|
-
let Some(route_file) = files_by_path.get(route_path) else {
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
let Some(helper_file) = files_by_path.get(helper_path) else {
|
|
119
|
-
return false;
|
|
120
|
-
};
|
|
121
|
-
is_typed_go_router_navigation_helper(helper_file, route_file)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
fn is_typed_go_router_navigation_helper(helper_file: &DartFile, route_file: &DartFile) -> bool {
|
|
125
|
-
let route_classes = route_file
|
|
126
|
-
.routes
|
|
127
|
-
.iter()
|
|
128
|
-
.map(|route| route.route_class.clone())
|
|
129
|
-
.collect::<BTreeSet<_>>();
|
|
130
|
-
if route_classes.is_empty() {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
let Ok(source) = fs::read_to_string(&helper_file.path) else {
|
|
134
|
-
return false;
|
|
135
|
-
};
|
|
136
|
-
let Ok(parsed) = crate::dart_parser::parse_dart_source_lossy(&helper_file.path, &source) else {
|
|
137
|
-
return false;
|
|
138
|
-
};
|
|
139
|
-
helper_has_typed_route_navigation_call(
|
|
140
|
-
parsed.tree().root_node(),
|
|
141
|
-
parsed.source(),
|
|
142
|
-
&route_classes,
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
24
|
fn helper_has_typed_route_navigation_call(
|
|
147
25
|
root: Node<'_>,
|
|
148
26
|
source: &str,
|
|
@@ -347,6 +225,16 @@ fn route_location_expression(
|
|
|
347
225
|
route_classes: &BTreeSet<String>,
|
|
348
226
|
source: &str,
|
|
349
227
|
) -> bool {
|
|
228
|
+
route_location_expression_member(node, root, site, route_classes, source).is_some()
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fn route_location_expression_member<'tree>(
|
|
232
|
+
node: Node<'tree>,
|
|
233
|
+
root: Node<'tree>,
|
|
234
|
+
site: Node<'tree>,
|
|
235
|
+
route_classes: &BTreeSet<String>,
|
|
236
|
+
source: &str,
|
|
237
|
+
) -> Option<Node<'tree>> {
|
|
350
238
|
route_location_member(
|
|
351
239
|
unwrap_expression_node(node),
|
|
352
240
|
root,
|
|
@@ -373,34 +261,31 @@ fn unwrap_expression_node(mut node: Node<'_>) -> Node<'_> {
|
|
|
373
261
|
}
|
|
374
262
|
}
|
|
375
263
|
|
|
376
|
-
fn route_location_member(
|
|
377
|
-
node: Node<'
|
|
378
|
-
root: Node<'
|
|
379
|
-
site: Node<'
|
|
264
|
+
fn route_location_member<'tree>(
|
|
265
|
+
node: Node<'tree>,
|
|
266
|
+
root: Node<'tree>,
|
|
267
|
+
site: Node<'tree>,
|
|
380
268
|
route_classes: &BTreeSet<String>,
|
|
381
269
|
source: &str,
|
|
382
|
-
) ->
|
|
270
|
+
) -> Option<Node<'tree>> {
|
|
383
271
|
if !matches!(
|
|
384
272
|
node.kind(),
|
|
385
273
|
"member_expression" | "null_aware_member_expression" | "assignable_expression"
|
|
386
274
|
) {
|
|
387
|
-
return
|
|
275
|
+
return None;
|
|
388
276
|
}
|
|
389
|
-
let
|
|
390
|
-
return false;
|
|
391
|
-
};
|
|
277
|
+
let property = node.child_by_field_name("property")?;
|
|
392
278
|
if property.utf8_text(source.as_bytes()).ok() != Some("location") {
|
|
393
|
-
return
|
|
279
|
+
return None;
|
|
394
280
|
}
|
|
395
|
-
let
|
|
396
|
-
|
|
397
|
-
};
|
|
398
|
-
route_constructor_receiver(root, object, route_classes, source)
|
|
281
|
+
let object = node.child_by_field_name("object")?;
|
|
282
|
+
(route_constructor_receiver(root, object, route_classes, source)
|
|
399
283
|
|| route_alias_receiver_node(
|
|
400
284
|
object,
|
|
401
285
|
&route_aliases_at(root, site, route_classes, source),
|
|
402
286
|
source,
|
|
403
|
-
)
|
|
287
|
+
))
|
|
288
|
+
.then_some(node)
|
|
404
289
|
}
|
|
405
290
|
|
|
406
291
|
pub(super) fn route_constructor_receiver(
|
|
@@ -671,25 +556,6 @@ fn strip_method_type_arguments(name: &str) -> &str {
|
|
|
671
556
|
}
|
|
672
557
|
}
|
|
673
558
|
|
|
674
|
-
fn is_typed_go_router_registry(file: &DartFile) -> bool {
|
|
675
|
-
if file.routes.is_empty()
|
|
676
|
-
&& !file.references.iter().any(|reference| {
|
|
677
|
-
matches!(
|
|
678
|
-
reference.name.as_str(),
|
|
679
|
-
"TypedGoRoute"
|
|
680
|
-
| "TypedRelativeGoRoute"
|
|
681
|
-
| "TypedShellRoute"
|
|
682
|
-
| "TypedStatefulShellRoute"
|
|
683
|
-
| "TypedStatefulShellBranch"
|
|
684
|
-
)
|
|
685
|
-
})
|
|
686
|
-
{
|
|
687
|
-
return false;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
file.parts.iter().any(|part| part.uri.ends_with(".g.dart"))
|
|
691
|
-
}
|
|
692
|
-
|
|
693
559
|
fn direct_named_child<'tree>(node: Node<'tree>, kind: &str) -> Option<Node<'tree>> {
|
|
694
560
|
let mut cursor = node.walk();
|
|
695
561
|
node.named_children(&mut cursor)
|
package/src/output/types.rs
CHANGED
|
@@ -279,9 +279,9 @@ pub struct ReportSummary {
|
|
|
279
279
|
pub attack_surface: usize,
|
|
280
280
|
/// Missing requested entry points.
|
|
281
281
|
pub missing_entry_points: usize,
|
|
282
|
-
/// Circular dependency
|
|
282
|
+
/// Circular dependency findings after policy classification.
|
|
283
283
|
pub cycles: usize,
|
|
284
|
-
/// Export-only circular dependency
|
|
284
|
+
/// Export-only circular dependency findings after policy classification.
|
|
285
285
|
pub re_export_cycles: usize,
|
|
286
286
|
/// Architecture boundary violations.
|
|
287
287
|
pub boundary_violations: usize,
|
|
@@ -367,7 +367,7 @@ pub enum FindingKind {
|
|
|
367
367
|
MissingContextMountedAfterAwait,
|
|
368
368
|
/// Missing entry point.
|
|
369
369
|
MissingEntryPoint,
|
|
370
|
-
///
|
|
370
|
+
/// Circular dependency finding after graph policy classification.
|
|
371
371
|
CircularDependency,
|
|
372
372
|
/// Strongly connected component composed only of export edges.
|
|
373
373
|
ReExportCycle,
|
package/src/output.rs
CHANGED
|
@@ -523,8 +523,8 @@ fn apply_graph_policy_summary(
|
|
|
523
523
|
.dead_code
|
|
524
524
|
.as_ref()
|
|
525
525
|
.map_or(0, |dead_code| dead_code.missing_entry_points.len());
|
|
526
|
-
summary.cycles =
|
|
527
|
-
summary.re_export_cycles =
|
|
526
|
+
summary.cycles = kind_count(findings, FindingKind::CircularDependency);
|
|
527
|
+
summary.re_export_cycles = kind_count(findings, FindingKind::ReExportCycle);
|
|
528
528
|
summary.boundary_violations = results.boundary_violations.len();
|
|
529
529
|
summary.boundary_coverage = kind_count(findings, FindingKind::BoundaryCoverage);
|
|
530
530
|
summary.boundary_call_violations = kind_count(findings, FindingKind::BoundaryCallViolation);
|