Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Fix clippy warnings around `unwrap`
cloudhead committed 1 year ago
commit f83c11674287d4f56c43daac74d7461abfc0ddde
parent 989edacd564fa658358f5ccfd08c243c5ebd8cda
15 files changed +22 -2
modified radicle/src/lib.rs
@@ -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;

modified radicle/src/node.rs
@@ -1356,6 +1356,7 @@ impl AliasStore for HashMap<NodeId, Alias> {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;
    use crate::assert_matches;
modified radicle/src/node/address/store.rs
@@ -489,6 +489,7 @@ impl sql::BindableWithIndex for AddressType {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use std::net;

modified radicle/src/node/db.rs
@@ -214,6 +214,7 @@ pub fn migrate(db: &sql::Connection) -> Result<usize, Error> {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;

modified radicle/src/node/events.rs
@@ -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()
modified radicle/src/node/notifications/store.rs
@@ -393,6 +393,7 @@ mod parse {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use radicle_git_ext::ref_format::{qualified, refname};

modified radicle/src/node/policy/store.rs
@@ -354,6 +354,7 @@ impl<T> AliasStore for Store<T> {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use crate::assert_matches;

modified radicle/src/node/refs/store.rs
@@ -173,6 +173,7 @@ impl Store for Database {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;
    use crate::git::qualified;
modified radicle/src/node/routing.rs
@@ -259,6 +259,7 @@ impl Store for Database {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use localtime::LocalTime;

modified radicle/src/profile.rs
@@ -733,6 +733,7 @@ impl Home {

#[cfg(test)]
#[cfg(not(target_os = "macos"))]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;
    use std::fs;
modified radicle/src/rad.rs
@@ -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;

modified radicle/src/serde_ext.rs
@@ -121,6 +121,7 @@ where
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;

modified radicle/src/storage.rs
@@ -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)
modified radicle/src/storage/refs.rs
@@ -462,6 +462,7 @@ pub mod canonical {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod tests {
    use crypto::test::signer::MockSigner;
    use qcheck_macros::quickcheck;
modified radicle/src/version.rs
@@ -33,6 +33,7 @@ impl<'a> Version<'a> {
}

#[cfg(test)]
+
#[allow(clippy::unwrap_used)]
mod test {
    use super::*;