From d4ab195d8a140de4a388de12c8a879432a192882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Wed, 7 Feb 2024 16:51:47 +0100 Subject: [PATCH] cargo clippy fixes --- client/src/gui/components/changelog_panel.rs | 6 ++++-- client/src/gui/components/mod.rs | 4 +--- client/src/gui/components/server_browser_panel.rs | 4 +++- client/src/gui/rss_feed.rs | 13 +++++++++---- client/src/io/fs.rs | 2 +- server/src/routes/gitlab.rs | 1 - 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/client/src/gui/components/changelog_panel.rs b/client/src/gui/components/changelog_panel.rs index 391c7ff5..8029a825 100644 --- a/client/src/gui/components/changelog_panel.rs +++ b/client/src/gui/components/changelog_panel.rs @@ -143,8 +143,10 @@ impl ChangelogPanelComponent { // section done // save if not empty - if section_name.is_some() && !section_lines.is_empty() { - sections.push((section_name.unwrap(), section_lines)); + if let Some(section_name) = section_name + && !section_lines.is_empty() + { + sections.push((section_name, section_lines)); } }, // paragraph without section aka note diff --git a/client/src/gui/components/mod.rs b/client/src/gui/components/mod.rs index cf933a8f..aede76dc 100644 --- a/client/src/gui/components/mod.rs +++ b/client/src/gui/components/mod.rs @@ -15,7 +15,5 @@ pub use community_showcase_panel::{ pub use game_panel::{GamePanelComponent, GamePanelMessage}; pub use logo_panel::LogoPanelComponent; pub use news_panel::{NewsPanelComponent, NewsPanelMessage}; -pub use server_browser_panel::{ - ServerBrowserPanelComponent, ServerBrowserPanelMessage, -}; +pub use server_browser_panel::{ServerBrowserPanelComponent, ServerBrowserPanelMessage}; pub use settings_panel::{SettingsPanelComponent, SettingsPanelMessage}; diff --git a/client/src/gui/components/server_browser_panel.rs b/client/src/gui/components/server_browser_panel.rs index 1e124cb1..5280ab38 100644 --- a/client/src/gui/components/server_browser_panel.rs +++ b/client/src/gui/components/server_browser_panel.rs @@ -303,7 +303,9 @@ impl ServerBrowserPanelComponent { ) .padding(0); - let row_style = if let Some(selected_index) = self.selected_index && selected_index == i { + let row_style = if let Some(selected_index) = self.selected_index + && selected_index == i + { ButtonStyle::ServerListEntry(ServerListEntryButtonState::Selected) } else { ButtonStyle::ServerListEntry(ServerListEntryButtonState::NotSelected) diff --git a/client/src/gui/rss_feed.rs b/client/src/gui/rss_feed.rs index 972e6dda..1b459a8d 100644 --- a/client/src/gui/rss_feed.rs +++ b/client/src/gui/rss_feed.rs @@ -250,8 +250,11 @@ impl RssPost { .lines() .take(3) .filter(|x| !x.contains("[banner]")) - .map(|x| format!("{}\n", x)) - .collect::(); + .fold(String::new(), |mut output, b| { + use std::fmt::Write; + let _ = writeln!(output, "{b}"); + output + }); strip_markdown::strip_markdown(&stripped_html) }, None => "No description found.".into(), @@ -272,10 +275,12 @@ impl From<&rss::Item> for RssPost { // If the RSS item has an enclosure (attached media), check if it's a jpg or png // and if it is store the URL against the post for display in the RSS // feed. - if let Some(enclosure) = &item.enclosure && matches!(enclosure.mime_type.as_str(), "image/jpg" | "image/png") { + if let Some(enclosure) = &item.enclosure + && matches!(enclosure.mime_type.as_str(), "image/jpg" | "image/png") + { let mut url = enclosure.url.clone(); - // If the image is hosted by the discord CDN, use its ability to provide a + // If the image is hosted by the discord CDN, use its ability to provide a // resized image to save bandwidth if url.starts_with("https://media.discordapp.net") { url = format!("{}?width=320&height=240", url); diff --git a/client/src/io/fs.rs b/client/src/io/fs.rs index db3c4da9..d90b0f22 100644 --- a/client/src/io/fs.rs +++ b/client/src/io/fs.rs @@ -67,7 +67,7 @@ pub fn log_path_file() -> (&'static Path, &'static str) { pub fn unzip(profile: &Profile) -> Result<()> { tracing::info!("Unzipping to {:?}", profile.directory()); let mut zip_file = - std::fs::File::open(&profile.directory().join(consts::DOWNLOAD_FILE))?; + std::fs::File::open(profile.directory().join(consts::DOWNLOAD_FILE))?; let mut archive = zip::ZipArchive::new(&mut zip_file)?; diff --git a/server/src/routes/gitlab.rs b/server/src/routes/gitlab.rs index 7382dfaf..a9de18e5 100644 --- a/server/src/routes/gitlab.rs +++ b/server/src/routes/gitlab.rs @@ -10,7 +10,6 @@ use std::sync::Arc; use tracing::*; #[tracing::instrument(skip(_secret, _event, metrics, payload, db))] - #[post("/", format = "json", data = "")] pub async fn post_pipeline_update( _secret: GitlabSecret,