diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9952e53..a9ad817 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -27,15 +27,24 @@ "group": "none" }, { - "label": "Clippy Fix Project", + "label": "Clippy All Targets", + "type": "cargo", + "command": "clippy", + "args": [ + "--all-targets", + "--", + "-Wclippy::pedantic" + ], + "problemMatcher": "$rustc", + "group": "build" + }, + { + "label": "Clippy Fix All Targets", "type": "cargo", "command": "clippy", "args": [ "--fix", - "--lib", - "--bin", - "shrupl", - "--allow-dirty", + "--all-targets", "--allow-staged", "--", "-Wclippy::pedantic" diff --git a/src/test_util/data.rs b/src/test_util/data.rs index 288c9e9..1aa9a66 100644 --- a/src/test_util/data.rs +++ b/src/test_util/data.rs @@ -38,7 +38,7 @@ pub const DATA_LENGTHS_BAD: [u64; 8] = [36, 12, 1, 0, 9, 24, 13, 10]; /// known good hashes of the test dataset /// -/// using BLAKE2b, 512 bit, with unpadded Base64 (standard variant) +/// using `BLAKE2b`, 512 bit, with unpadded Base64 (standard variant) pub const HASHES_STD_GOOD: [&str; 8] = [ // empty slice "eGoC90IBWQPGxv2FJVLScpEvR0DhWEdhiobiF/cfVBnSXhAxr+5YUxOJZESTTrBLkDpoWxRIt1XVb3Aa/pvizg", @@ -101,7 +101,7 @@ pub const HASHES_STD_BAD: [&str; 8] = [ // ]; pub fn data() -> impl Iterator { - DATA.iter().map(|item| *item) + DATA.iter().copied() } pub fn cases() -> impl Iterator { diff --git a/src/test_util/mock_ids.rs b/src/test_util/mock_ids.rs index 0fa6f84..9660c4e 100644 --- a/src/test_util/mock_ids.rs +++ b/src/test_util/mock_ids.rs @@ -3,10 +3,10 @@ use crate::{ sharry::{AliasID, FileID, ShareID, Uri}, }; -const VALID_URI: &'static str = "scheme://valid.uri"; -const VALID_ALIAS: &'static str = "valid-alias"; -const VALID_SHARE: &'static str = "valid-share"; -const VALID_FILE: &'static str = "valid-file"; +const VALID_URI: &str = "scheme://valid.uri"; +const VALID_ALIAS: &str = "valid-alias"; +const VALID_SHARE: &str = "valid-share"; +const VALID_FILE: &str = "valid-file"; pub trait CheckID { fn check(self) -> Result<()>; @@ -26,10 +26,10 @@ impl CheckID for (&Uri, &AliasID) { impl CheckID for &ShareID { fn check(self) -> Result<()> { - if self.to_string() != VALID_SHARE { - Err(self.into()) - } else { + if self.to_string() == VALID_SHARE { Ok(()) + } else { + Err(self.into()) } } } @@ -38,10 +38,10 @@ impl CheckID for (&ShareID, &FileID) { fn check(self) -> Result<()> { self.0.check()?; - if self.1.to_string() != VALID_FILE { - Err(self.1.into()) - } else { + if self.1.to_string() == VALID_FILE { Ok(()) + } else { + Err(self.1.into()) } } } @@ -55,36 +55,40 @@ fn make_invalid(valid: &str) -> String { impl From for Uri { fn from(value: bool) -> Self { - match value { - true => Self::from(VALID_URI.to_string()), - false => Self::from(make_invalid(VALID_URI)), + if value { + Self::from(VALID_URI.to_string()) + } else { + Self::from(make_invalid(VALID_URI)) } } } impl From for AliasID { fn from(value: bool) -> Self { - match value { - true => Self::from(VALID_ALIAS.to_string()), - false => Self::from(make_invalid(VALID_ALIAS)), + if value { + Self::from(VALID_ALIAS.to_string()) + } else { + Self::from(make_invalid(VALID_ALIAS)) } } } impl From for ShareID { fn from(value: bool) -> Self { - match value { - true => Self::from(VALID_SHARE.to_string()), - false => Self::from(make_invalid(VALID_SHARE)), + if value { + Self::from(VALID_SHARE.to_string()) + } else { + Self::from(make_invalid(VALID_SHARE)) } } } impl From for FileID { fn from(value: bool) -> Self { - match value { - true => Self::new_test(VALID_FILE), - false => Self::new_test(make_invalid(VALID_FILE)), + if value { + Self::new_test(VALID_FILE) + } else { + Self::new_test(make_invalid(VALID_FILE)) } } } diff --git a/src/test_util/mod.rs b/src/test_util/mod.rs index 0690a96..50c3fe0 100644 --- a/src/test_util/mod.rs +++ b/src/test_util/mod.rs @@ -8,6 +8,7 @@ use std::{fmt, io::Write}; use tempfile::NamedTempFile; +#[allow(clippy::needless_pass_by_value)] pub fn check_trait(actual: A, expected: E, tr: &str, ty: &str) where A: fmt::Debug + PartialEq, @@ -15,8 +16,7 @@ where { assert_eq!( actual, expected, - "`impl {tr} for {ty}` expected: {:?}, actual: {:?}", - expected, actual, + "`impl {tr} for {ty}` expected: {expected:?}, actual: {actual:?}", ); }