Remove warnings from build and satisfied clippy (#1288)

* Prefixed unused functions with underscore

* Applied clippy lints

* Fixed some warnings and removed some `allow` statements
This commit is contained in:
Prikshit Gautam
2023-06-07 14:46:47 +05:30
committed by Dennis Kobert
parent 9b4bc566eb
commit f933ece04d
33 changed files with 54 additions and 60 deletions

View File

@@ -168,8 +168,8 @@ impl NodeGraphMessageHandler {
fn collect_nested_addresses(&mut self, document: &Document, responses: &mut VecDeque<Message>) {
// // Build path list
let mut path = vec![];
if let Some(layer) = self.layer_path.as_ref().and_then(|path| document.layer(&path).ok()) {
path.push(format!("Layer: {}", layer.name.as_ref().map(|name| name.as_str()).unwrap_or("Untitled Layer")));
if let Some(layer) = self.layer_path.as_ref().and_then(|path| document.layer(path).ok()) {
path.push(format!("Layer: {}", layer.name.as_deref().unwrap_or("Untitled Layer")));
} else {
path.push("Document Network".to_string());
}

View File

@@ -1,3 +1,5 @@
#![allow(clippy::too_many_arguments)]
use super::document_node_types::NodePropertiesContext;
use super::FrontendGraphDataType;
use crate::messages::layout::utility_types::widget_prelude::*;
@@ -699,7 +701,7 @@ pub fn brightness_contrast_properties(document_node: &DocumentNode, node_id: Nod
]
}
pub fn blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
pub fn _blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let radius = number_widget(document_node, node_id, 1, "Radius", NumberInput::default().min(0.).max(20.).int(), true);
let sigma = number_widget(document_node, node_id, 2, "Sigma", NumberInput::default().min(0.).max(10000.), true);
@@ -869,7 +871,7 @@ pub fn adjust_selective_color_properties(document_node: &DocumentNode, node_id:
}
#[cfg(feature = "gpu")]
pub fn gpu_map_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
pub fn _gpu_map_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let map = text_widget(document_node, node_id, 1, "Map", true);
vec![LayoutGroup::Row { widgets: map }]

View File

@@ -27,10 +27,10 @@ pub fn new_custom_layer(network: NodeNetwork, layer_path: Vec<LayerId>, response
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
}
pub fn set_manipulator_mirror_angle(manipulator_groups: &Vec<ManipulatorGroup<ManipulatorGroupId>>, layer_path: &Vec<u64>, mirror_angle: bool, responses: &mut VecDeque<Message>) {
pub fn set_manipulator_mirror_angle(manipulator_groups: &Vec<ManipulatorGroup<ManipulatorGroupId>>, layer_path: &[u64], mirror_angle: bool, responses: &mut VecDeque<Message>) {
for manipulator_group in manipulator_groups {
responses.add(GraphOperationMessage::Vector {
layer: layer_path.clone(),
layer: layer_path.to_owned(),
modification: VectorDataModification::SetManipulatorHandleMirroring {
id: manipulator_group.id,
mirror_angle,

View File

@@ -123,7 +123,7 @@ impl OverlayRenderer {
responses.add(OverlaysMessage::Rerender);
}
pub fn clear_subpath_overlays(&mut self, document: &Document, layer_path: Vec<LayerId>, responses: &mut VecDeque<Message>) {
pub fn clear_subpath_overlays(&mut self, _document: &Document, layer_path: Vec<LayerId>, responses: &mut VecDeque<Message>) {
let layer_id = layer_path.last().unwrap();
// Remove the shape outline overlays

View File

@@ -22,7 +22,7 @@ use graphene_core::Color;
use glam::DAffine2;
use serde::{Deserialize, Serialize};
const EXPOSED_BLEND_MODES: &'static [&'static [BlendMode]] = {
const EXPOSED_BLEND_MODES: &[&[BlendMode]] = {
use BlendMode::*;
&[
// Basic group

View File

@@ -231,7 +231,7 @@ impl Fsm for EllipseToolFsmState {
let fill_color = tool_options.fill.active_color();
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -293,7 +293,7 @@ fn add_polyline(data: &FreehandToolData, stroke_color: Option<Color>, fill_color
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -269,7 +269,7 @@ impl PenToolData {
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -226,7 +226,7 @@ impl Fsm for RectangleToolFsmState {
let fill_color = tool_options.fill.active_color();
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -1,3 +1,4 @@
#![allow(clippy::too_many_arguments)]
use crate::application::generate_uuid;
use crate::consts::{ROTATE_SNAP_ANGLE, SELECTION_TOLERANCE};
use crate::messages::frontend::utility_types::MouseCursorIcon;
@@ -1219,7 +1220,7 @@ fn edit_layer_deepest_manipulation(intersect: &Layer, responses: &mut VecDeque<M
}
}
fn recursive_search(document: &DocumentMessageHandler, layer_path: &Vec<u64>, incoming_layer_path_vector: &Vec<u64>) -> bool {
fn recursive_search(document: &DocumentMessageHandler, layer_path: &[u64], incoming_layer_path_vector: &Vec<u64>) -> bool {
let layer_paths = document.document_legacy.folder_children_paths(layer_path);
for path in layer_paths {
if path == *incoming_layer_path_vector || document.document_legacy.is_folder(path.clone()) && recursive_search(document, &path, incoming_layer_path_vector) {

View File

@@ -244,7 +244,7 @@ impl Fsm for ShapeToolFsmState {
let fill_color = tool_options.fill.active_color();
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -339,7 +339,7 @@ fn add_spline(tool_data: &SplineToolData, show_preview: bool, fill_color: Option
responses.add(GraphOperationMessage::FillSet {
layer: layer_path.clone(),
fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None },
fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None },
});
responses.add(GraphOperationMessage::StrokeSet {

View File

@@ -1,3 +1,5 @@
#![allow(clippy::too_many_arguments)]
use crate::application::generate_uuid;
use crate::consts::{COLOR_ACCENT, SELECTION_TOLERANCE};
use crate::messages::frontend::utility_types::MouseCursorIcon;
@@ -209,7 +211,6 @@ impl ToolTransition for TextTool {
tool_abort: Some(TextToolMessage::Abort.into()),
selection_changed: Some(TextToolMessage::DocumentIsDirty.into()),
working_color_changed: Some(TextToolMessage::WorkingColorChanged.into()),
..Default::default()
}
}
}

View File

@@ -1,3 +1,4 @@
#![allow(clippy::too_many_arguments)]
use super::common_functionality::overlay_renderer::OverlayRenderer;
use super::common_functionality::shape_editor::ShapeState;
use super::tool_messages::*;

View File

@@ -38,11 +38,6 @@ pub struct NodeRuntime {
canvas_cache: HashMap<Vec<LayerId>, SurfaceId>,
}
fn get_imaginate_index(name: &str) -> usize {
use crate::messages::portfolio::document::node_graph::IMAGINATE_NODE;
IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found"))
}
enum NodeRuntimeMessage {
GenerationRequest(GenerationRequest),
FontCacheUpdate(FontCache),