Loading clippy.toml 0 → 100644 +3 −0 Original line number Original line Diff line number Diff line disallowed-methods = [ { path = "std::time::SystemTime::now", reason = "prefere using SleepProvider::wallclock instead when possible" }, ] crates/arti-bench/src/main.rs +1 −0 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ // This file uses `unwrap()` a fair deal, but this is fine in test/bench code // This file uses `unwrap()` a fair deal, but this is fine in test/bench code // because it's OK if tests and benchmarks simply crash if things go wrong. // because it's OK if tests and benchmarks simply crash if things go wrong. #![allow(clippy::unwrap_used)] #![allow(clippy::unwrap_used)] #![allow(clippy::disallowed_methods)] use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result}; use arti::cfg::ArtiConfig; use arti::cfg::ArtiConfig; Loading crates/arti-client/src/status.rs +5 −1 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,10 @@ impl BootstrapStatus { /// 0 is defined as "just started"; 1 is defined as "ready to use." /// 0 is defined as "just started"; 1 is defined as "ready to use." pub fn as_frac(&self) -> f32 { pub fn as_frac(&self) -> f32 { // Coefficients chosen arbitrarily. // Coefficients chosen arbitrarily. self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85 #[allow(clippy::disallowed_methods)] let res = self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85; res } } /// Return true if the status indicates that the client is ready for /// Return true if the status indicates that the client is ready for Loading @@ -47,6 +50,7 @@ impl BootstrapStatus { /// For the purposes of this function, the client is "ready for traffic" if, /// For the purposes of this function, the client is "ready for traffic" if, /// as far as we know, we can start acting on a new client request immediately. /// as far as we know, we can start acting on a new client request immediately. pub fn ready_for_traffic(&self) -> bool { pub fn ready_for_traffic(&self) -> bool { #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let now = SystemTime::now(); self.conn_status.usable() && self.dir_status.usable_at(now) self.conn_status.usable() && self.dir_status.usable_at(now) } } Loading crates/tor-checkable/src/lib.rs +1 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,7 @@ pub trait Timebound<T>: Sized { /// Unwrap this Timebound object if it is valid now. /// Unwrap this Timebound object if it is valid now. fn check_valid_now(self) -> Result<T, Self::Error> { fn check_valid_now(self) -> Result<T, Self::Error> { #[allow(clippy::disallowed_methods)] self.check_valid_at(&time::SystemTime::now()) self.check_valid_at(&time::SystemTime::now()) } } Loading crates/tor-circmgr/src/build.rs +10 −0 Original line number Original line Diff line number Diff line Loading @@ -264,6 +264,11 @@ impl<R: Runtime, C: Buildable + Sync + Send + 'static> Builder<R, C> { Err(e) => Err(e), Err(e) => Err(e), } } } } /// Return a reference to this Builder runtime. pub(crate) fn runtime(&self) -> &R { &self.runtime } } } /// A factory object to build circuits. /// A factory object to build circuits. Loading Loading @@ -387,6 +392,11 @@ impl<R: Runtime> CircuitBuilder<R> { pub(crate) fn guardmgr(&self) -> &tor_guardmgr::GuardMgr<R> { pub(crate) fn guardmgr(&self) -> &tor_guardmgr::GuardMgr<R> { &self.guardmgr &self.guardmgr } } /// Return a reference to this builder's runtime pub(crate) fn runtime(&self) -> &R { self.builder.runtime() } } } /// Helper function: spawn a future as a background task, and run it with /// Helper function: spawn a future as a background task, and run it with Loading Loading
clippy.toml 0 → 100644 +3 −0 Original line number Original line Diff line number Diff line disallowed-methods = [ { path = "std::time::SystemTime::now", reason = "prefere using SleepProvider::wallclock instead when possible" }, ]
crates/arti-bench/src/main.rs +1 −0 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ // This file uses `unwrap()` a fair deal, but this is fine in test/bench code // This file uses `unwrap()` a fair deal, but this is fine in test/bench code // because it's OK if tests and benchmarks simply crash if things go wrong. // because it's OK if tests and benchmarks simply crash if things go wrong. #![allow(clippy::unwrap_used)] #![allow(clippy::unwrap_used)] #![allow(clippy::disallowed_methods)] use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result}; use arti::cfg::ArtiConfig; use arti::cfg::ArtiConfig; Loading
crates/arti-client/src/status.rs +5 −1 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,10 @@ impl BootstrapStatus { /// 0 is defined as "just started"; 1 is defined as "ready to use." /// 0 is defined as "just started"; 1 is defined as "ready to use." pub fn as_frac(&self) -> f32 { pub fn as_frac(&self) -> f32 { // Coefficients chosen arbitrarily. // Coefficients chosen arbitrarily. self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85 #[allow(clippy::disallowed_methods)] let res = self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85; res } } /// Return true if the status indicates that the client is ready for /// Return true if the status indicates that the client is ready for Loading @@ -47,6 +50,7 @@ impl BootstrapStatus { /// For the purposes of this function, the client is "ready for traffic" if, /// For the purposes of this function, the client is "ready for traffic" if, /// as far as we know, we can start acting on a new client request immediately. /// as far as we know, we can start acting on a new client request immediately. pub fn ready_for_traffic(&self) -> bool { pub fn ready_for_traffic(&self) -> bool { #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let now = SystemTime::now(); self.conn_status.usable() && self.dir_status.usable_at(now) self.conn_status.usable() && self.dir_status.usable_at(now) } } Loading
crates/tor-checkable/src/lib.rs +1 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,7 @@ pub trait Timebound<T>: Sized { /// Unwrap this Timebound object if it is valid now. /// Unwrap this Timebound object if it is valid now. fn check_valid_now(self) -> Result<T, Self::Error> { fn check_valid_now(self) -> Result<T, Self::Error> { #[allow(clippy::disallowed_methods)] self.check_valid_at(&time::SystemTime::now()) self.check_valid_at(&time::SystemTime::now()) } } Loading
crates/tor-circmgr/src/build.rs +10 −0 Original line number Original line Diff line number Diff line Loading @@ -264,6 +264,11 @@ impl<R: Runtime, C: Buildable + Sync + Send + 'static> Builder<R, C> { Err(e) => Err(e), Err(e) => Err(e), } } } } /// Return a reference to this Builder runtime. pub(crate) fn runtime(&self) -> &R { &self.runtime } } } /// A factory object to build circuits. /// A factory object to build circuits. Loading Loading @@ -387,6 +392,11 @@ impl<R: Runtime> CircuitBuilder<R> { pub(crate) fn guardmgr(&self) -> &tor_guardmgr::GuardMgr<R> { pub(crate) fn guardmgr(&self) -> &tor_guardmgr::GuardMgr<R> { &self.guardmgr &self.guardmgr } } /// Return a reference to this builder's runtime pub(crate) fn runtime(&self) -> &R { self.builder.runtime() } } } /// Helper function: spawn a future as a background task, and run it with /// Helper function: spawn a future as a background task, and run it with Loading