From 06a2c3ab1257d639bdc8139bc0ea7582633d8d0d Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 5 Feb 2020 15:38:17 +0100 Subject: [PATCH] Get rid of clippy warnings --- podcasts-data/src/feed.rs | 2 +- podcasts-data/src/utils.rs | 1 - podcasts-downloader/src/downloader.rs | 2 +- podcasts-downloader/src/lib.rs | 2 +- podcasts-gtk/src/app.rs | 2 +- podcasts-gtk/src/headerbar.rs | 2 +- podcasts-gtk/src/main.rs | 9 +++++---- podcasts-gtk/src/utils.rs | 8 ++++---- podcasts-gtk/src/widgets/episode.rs | 4 ++-- podcasts-gtk/src/widgets/player.rs | 12 +++++------- 10 files changed, 21 insertions(+), 23 deletions(-) diff --git a/podcasts-data/src/feed.rs b/podcasts-data/src/feed.rs index 2f4ea24..c36095b 100644 --- a/podcasts-data/src/feed.rs +++ b/podcasts-data/src/feed.rs @@ -18,7 +18,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#![cfg_attr(feature = "cargo-clippy", allow(unit_arg))] +#![allow(clippy::unit_arg)] //! Index Feeds. use futures::future::*; diff --git a/podcasts-data/src/utils.rs b/podcasts-data/src/utils.rs index aceba54..eb2ccb5 100644 --- a/podcasts-data/src/utils.rs +++ b/podcasts-data/src/utils.rs @@ -161,7 +161,6 @@ use crate::Feed; pub fn get_feed(file_path: &str, id: i32) -> Feed { use crate::feed::FeedBuilder; use rss::Channel; - use std::fs; use std::io::BufReader; // open the xml file diff --git a/podcasts-downloader/src/downloader.rs b/podcasts-downloader/src/downloader.rs index 5a2b94d..2afa636 100644 --- a/podcasts-downloader/src/downloader.rs +++ b/podcasts-downloader/src/downloader.rs @@ -153,7 +153,7 @@ fn get_ext(content: Option<&str>) -> Option { // TODO: Refactor... Somehow. /// Handles the I/O of fetching a remote file and saving into a Buffer and A /// File. -#[allow(needless_pass_by_value)] +#[allow(clippy::needless_pass_by_value)] fn save_io( file: &str, resp: &mut reqwest::Response, diff --git a/podcasts-downloader/src/lib.rs b/podcasts-downloader/src/lib.rs index d0c5cd1..e4cf156 100644 --- a/podcasts-downloader/src/lib.rs +++ b/podcasts-downloader/src/lib.rs @@ -19,7 +19,7 @@ #![recursion_limit = "1024"] #![allow(unknown_lints)] -#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))] +#![allow(clippy::blacklisted_name)] // Enable lint group collections #![warn(nonstandard_style, edition_2018, rust_2018_idioms, bad_style, unused)] // standalone lints diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index 17fbf58..9dc0e02 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -18,7 +18,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#![allow(new_without_default)] +#![allow(clippy::new_without_default)] use glib::subclass; use glib::subclass::prelude::*; diff --git a/podcasts-gtk/src/headerbar.rs b/podcasts-gtk/src/headerbar.rs index b8ca776..3445082 100644 --- a/podcasts-gtk/src/headerbar.rs +++ b/podcasts-gtk/src/headerbar.rs @@ -249,7 +249,7 @@ impl Header { .connect_activate(clone!(weak, sender => move |_| { weak.upgrade().map(|h| { if h.add.add.get_sensitive() { - h.add.on_add_clicked(&sender); + h.add.on_add_clicked(&sender).unwrap(); } }); })); diff --git a/podcasts-gtk/src/main.rs b/podcasts-gtk/src/main.rs index f802e48..00bcbf6 100644 --- a/podcasts-gtk/src/main.rs +++ b/podcasts-gtk/src/main.rs @@ -17,11 +17,12 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#![cfg_attr( - feature = "cargo-clippy", - allow(clone_on_ref_ptr, blacklisted_name, match_same_arms,) +#![allow( + clippy::clone_on_ref_ptr, + clippy::blacklisted_name, + clippy::match_same_arms, + unknown_lints )] -#![allow(unknown_lints)] // Enable lint group collections #![warn(nonstandard_style, edition_2018, rust_2018_idioms, bad_style, unused)] // standalone lints diff --git a/podcasts-gtk/src/utils.rs b/podcasts-gtk/src/utils.rs index bb1d2d7..c1b82c7 100644 --- a/podcasts-gtk/src/utils.rs +++ b/podcasts-gtk/src/utils.rs @@ -17,7 +17,7 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] +#![allow(clippy::type_complexity)] use gdk_pixbuf::{Object, Pixbuf}; use glib::{self, object::WeakRef}; @@ -115,7 +115,7 @@ pub(crate) fn lazy_load( /// This is a more flexible version of `lazy_load` with less constrains. /// If you just want to lazy add `widgets` to a `container` check if /// `lazy_load` fits your needs first. -#[cfg_attr(feature = "cargo-clippy", allow(redundant_closure))] +#[allow(clippy::redundant_closure)] pub(crate) fn lazy_load_full(data: T, mut func: F, finish_callback: U) where T: IntoIterator + 'static, @@ -137,7 +137,7 @@ where // Kudos to Julian Sparber // https://blogs.gnome.org/jsparber/2018/04/29/animate-a-scrolledwindow/ -#[cfg_attr(feature = "cargo-clippy", allow(float_cmp))] +#[allow(clippy::float_cmp)] pub(crate) fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) { if let Some(adj) = view.get_vadjustment() { if let Some(clock) = view.get_frame_clock() { @@ -423,7 +423,7 @@ pub(crate) fn on_import_clicked(window: >k::ApplicationWindow, sender: &Sender refresh(Some(sources), sender) } else { let text = i18n("Failed to parse the imported file"); - sender.send(Action::ErrorNotification(text)).expect("Action channel blew up somehow");; + sender.send(Action::ErrorNotification(text)).expect("Action channel blew up somehow"); } })) } else { diff --git a/podcasts-gtk/src/widgets/episode.rs b/podcasts-gtk/src/widgets/episode.rs index 2b9ea22..7afdf59 100644 --- a/podcasts-gtk/src/widgets/episode.rs +++ b/podcasts-gtk/src/widgets/episode.rs @@ -522,7 +522,7 @@ fn on_play_bttn_clicked( // Setup a callback that will update the progress bar. #[inline] -#[cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))] +#[allow(clippy::if_same_then_else)] fn update_progressbar_callback( widget: &Weak, prog: &Arc>, @@ -535,7 +535,7 @@ fn update_progressbar_callback( timeout_add(100, callback); } -#[allow(if_same_then_else)] +#[allow(clippy::if_same_then_else)] fn progress_bar_helper( widget: &Weak, prog: &Arc>, diff --git a/podcasts-gtk/src/widgets/player.rs b/podcasts-gtk/src/widgets/player.rs index 11acc66..4a18d68 100644 --- a/podcasts-gtk/src/widgets/player.rs +++ b/podcasts-gtk/src/widgets/player.rs @@ -23,7 +23,6 @@ use gtk; use gtk::prelude::*; use libhandy as hdy; -use libhandy::prelude::HeaderBarExt; use libhandy::prelude::*; use gio::{File, FileExt}; @@ -244,14 +243,13 @@ impl PlayerRate { fn connect_signals(&self, widget: &Rc) { let weak = Rc::downgrade(widget); - self.radio_normal - .connect_toggled(clone!(weak => move |rate| { - weak.upgrade().map(|w| w.on_rate_changed(1.00)); - })); - self.radio125.connect_toggled(clone!(weak => move |rate| { + self.radio_normal.connect_toggled(clone!(weak => move |_| { + weak.upgrade().map(|w| w.on_rate_changed(1.00)); + })); + self.radio125.connect_toggled(clone!(weak => move |_| { weak.upgrade().map(|w| w.on_rate_changed(1.25)); })); - self.radio150.connect_toggled(clone!(weak => move |rate| { + self.radio150.connect_toggled(clone!(weak => move |_| { weak.upgrade().map(|w| w.on_rate_changed(1.50)); })); }