Skip to content

Commit

Permalink
fix(ci): Clippy Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Nov 28, 2024
1 parent 0d890fd commit 930118e
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.3.1", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.15.0", path = "misc/metrics" }
libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" }
libp2p-noise = { version = "0.45.0", path = "transports/noise" }
libp2p-noise = { version = "0.45.1", path = "transports/noise" }
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
libp2p-ping = { version = "0.45.1", path = "protocols/ping" }
libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" }
Expand All @@ -111,7 +111,7 @@ libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.44.1", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.4.1", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" }
libp2p-webtransport-websys = { version = "0.4.1", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" }

# External dependencies
Expand Down
4 changes: 4 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
- Introduce back pressure and penalize slow peers. Drop stale messages that timeout before being
delivered.
See [PR 5595](https://github.com/libp2p/rust-libp2p/pull/5595).

- Change `Behaviour::unsubscribe` and `Behaviour::report_message_validation_result`
to `bool` they don't need to be a `Result`.
See [PR 5595](https://github.com/libp2p/rust-libp2p/pull/5595).

- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.47.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl BackoffStorage {
pub(crate) fn is_backoff_with_slack(&self, topic: &TopicHash, peer: &PeerId) -> bool {
self.backoffs
.get(topic)
.map_or(false, |m| m.contains_key(peer))
.is_some_and(|m| m.contains_key(peer))
}

pub(crate) fn get_backoff_time(&self, topic: &TopicHash, peer: &PeerId) -> Option<Instant> {
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ where
let self_published = !self.config.allow_self_origin()
&& if let Some(own_id) = self.publish_config.get_own_id() {
own_id != propagation_source
&& raw_message.source.as_ref().map_or(false, |s| s == own_id)
&& raw_message.source.as_ref().is_some_and(|s| s == own_id)
} else {
self.published_message_ids.contains(msg_id)
};
Expand Down
2 changes: 2 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
See [PR 5573](https://github.com/libp2p/rust-libp2p/pull/5573).
- Add `Behavior::find_closest_local_peers()`.
See [PR 5645](https://github.com/libp2p/rust-libp2p/pull/5645).
- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.46.2

Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl PutRecordJob {
T: RecordStore,
{
if self.inner.check_ready(cx, now) {
let publish = self.next_publish.map_or(false, |t_pub| now >= t_pub);
let publish = self.next_publish.is_some_and(|t_pub| now >= t_pub);
let records = store
.records()
.filter_map(|r| {
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ where

/// Returns true if the bucket has a pending node.
pub fn has_pending(&self) -> bool {
self.bucket.pending().map_or(false, |n| !n.is_ready())
self.bucket.pending().is_some_and(|n| !n.is_ready())
}

/// Tests whether the given distance falls into this bucket.
pub fn contains(&self, d: &Distance) -> bool {
BucketIndex::new(d).map_or(false, |i| i == self.index)
BucketIndex::new(d).is_some_and(|i| i == self.index)
}

/// Generates a random distance that falls into this bucket.
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ where
// Adjust `first_connected_pos` accordingly.
match status {
NodeStatus::Connected => {
if self.first_connected_pos.map_or(false, |p| p == pos.0)
if self.first_connected_pos.is_some_and(|p| p == pos.0)
&& pos.0 == self.nodes.len()
{
// It was the last connected node.
Expand All @@ -398,7 +398,7 @@ where

/// Returns the status of the node at the given position.
pub(crate) fn status(&self, pos: Position) -> NodeStatus {
if self.first_connected_pos.map_or(false, |i| pos.0 >= i) {
if self.first_connected_pos.is_some_and(|i| pos.0 >= i) {
NodeStatus::Connected
} else {
NodeStatus::Disconnected
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Record {

/// Checks whether the record is expired w.r.t. the given `Instant`.
pub fn is_expired(&self, now: Instant) -> bool {
self.expires.map_or(false, |t| now >= t)
self.expires.is_some_and(|t| now >= t)
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ impl ProviderRecord {

/// Checks whether the provider record is expired w.r.t. the given `Instant`.
pub fn is_expired(&self, now: Instant) -> bool {
self.expires.map_or(false, |t| now >= t)
self.expires.is_some_and(|t| now >= t)
}
}

Expand Down
3 changes: 3 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

- Deprecate `void` crate.
See [PR 5676](https://github.com/libp2p/rust-libp2p/pull/5676).

- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.45.1

Expand Down
2 changes: 1 addition & 1 deletion swarm/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct PendingConnection {

impl PendingConnection {
fn is_for_same_remote_as(&self, other: PeerId) -> bool {
self.peer_id.map_or(false, |peer| peer == other)
self.peer_id == Some(other)
}

/// Aborts the connection attempt, closing the connection.
Expand Down
5 changes: 5 additions & 0 deletions transports/noise/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.45.1

- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.45.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion transports/noise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-noise"
edition = "2021"
rust-version = { workspace = true }
description = "Cryptographic handshake protocol using the noise framework."
version = "0.45.0"
version = "0.45.1"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
2 changes: 1 addition & 1 deletion transports/noise/src/io/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
.id_remote_pubkey
.ok_or_else(|| Error::AuthenticationFailed)?;

let is_valid_signature = self.dh_remote_pubkey_sig.as_ref().map_or(false, |s| {
let is_valid_signature = self.dh_remote_pubkey_sig.as_ref().is_some_and(|s| {
id_pk.verify(&[STATIC_KEY_DOMAIN.as_bytes(), pubkey.as_ref()].concat(), s)
});

Expand Down
3 changes: 3 additions & 0 deletions transports/websocket-websys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- fix: Return `None` when extracting a `/dnsaddr` address
See [PR 5613](https://github.com/libp2p/rust-libp2p/pull/5613)

- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.4.0

- Implement refactored `Transport`.
Expand Down
2 changes: 2 additions & 0 deletions transports/websocket-websys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

//! Libp2p websocket transports built on [web-sys](https://rustwasm.github.io/wasm-bindgen/web-sys/index.html).

#![allow(unexpected_cfgs)]

mod web_context;

use bytes::BytesMut;
Expand Down
5 changes: 5 additions & 0 deletions transports/webtransport-websys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.1

- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

## 0.4.0

- Implement refactored `Transport`.
Expand Down
2 changes: 1 addition & 1 deletion transports/webtransport-websys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-webtransport-websys"
edition = "2021"
rust-version = { workspace = true }
description = "WebTransport for libp2p under WASM environment"
version = "0.4.0"
version = "0.4.1"
authors = [
"Yiannis Marangos <[email protected]>",
"oblique <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions transports/webtransport-websys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Libp2p WebTransport built on [web-sys](https://rustwasm.github.io/wasm-bindgen/web-sys/index.html)

#![allow(unexpected_cfgs)]

mod bindings;
mod connection;
mod endpoint;
Expand Down
2 changes: 2 additions & 0 deletions wasm-tests/webtransport-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unexpected_cfgs)]

use futures::channel::oneshot;
use futures::{AsyncReadExt, AsyncWriteExt};
use getrandom::getrandom;
Expand Down

0 comments on commit 930118e

Please sign in to comment.