From c50e3adec66c04e61acbdb886659ed8feb54c461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 27 Dec 2022 09:14:03 +0100 Subject: [PATCH] CI: fail on clippy warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- .woodpecker.yml | 1 + src/error.rs | 18 +++++++++--------- src/handlers/presence.rs | 2 +- src/occupant.rs | 2 +- src/room.rs | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 1deb124..7329d4b 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -5,6 +5,7 @@ pipeline: image: rustlang/rust:nightly-alpine commands: - cargo fmt --check + - cargo clippy -- -Dwarnings test: image: rustlang/rust:nightly-alpine commands: diff --git a/src/error.rs b/src/error.rs index f89cf94..27246b1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -52,17 +52,17 @@ impl StdError for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::MismatchJids(jid1, jid2) => write!(f, "Mismatch Jids: {}, {}", jid1, jid2), - Error::NickAlreadyAssigned(err) => write!(f, "Nickname already assigned: {}", err), - Error::NonexistantSession(err) => write!(f, "Session doesn't exist: {:?}", err), - Error::SessionAlreadyExists(err) => write!(f, "Session already exist: {:?}", err), - Error::ParticipantNotFound(err) => write!(f, "Participant not found: {}", err), + Error::MismatchJids(jid1, jid2) => write!(f, "Mismatch Jids: {jid1}, {jid2}"), + Error::NickAlreadyAssigned(err) => write!(f, "Nickname already assigned: {err}"), + Error::NonexistantSession(err) => write!(f, "Session doesn't exist: {err:?}"), + Error::SessionAlreadyExists(err) => write!(f, "Session already exist: {err:?}"), + Error::ParticipantNotFound(err) => write!(f, "Participant not found: {err}"), Error::InvalidOriginJid => write!(f, "Invalid origin JID"), Error::InvalidDestinationJid => write!(f, "Invalid destination JID"), - Error::UnhandledIq(err) => write!(f, "Unhandled Iq: {:?}", err), - Error::Jid(err) => write!(f, "Jid Parse error: {}", err), - Error::Xmpp(err) => write!(f, "XMPP error: {}", err), - Error::Parser(err) => write!(f, "Parser error: {}", err), + Error::UnhandledIq(err) => write!(f, "Unhandled Iq: {err:?}"), + Error::Jid(err) => write!(f, "Jid Parse error: {err}"), + Error::Xmpp(err) => write!(f, "XMPP error: {err}"), + Error::Parser(err) => write!(f, "Parser error: {err}"), } } } diff --git a/src/handlers/presence.rs b/src/handlers/presence.rs index ccd401c..a25c7a6 100644 --- a/src/handlers/presence.rs +++ b/src/handlers/presence.rs @@ -94,7 +94,7 @@ async fn handle_presence_full_available( ErrorType::Cancel, DefinedCondition::Conflict, "en", - format!("Nickname conflict: {}", nick), + format!("Nickname conflict: {nick}"), ) .into()]); component.send_stanza(error).await?; diff --git a/src/occupant.rs b/src/occupant.rs index 08ad8f8..c16ac6f 100644 --- a/src/occupant.rs +++ b/src/occupant.rs @@ -39,7 +39,7 @@ impl Occupant { Ok(Occupant { real: BareJid::from(session.real().clone()), nick: participant.resource.clone(), - participant: participant, + participant, sessions: vec![session], }) } diff --git a/src/room.rs b/src/room.rs index 3a0a03c..e29f02b 100644 --- a/src/room.rs +++ b/src/room.rs @@ -286,7 +286,7 @@ impl Room { Some(BroadcastPresence::Resync) => { self.broadcast_presence( component, - &occupant, + occupant, new_session.presence, BroadcastPresence::Resync, ) @@ -297,7 +297,7 @@ impl Room { self.broadcast_presence( component, - &occupant, + occupant, new_session.presence.clone(), BroadcastPresence::Join, ) @@ -327,7 +327,7 @@ impl Room { let occupant = self.get_occupant(&session)?; self.broadcast_presence( component, - &occupant, + occupant, session.presence, BroadcastPresence::Update, )