From e8f9d9fdb5fa8ac054549fff7e05c693235a7381 Mon Sep 17 00:00:00 2001 From: Benedikt Terhechte Date: Sun, 19 Dec 2021 10:17:53 +0100 Subject: [PATCH] Clippy Feedback --- postsack-web/src/database.rs | 14 ++++++++------ ps-core/src/importer.rs | 1 - ps-core/src/message_adapter.rs | 1 + ps-core/src/types/config.rs | 2 +- ps-gui/src/app.rs | 1 + ps-gui/src/app_state/import.rs | 3 --- ps-gui/src/platform/macos.rs | 1 - ps-gui/src/platform/web.rs | 2 +- ps-gui/src/textures.rs | 3 --- ps-importer/src/formats/apple_mail/mod.rs | 1 - ps-importer/src/formats/mbox/mod.rs | 1 - 11 files changed, 12 insertions(+), 18 deletions(-) diff --git a/postsack-web/src/database.rs b/postsack-web/src/database.rs index 3b12ea8..02d760f 100644 --- a/postsack-web/src/database.rs +++ b/postsack-web/src/database.rs @@ -55,8 +55,8 @@ impl Entry { fn as_row(&self, fields: &[Field]) -> QueryRow { let mut row = QueryRow::new(); for field in fields { - let value = self.value(&field); - let value_field = ValueField::new(&field, value); + let value = self.value(field); + let value_field = ValueField::new(field, value); row.insert(*field, value_field); } row @@ -66,6 +66,7 @@ impl Entry { #[derive(Debug, PartialEq, Eq)] struct HashedValue(Value); +#[allow(clippy::derive_hash_xor_eq)] impl Hash for HashedValue { fn hash(&self, state: &mut H) { match &self.0 { @@ -85,14 +86,15 @@ impl Hash for HashedValue { pub struct FakeDatabase; impl FakeDatabase { + #[allow(unused)] pub fn total_item_count() -> usize { ENTRIES.len() } fn query_normal( &self, - fields: &Vec, - filters: &Vec, + fields: &[Field], + filters: &[Filter], range: &Range, ) -> Vec { let entries = self.filtered(filters); @@ -103,7 +105,7 @@ impl FakeDatabase { result } - fn query_grouped(&self, filters: &Vec, group_by: &Field) -> Vec { + fn query_grouped(&self, filters: &[Filter], group_by: &Field) -> Vec { let mut map = HashMap::::new(); for entry in self .filtered(filters) @@ -139,7 +141,7 @@ impl FakeDatabase { result } - fn filtered<'a>(&'a self, filters: &'a Vec) -> impl Iterator { + fn filtered<'a>(&'a self, filters: &'a [Filter]) -> impl Iterator { ENTRIES.iter().filter(move |entry| { for filter in filters { // Go through all filters and escape early if they don't match diff --git a/ps-core/src/importer.rs b/ps-core/src/importer.rs index 4191cd1..811124d 100644 --- a/ps-core/src/importer.rs +++ b/ps-core/src/importer.rs @@ -1,4 +1,3 @@ -use crossbeam_channel; use eyre::Result; use std::thread::JoinHandle; diff --git a/ps-core/src/message_adapter.rs b/ps-core/src/message_adapter.rs index edc51f8..9af96d2 100644 --- a/ps-core/src/message_adapter.rs +++ b/ps-core/src/message_adapter.rs @@ -42,6 +42,7 @@ pub struct Adapter { } impl Adapter { + #[allow(clippy::new_without_default)] pub fn new() -> Self { let rw_lock = Arc::new(RwLock::default()); // FIXME: Look up this warning. It looks like the clones are necessary? diff --git a/ps-core/src/types/config.rs b/ps-core/src/types/config.rs index 7fa72b9..a59bbaa 100644 --- a/ps-core/src/types/config.rs +++ b/ps-core/src/types/config.rs @@ -200,5 +200,5 @@ fn random_filename() -> String { use rand::Rng; let number: u32 = rand::thread_rng().gen(); let filename = format!("{}.sqlite", number); - return filename; + filename } diff --git a/ps-gui/src/app.rs b/ps-gui/src/app.rs index d83b102..a50ef9c 100644 --- a/ps-gui/src/app.rs +++ b/ps-gui/src/app.rs @@ -19,6 +19,7 @@ pub struct PostsackApp { } impl PostsackApp { + #[allow(clippy::new_without_default)] #[cfg(not(target_arch = "wasm32"))] pub fn new() -> Self { let state = StateUI::new(); diff --git a/ps-gui/src/app_state/import.rs b/ps-gui/src/app_state/import.rs index 1a5ffbd..a8c8432 100644 --- a/ps-gui/src/app_state/import.rs +++ b/ps-gui/src/app_state/import.rs @@ -15,9 +15,6 @@ use ps_core::{ Config, DatabaseLike, FormatType, }; -#[cfg(not(target_arch = "wasm32"))] -use ps_importer; - pub struct ImporterUI { /// The config for this configuration config: Config, diff --git a/ps-gui/src/platform/macos.rs b/ps-gui/src/platform/macos.rs index d45d78a..8ea498a 100644 --- a/ps-gui/src/platform/macos.rs +++ b/ps-gui/src/platform/macos.rs @@ -6,7 +6,6 @@ const SYSTEM_FONT: &[u8] = include_bytes!("../fonts/mac_regular.otf"); const SYSTEM_MONO_FONT: &[u8] = include_bytes!("../fonts/mac_mono.ttc"); -use cocoa; use eframe::egui::{self, Color32, FontDefinitions, FontFamily, Stroke}; use ps_core::eyre::{bail, Result}; diff --git a/ps-gui/src/platform/web.rs b/ps-gui/src/platform/web.rs index e1299cb..515c264 100644 --- a/ps-gui/src/platform/web.rs +++ b/ps-gui/src/platform/web.rs @@ -1,7 +1,7 @@ #![cfg(target_arch = "wasm32")] use eframe::egui::{self, Color32}; -use eyre::Result; +use ps_core::eyre::Result; use super::{PlatformColors, Theme}; diff --git a/ps-gui/src/textures.rs b/ps-gui/src/textures.rs index 7cd944e..8f59bdd 100644 --- a/ps-gui/src/textures.rs +++ b/ps-gui/src/textures.rs @@ -12,9 +12,6 @@ use eframe::{self, epi}; #[cfg(target_os = "macos")] use eframe::{self, egui, epi}; -#[cfg(target_os = "macos")] -use image; - /// Pre-loaded textures pub struct Textures { #[cfg(target_os = "macos")] diff --git a/ps-importer/src/formats/apple_mail/mod.rs b/ps-importer/src/formats/apple_mail/mod.rs index 204177a..ccaacac 100644 --- a/ps-importer/src/formats/apple_mail/mod.rs +++ b/ps-importer/src/formats/apple_mail/mod.rs @@ -1,7 +1,6 @@ mod filesystem; mod mail; -use shellexpand; use std::{path::PathBuf, str::FromStr}; use super::{ImporterFormat, Result}; diff --git a/ps-importer/src/formats/mbox/mod.rs b/ps-importer/src/formats/mbox/mod.rs index ec0ffb3..84929fe 100644 --- a/ps-importer/src/formats/mbox/mod.rs +++ b/ps-importer/src/formats/mbox/mod.rs @@ -4,7 +4,6 @@ //! (or aho corasick) //! MBox parsing is also not particularly fast as it currently doesn't use parallelism -use mbox_reader; use ps_core::eyre::eyre; use ps_core::tracing; use rayon::prelude::*;