radicle: Fix clippy warnings around `unwrap`
The policy should be that we don't use unwraps outside of test code, unless we have a good reason to.
This commit is contained in:
parent
989edacd56
commit
f83c116742
|
|
@ -1,6 +1,7 @@
|
|||
#![allow(clippy::match_like_matches_macro)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::iter_nth_zero)]
|
||||
#![warn(clippy::unwrap_used)]
|
||||
|
||||
pub extern crate radicle_crypto as crypto;
|
||||
|
||||
|
|
|
|||
|
|
@ -1356,6 +1356,7 @@ impl AliasStore for HashMap<NodeId, Alias> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::assert_matches;
|
||||
|
|
|
|||
|
|
@ -489,6 +489,7 @@ impl sql::BindableWithIndex for AddressType {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use std::net;
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ pub fn migrate(db: &sql::Connection) -> Result<usize, Error> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,8 @@ impl<T: Clone> Emitter<T> {
|
|||
/// Emit event to subscribers and drop those who can't receive it.
|
||||
/// Nb. subscribers are also dropped if their channel is full.
|
||||
pub fn emit(&self, event: T) {
|
||||
// SAFETY: We deliberately propagate panics from other threads holding the lock.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.subscribers
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
@ -163,6 +165,8 @@ impl<T: Clone> Emitter<T> {
|
|||
/// Subscribe to events stream.
|
||||
pub fn subscribe(&self) -> chan::Receiver<T> {
|
||||
let (sender, receiver) = chan::bounded(MAX_PENDING_EVENTS);
|
||||
// SAFETY: We deliberately propagate panics from other threads holding the lock.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let mut subs = self.subscribers.lock().unwrap();
|
||||
subs.push(sender);
|
||||
|
||||
|
|
@ -171,11 +175,15 @@ impl<T: Clone> Emitter<T> {
|
|||
|
||||
/// Number of subscribers.
|
||||
pub fn subscriptions(&self) -> usize {
|
||||
// SAFETY: We deliberately propagate panics from other threads holding the lock.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.subscribers.lock().unwrap().len()
|
||||
}
|
||||
|
||||
/// Number of messages that have not yet been received.
|
||||
pub fn pending(&self) -> usize {
|
||||
// SAFETY: We deliberately propagate panics from other threads holding the lock.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.subscribers
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ mod parse {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use radicle_git_ext::ref_format::{qualified, refname};
|
||||
|
||||
|
|
|
|||
|
|
@ -354,6 +354,7 @@ impl<T> AliasStore for Store<T> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use crate::assert_matches;
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ impl Store for Database {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::git::qualified;
|
||||
|
|
|
|||
|
|
@ -259,6 +259,7 @@ impl Store for Database {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use localtime::LocalTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -733,6 +733,7 @@ impl Home {
|
|||
|
||||
#[cfg(test)]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![allow(clippy::let_unit_value)]
|
||||
#![warn(clippy::unwrap_used)]
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
|
@ -388,6 +387,7 @@ pub fn setup_patch_upstream<'a>(
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ where
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ pub trait WriteRepository: ReadRepository + SignRepository {
|
|||
fn set_head(&self) -> Result<SetHead, RepositoryError>;
|
||||
/// Set the repository 'rad/id' to the canonical commit, agreed by quorum.
|
||||
fn set_identity_head(&self) -> Result<Oid, RepositoryError> {
|
||||
let head = self.canonical_identity_head().unwrap();
|
||||
let head = self.canonical_identity_head()?;
|
||||
self.set_identity_head_to(head)?;
|
||||
|
||||
Ok(head)
|
||||
|
|
|
|||
|
|
@ -462,6 +462,7 @@ pub mod canonical {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use crypto::test::signer::MockSigner;
|
||||
use qcheck_macros::quickcheck;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ impl<'a> Version<'a> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue