diff --git a/zaino-fetch/src/primitives/block.rs b/zaino-fetch/src/primitives/block.rs index 5a98fa1..24e06fc 100644 --- a/zaino-fetch/src/primitives/block.rs +++ b/zaino-fetch/src/primitives/block.rs @@ -66,7 +66,7 @@ impl FromHex for SerializedBlock { type Error = hex::FromHexError; fn from_hex>(hex: T) -> Result { - hex::decode(hex).map(|bytes| SerializedBlock::from(bytes)) + hex::decode(hex).map(SerializedBlock::from) } } diff --git a/zaino-nym/src/error.rs b/zaino-nym/src/error.rs index 5736a2a..fb785d1 100644 --- a/zaino-nym/src/error.rs +++ b/zaino-nym/src/error.rs @@ -39,10 +39,10 @@ impl From for tonic::Status { tonic::Status::internal(format!("Connection error: {}", e)) } NymError::EmptyMessageError => { - tonic::Status::internal(format!("Empty message received from nym mixnet")) + tonic::Status::internal("Empty message received from nym mixnet".to_string()) } NymError::EmptyRecipientTagError => { - tonic::Status::internal(format!("No AnonSenderTag received from nym mixnet")) + tonic::Status::internal("No AnonSenderTag received from nym mixnet".to_string()) } } } diff --git a/zaino-nym/src/utils.rs b/zaino-nym/src/utils.rs index 4c7c108..0631625 100644 --- a/zaino-nym/src/utils.rs +++ b/zaino-nym/src/utils.rs @@ -20,7 +20,7 @@ fn read_nym_method(data: &[u8]) -> Result<(String, &[u8]), NymError> { fn check_nym_body(data: &[u8]) -> Result<&[u8], NymError> { let mut cursor = Cursor::new(data); let body_len = CompactSize::read(&mut cursor).map_err(ParseError::Io)? as usize; - if &body_len != &data[cursor.position() as usize..].len() { + if body_len != data[cursor.position() as usize..].len() { return Err(NymError::ParseError(ParseError::InvalidData( "Incorrect request body size read.".to_string(), ))); diff --git a/zaino-serve/src/server/director.rs b/zaino-serve/src/server/director.rs index bbd9a3c..742acf7 100644 --- a/zaino-serve/src/server/director.rs +++ b/zaino-serve/src/server/director.rs @@ -79,6 +79,7 @@ pub struct Server { impl Server { /// Spawns a new Server. + #[allow(clippy::too_many_arguments)] pub async fn spawn( tcp_active: bool, tcp_ingestor_listen_addr: Option, diff --git a/zaino-serve/src/server/worker.rs b/zaino-serve/src/server/worker.rs index e1b0e81..b153d72 100644 --- a/zaino-serve/src/server/worker.rs +++ b/zaino-serve/src/server/worker.rs @@ -49,6 +49,7 @@ pub(crate) struct Worker { impl Worker { /// Creates a new queue worker. + #[allow(clippy::too_many_arguments)] pub(crate) async fn spawn( _worker_id: usize, queue: QueueReceiver, @@ -234,6 +235,7 @@ pub(crate) struct WorkerPool { impl WorkerPool { /// Creates a new worker pool containing [idle_workers] workers. + #[allow(clippy::too_many_arguments)] pub(crate) async fn spawn( max_size: u16, idle_size: u16, @@ -322,14 +324,14 @@ impl WorkerPool { self.status.statuses[worker_index].store(5); self.workers.pop(); self.status.workers.fetch_sub(1, Ordering::SeqCst); - return Ok(()); + Ok(()) } Err(e) => { self.status.statuses[worker_index].store(6); eprintln!("Worker returned error on shutdown: {}", e); // TODO: Handle the inner WorkerError. Return error. self.status.workers.fetch_sub(1, Ordering::SeqCst); - return Ok(()); + Ok(()) } }, Err(e) => { @@ -337,9 +339,9 @@ impl WorkerPool { eprintln!("Worker returned error on shutdown: {}", e); // TODO: Handle the JoinError. Return error. self.status.workers.fetch_sub(1, Ordering::SeqCst); - return Ok(()); + Ok(()) } - }; + } } } @@ -370,7 +372,7 @@ impl WorkerPool { /// Shuts down all the workers in the pool. pub(crate) async fn shutdown( &mut self, - worker_handles: &mut Vec>>>, + worker_handles: &mut [Option>>], ) { for i in (0..self.workers.len()).rev() { self.workers[i].shutdown().await; diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 2eade9b..853e32e 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -186,8 +186,11 @@ fn set_custom_drops( eprintln!("Failed to delete temporary wallet directory: {:?}.", e); } } - // Assures tests fail on secondary thread panics. - assert!(false); + // Ensures tests fail on secondary thread panics. + #[allow(clippy::assertions_on_constants)] + { + assert!(false); + } std::process::exit(0); })); @@ -208,8 +211,11 @@ fn set_custom_drops( eprintln!("Failed to delete temporary wallet directory: {:?}.", e); } } - // Assures tests fail on ctrlc exit. - assert!(false); + // Ensures tests fail on ctrlc exit. + #[allow(clippy::assertions_on_constants)] + { + assert!(false); + } std::process::exit(0); }) .expect("Error setting Ctrl-C handler"); diff --git a/zaino-wallet/src/service.rs b/zaino-wallet/src/service.rs index c2f2b1b..46fe52a 100644 --- a/zaino-wallet/src/service.rs +++ b/zaino-wallet/src/service.rs @@ -252,10 +252,10 @@ where Ok(tonic::Response::new(response)) } Err(e) => { - return Err(Status::invalid_argument(format!( + Err(Status::invalid_argument(format!( "Failed to parse nym address: {}", e - ))); + ))) } } } @@ -440,10 +440,10 @@ where Ok(tonic::Response::new(response)) } Err(e) => { - return Err(Status::invalid_argument(format!( + Err(Status::invalid_argument(format!( "Failed to parse nym address: {}", e - ))); + ))) } } } diff --git a/zainod/src/config.rs b/zainod/src/config.rs index e60d72b..d065059 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -54,12 +54,10 @@ impl IndexerConfig { "Invalid nym conf path syntax or non-UTF-8 characters in path.".to_string(), )); } - } else { - if self.nym_active { - return Err(IndexerError::ConfigError( - "NYM is active but no conf path provided.".to_string(), - )); - } + } else if self.nym_active { + return Err(IndexerError::ConfigError( + "NYM is active but no conf path provided.".to_string(), + )); } Ok(()) }