dart-decimate 0.0.39 → 0.0.41
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 +27 -28
- package/Cargo.toml +3 -3
- package/README.md +6 -2
- package/package.json +2 -2
- package/src/baseline.rs +7 -7
- package/src/ci_template.rs +6 -6
- package/src/cli/coverage_run.rs +12 -12
- package/src/cli/dupes_args.rs +16 -16
- package/src/cli/health_args.rs +28 -28
- package/src/cli/request_args.rs +4 -4
- package/src/cli.rs +4 -4
- package/src/dart_parser.rs +707 -31
- package/src/extract/members.rs +4 -4
- package/src/extract/primary_constructors.rs +5 -5
- package/src/extract/references.rs +8 -8
- package/src/extract/routes.rs +38 -40
- package/src/extract/signatures.rs +8 -8
- package/src/extract/strings.rs +2 -3
- package/src/extract/tests.rs +71 -0
- package/src/extract.rs +8 -8
- package/src/graph/parts.rs +5 -6
- package/src/graph.rs +24 -25
- package/src/health/runtime_coverage.rs +5 -5
- package/src/output/next_steps.rs +4 -4
- package/src/output/security_sarif.rs +10 -10
- package/src/output/suppressions.rs +12 -12
- package/src/package_map.rs +18 -20
- package/src/security/detect/weak_randomness.rs +3 -5
- package/src/security/detect.rs +18 -17
- package/src/widgets/patterns.rs +2 -0
- package/src/widgets/tests.rs +28 -5
- package/src/widgets/top_level.rs +2 -0
- package/src/widgets/unrendered.rs +8 -8
package/src/widgets/tests.rs
CHANGED
|
@@ -1346,8 +1346,13 @@ String prefixedShadowHelper(PrefixedInheritedShadowWidget widget) {
|
|
|
1346
1346
|
#[test]
|
|
1347
1347
|
fn object_pattern_helpers_accept_prefixed_flutter_framework_superclasses()
|
|
1348
1348
|
-> Result<(), Box<dyn std::error::Error>> {
|
|
1349
|
-
|
|
1350
|
-
|
|
1349
|
+
for package in [
|
|
1350
|
+
"flutter/widgets.dart",
|
|
1351
|
+
"material_ui/material_ui.dart",
|
|
1352
|
+
"cupertino_ui/cupertino_ui.dart",
|
|
1353
|
+
] {
|
|
1354
|
+
let source = r"
|
|
1355
|
+
import 'package:PACKAGE' as f;
|
|
1351
1356
|
|
|
1352
1357
|
class PrefixedFrameworkHelperWidget extends f.StatelessWidget {
|
|
1353
1358
|
const PrefixedFrameworkHelperWidget({super.key, required this.used, required this.unused});
|
|
@@ -1360,10 +1365,16 @@ String prefixedFrameworkHelper(PrefixedFrameworkHelperWidget widget) {
|
|
|
1360
1365
|
final PrefixedFrameworkHelperWidget(:used) = widget;
|
|
1361
1366
|
return used;
|
|
1362
1367
|
}
|
|
1363
|
-
"
|
|
1364
|
-
|
|
1368
|
+
"
|
|
1369
|
+
.replace("PACKAGE", package);
|
|
1370
|
+
let targets = unused_param_targets(parse_findings(&source)?.unused_params);
|
|
1365
1371
|
|
|
1366
|
-
|
|
1372
|
+
assert_eq!(
|
|
1373
|
+
targets,
|
|
1374
|
+
vec!["PrefixedFrameworkHelperWidget.unused"],
|
|
1375
|
+
"{package}"
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1367
1378
|
Ok(())
|
|
1368
1379
|
}
|
|
1369
1380
|
|
|
@@ -2010,6 +2021,18 @@ fn flags_top_level_helpers_in_screen_files() -> Result<(), Box<dyn std::error::E
|
|
|
2010
2021
|
Ok(())
|
|
2011
2022
|
}
|
|
2012
2023
|
|
|
2024
|
+
#[test]
|
|
2025
|
+
fn standalone_flutter_ui_packages_mark_ui_helpers() -> Result<(), Box<dyn std::error::Error>> {
|
|
2026
|
+
for package in ["material_ui", "cupertino_ui"] {
|
|
2027
|
+
let source = format!(
|
|
2028
|
+
"import 'package:{package}/{package}.dart';\nWidget header() => const SizedBox();\n"
|
|
2029
|
+
);
|
|
2030
|
+
let helpers = parse_findings_at("lib/helpers.dart", &source)?.top_level_functions;
|
|
2031
|
+
assert_eq!(helpers.len(), 1, "{package}");
|
|
2032
|
+
}
|
|
2033
|
+
Ok(())
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2013
2036
|
#[test]
|
|
2014
2037
|
fn does_not_flag_methods_local_functions_or_namespaces() -> Result<(), Box<dyn std::error::Error>> {
|
|
2015
2038
|
let source = r"
|
package/src/widgets/top_level.rs
CHANGED
|
@@ -96,6 +96,8 @@ fn imports_flutter_ui(root: Node<'_>, source: &str) -> bool {
|
|
|
96
96
|
.filter_map(|child| child.utf8_text(source.as_bytes()).ok())
|
|
97
97
|
.any(|text| {
|
|
98
98
|
text.contains("package:flutter/")
|
|
99
|
+
|| text.contains("package:material_ui/")
|
|
100
|
+
|| text.contains("package:cupertino_ui/")
|
|
99
101
|
|| text.contains("package:flutter_hooks/")
|
|
100
102
|
|| text.contains("package:flutter_riverpod/")
|
|
101
103
|
|| text.contains("package:hooks_riverpod/")
|
|
@@ -136,15 +136,15 @@ fn object_constructor_names(root: Node<'_>, source: &str) -> Vec<String> {
|
|
|
136
136
|
let mut constructors = Vec::new();
|
|
137
137
|
visit_named(root, &mut |node| {
|
|
138
138
|
if is_object_constructor(node) && !has_ancestor_kind(node, &["annotation"]) {
|
|
139
|
-
if let Some(constructor) = constructor_type_name(node, source)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
} else if is_arrow_body_constructor_identifier(node, source) {
|
|
145
|
-
if let Ok(constructor) = node.utf8_text(source.as_bytes()) {
|
|
146
|
-
constructors.push(constructor.to_owned());
|
|
139
|
+
if let Some(constructor) = constructor_type_name(node, source)
|
|
140
|
+
&& !constructor_name_candidates(&constructor).is_empty()
|
|
141
|
+
{
|
|
142
|
+
constructors.push(constructor);
|
|
147
143
|
}
|
|
144
|
+
} else if is_arrow_body_constructor_identifier(node, source)
|
|
145
|
+
&& let Ok(constructor) = node.utf8_text(source.as_bytes())
|
|
146
|
+
{
|
|
147
|
+
constructors.push(constructor.to_owned());
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
constructors
|