refactor: reduce quality findings

This commit is contained in:
2026-06-28 15:42:12 +08:00
parent 02716d3ccd
commit 3c00659691
11 changed files with 189 additions and 135 deletions
+12 -6
View File
@@ -23,19 +23,23 @@ impl AddressablesCatalogDriver {
}
fn locator_id(json: &Value) -> Option<String> {
json.get("m_LocatorId")
let locator = json
.get("m_LocatorId")
.and_then(|value| value.as_str())
.map(ToOwned::to_owned)
.map(ToOwned::to_owned);
locator
}
fn cdn_prefixes(json: &Value) -> Vec<String> {
json.get("m_InternalIdPrefixes")
let prefixes = json
.get("m_InternalIdPrefixes")
.and_then(|value| value.as_array())
.into_iter()
.flatten()
.filter_map(|value| value.as_str())
.map(ToOwned::to_owned)
.collect()
.collect();
prefixes
}
fn resource_type_for_path(path: &str) -> ResourceType {
@@ -49,7 +53,8 @@ impl AddressablesCatalogDriver {
}
fn resources(json: &Value) -> Vec<ResourceEntry> {
json.get("m_InternalIds")
let resources = json
.get("m_InternalIds")
.and_then(|value| value.as_array())
.into_iter()
.flatten()
@@ -67,7 +72,8 @@ impl AddressablesCatalogDriver {
resource_type: Self::resource_type_for_path(path),
})
})
.collect()
.collect();
resources
}
}