diff --git a/hammond-data/src/feed.rs b/hammond-data/src/feed.rs index 151234d..4d135ed 100644 --- a/hammond-data/src/feed.rs +++ b/hammond-data/src/feed.rs @@ -96,7 +96,7 @@ impl Feed { // I am not sure what the optimizations are on match vs allocating None. .map(|fut| { fut.and_then(|x| match x { - IndexState::NotChanged => return Err(DataError::EpisodeNotChanged), + IndexState::NotChanged => Err(DataError::EpisodeNotChanged), _ => Ok(x), }) }) diff --git a/hammond-data/src/models/episode.rs b/hammond-data/src/models/episode.rs index 65dafaa..0f22702 100644 --- a/hammond-data/src/models/episode.rs +++ b/hammond-data/src/models/episode.rs @@ -32,7 +32,8 @@ pub struct Episode { } impl Save for Episode { - /// Helper method to easily save/"sync" current state of self to the Database. + /// Helper method to easily save/"sync" current state of self to the + /// Database. fn save(&self) -> Result { let db = connection(); let tempdb = db.get()?; @@ -224,7 +225,8 @@ impl From for EpisodeWidgetQuery { } impl Save for EpisodeWidgetQuery { - /// Helper method to easily save/"sync" current state of self to the Database. + /// Helper method to easily save/"sync" current state of self to the + /// Database. fn save(&self) -> Result { use schema::episode::dsl::*; @@ -362,7 +364,8 @@ pub struct EpisodeCleanerQuery { } impl Save for EpisodeCleanerQuery { - /// Helper method to easily save/"sync" current state of self to the Database. + /// Helper method to easily save/"sync" current state of self to the + /// Database. fn save(&self) -> Result { use schema::episode::dsl::*; diff --git a/hammond-data/src/models/mod.rs b/hammond-data/src/models/mod.rs index 10f19ed..74abd18 100644 --- a/hammond-data/src/models/mod.rs +++ b/hammond-data/src/models/mod.rs @@ -45,6 +45,7 @@ pub trait Index: Insert + Update { /// FIXME: DOCS pub trait Save { - /// Helper method to easily save/"sync" current state of a diesel model to the Database. + /// Helper method to easily save/"sync" current state of a diesel model to + /// the Database. fn save(&self) -> Result; } diff --git a/hammond-data/src/models/new_episode.rs b/hammond-data/src/models/new_episode.rs index 7cc56c7..b0ce47c 100644 --- a/hammond-data/src/models/new_episode.rs +++ b/hammond-data/src/models/new_episode.rs @@ -74,7 +74,8 @@ impl Update<(), DataError> for NewEpisode { } impl Index<(), DataError> for NewEpisode { - // Does not update the episode description if it's the only thing that has changed. + // Does not update the episode description if it's the only thing that has + // changed. fn index(&self) -> Result<(), DataError> { let exists = dbqueries::episode_exists(self.title(), self.podcast_id())?; @@ -185,7 +186,7 @@ impl NewEpisodeMinimal { pub(crate) fn new(item: &rss::Item, parent_id: i32) -> Result { if item.title().is_none() { let err = DataError::ParseEpisodeError { - reason: format!("No title specified for this Episode."), + reason: "No title specified for this Episode.".into(), parent_id, }; @@ -201,7 +202,7 @@ impl NewEpisodeMinimal { item.link().map(|s| url_cleaner(s)) } else { let err = DataError::ParseEpisodeError { - reason: format!("No url specified for the item."), + reason: "No url specified for the item.".into(), parent_id, }; diff --git a/hammond-data/src/models/new_podcast.rs b/hammond-data/src/models/new_podcast.rs index c3e9632..ce2d1c6 100644 --- a/hammond-data/src/models/new_podcast.rs +++ b/hammond-data/src/models/new_podcast.rs @@ -343,7 +343,8 @@ mod tests { #[test] // TODO: Add more test/checks // Currently there's a test that only checks new description or title. - // If you have time and want to help, implement the test for the other fields too. + // If you have time and want to help, implement the test for the other fields + // too. fn test_new_podcast_update() { truncate_db().unwrap(); let old = EXPECTED_INTERCEPTED.to_podcast().unwrap(); diff --git a/hammond-data/src/models/podcast.rs b/hammond-data/src/models/podcast.rs index 67a8065..1ecb43a 100644 --- a/hammond-data/src/models/podcast.rs +++ b/hammond-data/src/models/podcast.rs @@ -26,7 +26,8 @@ pub struct Podcast { } impl Save for Podcast { - /// Helper method to easily save/"sync" current state of self to the Database. + /// Helper method to easily save/"sync" current state of self to the + /// Database. fn save(&self) -> Result { let db = connection(); let tempdb = db.get()?; diff --git a/hammond-data/src/models/source.rs b/hammond-data/src/models/source.rs index 92ec4cb..c8d77e1 100644 --- a/hammond-data/src/models/source.rs +++ b/hammond-data/src/models/source.rs @@ -34,7 +34,8 @@ pub struct Source { } impl Save for Source { - /// Helper method to easily save/"sync" current state of self to the Database. + /// Helper method to easily save/"sync" current state of self to the + /// Database. fn save(&self) -> Result { let db = connection(); let con = db.get()?; @@ -119,7 +120,7 @@ impl Source { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("304: skipping.."), + context: "304: skipping..".into(), }; return Err(err); @@ -131,7 +132,7 @@ impl Source { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("301: Feed was moved permanently."), + context: "301: Feed was moved permanently.".into(), }; return Err(err); @@ -142,7 +143,7 @@ impl Source { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("401: Unauthorized."), + context: "401: Unauthorized.".into(), }; return Err(err); @@ -151,17 +152,25 @@ impl Source { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("403: Forbidden."), + context: "403: Forbidden.".into(), + }; + + return Err(err); + } + StatusCode::NotFound => { + let err = DataError::HttpStatusError { + url: self.uri, + status_code: code, + context: "404: Not found.".into(), }; return Err(err); } - StatusCode::NotFound => return Err(format!("404: Not found.")).map_err(From::from), StatusCode::RequestTimeout => { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("408: Request Timeout."), + context: "408: Request Timeout.".into(), }; return Err(err); @@ -170,7 +179,7 @@ impl Source { let err = DataError::HttpStatusError { url: self.uri, status_code: code, - context: format!("410: Feed was deleted.."), + context: "410: Feed was deleted..".into(), }; return Err(err); @@ -267,6 +276,7 @@ impl Source { } } +#[allow(needless_pass_by_value)] fn response_to_channel( res: Response, pool: CpuPool, diff --git a/hammond-data/src/pipeline.rs b/hammond-data/src/pipeline.rs index 893bc23..22dab65 100644 --- a/hammond-data/src/pipeline.rs +++ b/hammond-data/src/pipeline.rs @@ -67,7 +67,8 @@ pub fn pipeline>( Ok(()) } -/// Creates a tokio `reactor::Core`, a `CpuPool`, and a `hyper::Client` and runs the pipeline. +/// Creates a tokio `reactor::Core`, a `CpuPool`, and a `hyper::Client` and +/// runs the pipeline. pub fn run(sources: Vec, ignore_etags: bool) -> Result<(), DataError> { if sources.is_empty() { return Ok(()); diff --git a/hammond-data/src/utils.rs b/hammond-data/src/utils.rs index 5ce5e66..b19e76c 100644 --- a/hammond-data/src/utils.rs +++ b/hammond-data/src/utils.rs @@ -14,7 +14,8 @@ use xdg_dirs::DL_DIR; use std::fs; use std::path::Path; -/// Scan downloaded `episode` entries that might have broken `local_uri`s and set them to `None`. +/// Scan downloaded `episode` entries that might have broken `local_uri`s and +/// set them to `None`. fn download_checker() -> Result<(), DataError> { let mut episodes = dbqueries::get_downloaded_episodes()?; diff --git a/hammond-downloader/src/downloader.rs b/hammond-downloader/src/downloader.rs index 4fa9bee..4dd3892 100644 --- a/hammond-downloader/src/downloader.rs +++ b/hammond-downloader/src/downloader.rs @@ -18,7 +18,8 @@ use hammond_data::xdg_dirs::HAMMOND_CACHE; use errors::DownloadError; // TODO: Replace path that are of type &str with std::path. -// TODO: Have a convention/document absolute/relative paths, if they should end with / or not. +// TODO: Have a convention/document absolute/relative paths, if they should end +// with / or not. pub trait DownloadProgress { fn set_downloaded(&mut self, downloaded: u64); @@ -75,7 +76,8 @@ fn download_into( info!("Extension: {}", ext); // Construct a temp file to save desired content. - // It has to be a `new_in` instead of new cause rename can't move cross filesystems. + // It has to be a `new_in` instead of new cause rename can't move cross + // filesystems. let tempdir = TempDir::new_in(HAMMOND_CACHE.to_str().unwrap(), "temp_download")?; let out_file = format!("{}/temp.part", tempdir.path().to_str().unwrap(),); @@ -113,7 +115,9 @@ fn get_ext(content: Option) -> Option { // TODO: Write unit-tests. // TODO: Refactor... Somehow. -/// Handles the I/O of fetching a remote file and saving into a Buffer and A File. +/// Handles the I/O of fetching a remote file and saving into a Buffer and A +/// File. +#[allow(needless_pass_by_value)] fn save_io( file: &str, resp: &mut reqwest::Response, diff --git a/hammond-downloader/src/lib.rs b/hammond-downloader/src/lib.rs index 64276d3..37b2c40 100644 --- a/hammond-downloader/src/lib.rs +++ b/hammond-downloader/src/lib.rs @@ -1,5 +1,7 @@ #![recursion_limit = "1024"] #![deny(unused_extern_crates, unused)] +#![allow(unknown_lints)] +#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))] extern crate failure; #[macro_use] diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index e35d18e..8027d4b 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -1,3 +1,5 @@ +#![allow(new_without_default)] + use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags}; use glib; use gtk; diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs index b19d6c8..fa09b19 100644 --- a/hammond-gtk/src/main.rs +++ b/hammond-gtk/src/main.rs @@ -1,5 +1,7 @@ -#![cfg_attr(feature = "cargo-clippy", allow(clone_on_ref_ptr, needless_pass_by_value))] -// #![deny(unused_extern_crates, unused)] +#![cfg_attr(feature = "cargo-clippy", + allow(clone_on_ref_ptr, needless_pass_by_value, useless_format))] +#![allow(unknown_lints)] +#![deny(unused_extern_crates, unused)] extern crate gdk; extern crate gdk_pixbuf; diff --git a/hammond-gtk/src/stacks/show.rs b/hammond-gtk/src/stacks/show.rs index f5cbb8d..ddcf583 100644 --- a/hammond-gtk/src/stacks/show.rs +++ b/hammond-gtk/src/stacks/show.rs @@ -102,8 +102,9 @@ impl ShowStack { debug!("Name: {:?}", WidgetExt::get_name(&old)); let new = ShowWidget::new(pd, self.sender.clone()); - // Each composite ShowWidget is a gtkBox with the Podcast.id encoded in the gtk::Widget - // name. It's a hack since we can't yet subclass GObject easily. + // Each composite ShowWidget is a gtkBox with the Podcast.id encoded in the + // gtk::Widget name. It's a hack since we can't yet subclass GObject + // easily. let oldid = WidgetExt::get_name(&old); let newid = WidgetExt::get_name(&new.container); debug!("Old widget Name: {:?}\nNew widget Name: {:?}", oldid, newid); diff --git a/hammond-gtk/src/static_resource.rs b/hammond-gtk/src/static_resource.rs index b48c444..25deef7 100644 --- a/hammond-gtk/src/static_resource.rs +++ b/hammond-gtk/src/static_resource.rs @@ -2,14 +2,16 @@ use gio::{resources_register, Error, Resource}; use glib::Bytes; pub fn init() -> Result<(), Error> { - // load the gresource binary at build time and include/link it into the final binary. + // load the gresource binary at build time and include/link it into the final + // binary. let res_bytes = include_bytes!("../resources/resources.gresource"); // Create Resource it will live as long the value lives. let gbytes = Bytes::from_static(res_bytes.as_ref()); let resource = Resource::new_from_data(&gbytes)?; - // Register the resource so It wont be dropped and will continue to live in memory. + // Register the resource so It wont be dropped and will continue to live in + // memory. resources_register(&resource); Ok(()) diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 1d91f74..f2b0876 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -36,13 +36,14 @@ fn refresh_feed(source: Option>, sender: Sender) -> Result<( }); // Work around to improve the feed addition experience. - // Many times links to rss feeds are just redirects(usually to an https version). - // Sadly I haven't figured yet a nice way to follow up links redirects without getting - // to lifetime hell with futures and hyper. + // Many times links to rss feeds are just redirects(usually to an https + // version). Sadly I haven't figured yet a nice way to follow up links + // redirects without getting to lifetime hell with futures and hyper. // So the requested refresh is only of 1 feed, and the feed fails to be indexed, - // (as a 301 redict would update the source entry and exit), another refresh is run. - // For more see hammond_data/src/models/source.rs `fn request_constructor`. - // also ping me on irc if or open an issue if you want to tackle it. + // (as a 301 redict would update the source entry and exit), another refresh is + // run. For more see hammond_data/src/models/source.rs `fn + // request_constructor`. also ping me on irc if or open an issue if you + // want to tackle it. if sources.len() == 1 { let source = sources.remove(0); let id = source.id(); @@ -56,12 +57,10 @@ fn refresh_feed(source: Option>, sender: Sender) -> Result<( } } } - } else { - // This is what would normally run - if let Err(err) = pipeline::run(sources, false) { - error!("Error While trying to update the database."); - error!("Error msg: {}", err); - } + // This is what would normally run + } else if let Err(err) = pipeline::run(sources, false) { + error!("Error While trying to update the database."); + error!("Error msg: {}", err); } sender diff --git a/hammond-gtk/src/views/shows.rs b/hammond-gtk/src/views/shows.rs index d3f57f0..38dfb0d 100644 --- a/hammond-gtk/src/views/shows.rs +++ b/hammond-gtk/src/views/shows.rs @@ -56,13 +56,10 @@ impl ShowsPopulated { fn populate_flowbox(&self) -> Result<(), Error> { let podcasts = dbqueries::get_podcasts()?; - podcasts - .into_iter() - .map(|pd| Arc::new(pd)) - .for_each(|parent| { - let flowbox_child = ShowsChild::new(parent); - self.flowbox.add(&flowbox_child.child); - }); + podcasts.into_iter().map(Arc::new).for_each(|parent| { + let flowbox_child = ShowsChild::new(parent); + self.flowbox.add(&flowbox_child.child); + }); self.flowbox.show_all(); Ok(()) } diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index e34c9a6..b705e9e 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -159,7 +159,8 @@ impl EpisodeWidget { })); } - /// Show or hide the play/delete/download buttons upon widget initialization. + /// Show or hide the play/delete/download buttons upon widget + /// initialization. fn show_buttons(&self, local_uri: Option<&str>) -> Result<(), Error> { let path = local_uri.ok_or_else(|| format_err!("Path is None"))?; if Path::new(path).exists() { @@ -329,6 +330,7 @@ fn update_progressbar_callback( ); } +#[allow(if_same_then_else)] fn progress_bar_helper( prog: Arc>, episode_rowid: i32, diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index 574f515..0a5808d 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -105,7 +105,8 @@ impl ShowWidget { /// Set the descripton text. fn set_description(&self, text: &str) { - // TODO: Temporary solution until we render html urls/bold/italic probably with markup. + // TODO: Temporary solution until we render html urls/bold/italic probably with + // markup. let desc = dissolve::strip_html_tags(text).join(" "); self.description.set_text(&replace_extra_spaces(&desc)); }