From 81d50af91931c22e9437c2e5e0412cd5a03abc83 Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Sat, 14 Dec 2024 03:10:01 +0900 Subject: [PATCH] Quick linter cleanup (#396) --- common/ferrostar/src/lib.rs | 1 + common/ferrostar/src/navigation_controller/models.rs | 2 ++ common/ferrostar/src/routing_adapters/osrm/mod.rs | 10 +++++----- .../ferrostar/src/routing_adapters/osrm/utilities.rs | 12 ++++++------ common/ferrostar/src/routing_adapters/valhalla.rs | 2 +- common/ferrostar/src/simulation.rs | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/ferrostar/src/lib.rs b/common/ferrostar/src/lib.rs index 682a5edf..20b82a44 100644 --- a/common/ferrostar/src/lib.rs +++ b/common/ferrostar/src/lib.rs @@ -72,6 +72,7 @@ mod uniffi_deps { pub use uuid::Uuid; } #[cfg(feature = "uniffi")] +#[allow(clippy::wildcard_imports)] use uniffi_deps::*; #[cfg(feature = "uniffi")] diff --git a/common/ferrostar/src/navigation_controller/models.rs b/common/ferrostar/src/navigation_controller/models.rs index b7177a60..23c1d1ff 100644 --- a/common/ferrostar/src/navigation_controller/models.rs +++ b/common/ferrostar/src/navigation_controller/models.rs @@ -38,6 +38,7 @@ pub struct TripProgress { #[cfg_attr(any(feature = "wasm-bindgen", test), derive(Serialize, Deserialize))] #[cfg_attr(feature = "wasm-bindgen", derive(Tsify))] #[cfg_attr(feature = "wasm-bindgen", tsify(into_wasm_abi, from_wasm_abi))] +#[allow(clippy::large_enum_variant)] pub enum TripState { /// The navigation controller is idle and there is no active trip. Idle, @@ -83,6 +84,7 @@ pub enum TripState { Complete, } +#[allow(clippy::large_enum_variant)] pub enum StepAdvanceStatus { /// Navigation has advanced, and the information on the next step is embedded. Advanced { diff --git a/common/ferrostar/src/routing_adapters/osrm/mod.rs b/common/ferrostar/src/routing_adapters/osrm/mod.rs index f35d4e09..ab29772f 100644 --- a/common/ferrostar/src/routing_adapters/osrm/mod.rs +++ b/common/ferrostar/src/routing_adapters/osrm/mod.rs @@ -111,7 +111,7 @@ impl Route { // Index for the annotations slice let mut start_index: usize = 0; - return leg.steps.iter().map(move |step| { + leg.steps.iter().map(move |step| { let step_geometry = get_coordinates_from_geometry(&step.geometry, polyline_precision)?; @@ -157,7 +157,7 @@ impl Route { end_index as u64 } else { adjusted_end - }) + }); } adjusted_incident }) @@ -165,13 +165,13 @@ impl Route { start_index = end_index; - return RouteStep::from_osrm_and_geom( + RouteStep::from_osrm_and_geom( step, step_geometry, annotation_slice, relevant_incidents_slice, - ); - }); + ) + }) }) .collect::, _>>()?; diff --git a/common/ferrostar/src/routing_adapters/osrm/utilities.rs b/common/ferrostar/src/routing_adapters/osrm/utilities.rs index 1ce6a775..cc90e441 100644 --- a/common/ferrostar/src/routing_adapters/osrm/utilities.rs +++ b/common/ferrostar/src/routing_adapters/osrm/utilities.rs @@ -23,7 +23,7 @@ pub(crate) fn get_annotation_slice( .map(<[AnyAnnotationValue]>::to_vec) } -/// Converts the the OSRM-style annotation object consisting of separate arrays +/// Converts the OSRM-style annotation object consisting of separate arrays /// to a single vector of parsed objects (one for each coordinate pair). pub(crate) fn zip_annotations(annotation: AnyAnnotation) -> Vec { let source: HashMap> = annotation.values; @@ -31,7 +31,7 @@ pub(crate) fn zip_annotations(annotation: AnyAnnotation) -> Vec Vec>() // Collect the key-value pairs into a hashmap. }) .map(|value| AnyAnnotationValue { value }) - .collect::>(); + .collect::>() } impl From<&MapboxOsrmIncident> for Incident { @@ -54,9 +54,9 @@ impl From<&MapboxOsrmIncident> for Incident { incident_type: incident.incident_type, description: incident.description.clone(), long_description: incident.long_description.clone(), - creation_time: incident.creation_time.clone(), - start_time: incident.start_time.clone(), - end_time: incident.end_time.clone(), + creation_time: incident.creation_time, + start_time: incident.start_time, + end_time: incident.end_time, impact: incident.impact, lanes_blocked: incident.lanes_blocked.clone(), congestion: incident.congestion.clone(), diff --git a/common/ferrostar/src/routing_adapters/valhalla.rs b/common/ferrostar/src/routing_adapters/valhalla.rs index 9e95131d..8ba5dda0 100644 --- a/common/ferrostar/src/routing_adapters/valhalla.rs +++ b/common/ferrostar/src/routing_adapters/valhalla.rs @@ -128,7 +128,7 @@ impl ValhallaHttpRequestGenerator { profile: String, options_json: Option<&str>, ) -> Result { - let parsed_options = match options_json.as_deref() { + let parsed_options = match options_json { // TODO: Another error variant Some(options) => serde_json::from_str::(options)? .as_object() diff --git a/common/ferrostar/src/simulation.rs b/common/ferrostar/src/simulation.rs index 141964f3..2f32bc3e 100644 --- a/common/ferrostar/src/simulation.rs +++ b/common/ferrostar/src/simulation.rs @@ -252,7 +252,7 @@ fn add_lateral_offset( let lateral_bearing_rad = (bearing + sign * 90.0).to_radians(); // offset to approximate degrees - let offset_deg = meters / 111111.0; + let offset_deg = meters / 111_111.0; let lat_offset = offset_deg * lateral_bearing_rad.cos(); let lng_offset = offset_deg * lateral_bearing_rad.sin();