Commit c0896019 authored by shivam37483's avatar shivam37483 😄 Committed by juga
Browse files

Move file-level lint attributes to function-level where appropriate

parent e207c24d
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
#![warn(clippy::cognitive_complexity)]
#![deny(clippy::await_holding_lock)]
#![warn(unused_imports)]
#![warn(clippy::all)]
#![warn(clippy::unnecessary_unwrap)]
#![warn(noop_method_call)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![deny(unreachable_pub)]
#![deny(clippy::await_holding_lock)]
#![deny(clippy::print_stdout)]
#![deny(clippy::print_stderr)]
#![deny(clippy::unnecessary_wraps)]
+0 −2
Original line number Diff line number Diff line
@@ -199,14 +199,12 @@ impl<R: Runtime> PartialEq for Client<R> {
impl<R: Runtime> Eq for Client<R> {}

// The implementation of PartialOrd also only compares the load value of the Client
#[allow(clippy::comparison_chain)]
impl<R: Runtime> PartialOrd for Client<R> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

#[allow(clippy::comparison_chain)]
impl<R: Runtime> Ord for Client<R> {
    fn cmp(&self, other: &Self) -> Ordering {
        let current_load_left = self.current_load.load();
+0 −5
Original line number Diff line number Diff line
#![warn(clippy::cognitive_complexity)]
#![deny(clippy::await_holding_lock)]
#![warn(unused_imports)]
#![warn(clippy::all)]
#![warn(clippy::unnecessary_unwrap)]
#![warn(noop_method_call)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![deny(unreachable_pub)]
#![deny(clippy::await_holding_lock)]
#![deny(clippy::print_stdout)]
#![deny(clippy::print_stderr)]
#![deny(clippy::unnecessary_wraps)]
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ use tokio::time;

/// Enum representing the types of metrics events that can be captured
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum MetricEvent {
    /// A circuit was successfully created
    CircuitSuccess,
@@ -66,6 +67,7 @@ pub struct Heartbeat {

impl Heartbeat {
    /// Create a new Heartbeat instance
    #[cfg(test)]
    pub fn new(interval_secs: u64) -> Arc<Self> {
        let (_, receiver) = mpsc::unbounded_channel();

@@ -188,6 +190,7 @@ impl Heartbeat {
    }

    /// Get the total circuits (successful + failed)
    #[cfg(test)]
    pub fn total_circuits(&self) -> u64 {
        self.total_success_circuits.load(Ordering::Relaxed) + self.total_failed_circuits.load(Ordering::Relaxed)
    }
+13 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@
//! We can have a field such as in_graph_but_not_in_netdir : Mutex<Vec<Arc<Node>>>
//!

#![allow(dead_code)]
use crate::error::{AssignAsExitError, NodeStartError};
use crossbeam::atomic::AtomicCell;
use erpc_scanner::work::{CompletedWork, IncompleteWork};
@@ -84,6 +83,7 @@ pub enum NodeStatus {

    /// The Node has been stopped, indicating that it was previously started and is now
    /// permanently stopped. It cannot be resumed.
    #[allow(dead_code)]
    Stopped,
}

@@ -155,6 +155,7 @@ pub struct Node {

    /// Notifier to notify when the NodeStatus changes
    /// TODO: To be used in future while adding feature of pause and resume
    #[allow(dead_code)]
    notifier_node_status: Notify,

    /// The Sender half to send the IncompleteWork produced by this Node
@@ -199,11 +200,13 @@ impl Node {
    }

    /// Get the weight of the Relay
    #[allow(dead_code)]
    pub fn get_weight(&self) -> u32 {
        self.weight.load()
    }

    /// Set the weight of the Relay
    #[allow(dead_code)]
    pub fn set_weight(&self, weight: u32) {
        self.weight.store(weight);
    }
@@ -219,22 +222,26 @@ impl Node {
    }

    /// Check if Relay **was started**
    #[allow(dead_code)]
    pub fn was_started(&self) -> bool {
        self.get_status() != NodeStatus::NotStarted
    }

    /// Check if Relay **is running**
    #[allow(dead_code)]
    pub fn is_running(&self) -> bool {
        self.get_status() == NodeStatus::Running
    }

    /// FEATURE TODO: Resume the Node
    #[allow(dead_code)]
    pub fn resume(&self) {
        self.set_status(NodeStatus::Running);
        // TODO: Add a guard for not resuming a Stopped and NotStarted and already running
    }

    /// FEATURE TODO : Pause the Node
    #[allow(dead_code)]
    pub fn pause(&self) {
        self.set_status(NodeStatus::Paused);
        // TODO: Add a guard for not pausing a Stopped and NotStarted and already paused
@@ -354,6 +361,7 @@ impl Node {
    }

    // This relay is the second hop
    #[allow(dead_code)]
    async fn add_onionperf_two_hop_succesful_circuit(&self) {}
    /// Acquires locks for both `acting_as_exit` and `acting_as_guard` in a loop until both locks are acquired.
    ///
@@ -454,6 +462,7 @@ impl Node {
    //
    // We simply move relays in to_be_used_as_exit to already_used_as_exit in that case, we do
    // nothing else
    #[allow(dead_code)]
    pub async fn submit_onion_perf_completed_work(&self, completed_work: CompletedWork) {
        if completed_work.source_relay == self.fingerprint {
            let mut _to_be_used_as_exit = self.to_be_used_as_exit.write().await;
@@ -467,12 +476,14 @@ impl Node {
    }

    // Gives no of relays present in to_be_used_as_exit currently
    #[cfg(test)]
    pub async fn no_of_relays_in_to_be_used_as_exit(&self) -> usize {
        let to_be_used_as_exit = self.to_be_used_as_exit.read().await;
        to_be_used_as_exit.len()
    }

    // Check if to_be_used_as_exit contains a specified Relay
    #[cfg(test)]
    pub async fn to_be_used_as_exit_contains(&self, relay: Arc<Node>) -> bool {
        let to_be_used_as_exit = self.to_be_used_as_exit.read().await;
        to_be_used_as_exit.contains(&relay)
@@ -493,6 +504,7 @@ impl Node {
    ///
    // TODO: Understand if we really need to push it to the last or at what position,
    // do we have to filter the to_be_used_as_exit vector
    #[allow(dead_code)]
    pub async fn add_a_node_in_to_be_used_as_exit(&self, node: Arc<Self>) {
        let mut to_be_used_as_exit = self.to_be_used_as_exit.write().await;

Loading