From 9384f534470693b8c3bd9e5d805db0b48dbccba8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:51:34 +0200 Subject: [PATCH 01/11] Remove unused imports --- imag-ref/src/main.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index 1d3a5a13..61206ac5 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -81,8 +81,6 @@ fn add(rt: &Runtime) { } fn remove(rt: &Runtime) { - use libimagref::error::RefErrorKind; - use libimagerror::into::IntoError; use libimaginteraction::ask::ask_bool; let cmd = rt.cli().subcommand_matches("remove").unwrap(); @@ -102,10 +100,8 @@ fn remove(rt: &Runtime) { fn list(rt: &Runtime) { use std::process::exit; - use std::ops::Deref; use libimagentrylist::lister::Lister; - use libimagentrylist::listers::core::CoreLister; use libimagref::lister::RefLister; let cmd = rt.cli().subcommand_matches("list").unwrap(); From 02d0dfa08472b72fd51e6fa57a7bb414b6cdd808 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:51:42 +0200 Subject: [PATCH 02/11] Use unused result --- imag-ref/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index 61206ac5..f233bd87 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -131,6 +131,7 @@ fn list(rt: &Runtime) { .check_changed(do_check_changed) .check_changed_content(do_check_changed_content) .check_changed_permiss(do_check_changed_permiss) - .list(iter.map(|e| e.into())); + .list(iter.map(|e| e.into())) + .ok(); } From 99d34d019b1a5bc02bccbccb0a5d9d79a3300606 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:51:47 +0200 Subject: [PATCH 03/11] Deny warnings --- imag-ref/src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index f233bd87..14bd664e 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -17,6 +17,21 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +#![deny( + non_camel_case_types, + non_snake_case, + path_statements, + trivial_numeric_casts, + unstable_features, + unused_allocation, + unused_import_braces, + unused_imports, + unused_must_use, + unused_mut, + unused_qualifications, + while_true, +)] + #[macro_use] extern crate log; #[macro_use] extern crate version; extern crate semver; From 18f575ebe5a5c656bead824a21ea19ab34ca0165 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:53:29 +0200 Subject: [PATCH 04/11] Remove unused function --- libimagref/src/lister.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs index 326a764f..f85e41c9 100644 --- a/libimagref/src/lister.rs +++ b/libimagref/src/lister.rs @@ -82,20 +82,6 @@ impl Default for RefLister { } } -fn list_fn(e: &Entry) -> String { - let stored_hash = match e.get_header().read("ref.content_hash") { - Ok(Some(Value::String(s))) => s.clone(), - _ => String::from(""), - }; - - let filepath = match e.get_header().read("ref.path") { - Ok(Some(Value::String(ref s))) => s.clone(), - _ => String::from(""), - }; - - format!("Ref({} -> {})", stored_hash, filepath) -} - impl Lister for RefLister { fn list<'b, I: Iterator>>(&self, entries: I) -> Result<()> { From 47ca51b895234d9ef85af853e2c98d5b7243ad83 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:53:44 +0200 Subject: [PATCH 05/11] Remove unused variable --- libimagref/src/lister.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs index f85e41c9..534698db 100644 --- a/libimagref/src/lister.rs +++ b/libimagref/src/lister.rs @@ -190,7 +190,7 @@ fn check_changed_content(r: &Ref) -> bool { } } -fn check_changed_permiss(r: &Ref) -> bool { +fn check_changed_permiss(_: &Ref) -> bool { warn!("Permission changes tracking not supported yet."); false } From 0a069a401b7752b154fd834a09ffc32c145fdcf7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:53:52 +0200 Subject: [PATCH 06/11] Remove unused variable --- libimagref/src/reference.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 63ca6a39..113e2636 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -169,13 +169,13 @@ impl<'a> Ref<'a> { match can.to_str().map(String::from) { // UTF convert error in PathBuf::to_str(), None => Err(REK::PathUTF8Error.into_error()), - Some(can) => Ok((file, opt_conhash, opt_perm, can, path_hash)) + Some(can) => Ok((opt_conhash, opt_perm, can, path_hash)) } }) // and then we create the FileLockEntry in the Store // and return (filelockentry, content hash, permissions, canonicalized path) - .and_then(|(file, opt_conhash, opt_perm, can, path_hash)| { + .and_then(|(opt_conhash, opt_perm, can, path_hash)| { let fle = try!(store .create(ModuleEntryPath::new(path_hash)) .map_err(Box::new) From f73c407e750ab8b9af5d875e24dbd4c25ad4955d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:56:57 +0200 Subject: [PATCH 07/11] Remove unused imports --- imag-bookmark/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index b23b7211..3adfcccf 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -30,8 +30,6 @@ extern crate libimagutil; use std::process::exit; -use libimagentrytag::ui::{get_add_tags, get_remove_tags}; -use libimagentrylink::internal::Link; use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagbookmark::collection::BookmarkCollection; From 8f26d5b9c32739480563986fe6db9eed2daef393 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:57:04 +0200 Subject: [PATCH 08/11] Use unused results --- imag-bookmark/src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 3adfcccf..814d1a40 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -69,7 +69,7 @@ fn add(rt: &Runtime) { BookmarkCollection::get(rt.store(), coll) .map(|mut collection| { for url in scmd.values_of("urls").unwrap() { // enforced by clap - collection.add_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)); + collection.add_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)).ok(); } }); info!("Ready"); @@ -115,7 +115,8 @@ fn list(rt: &Runtime) { }, Err(e) => trace_error_exit(&e, 1), } - }); + }) + .ok(); info!("Ready"); } @@ -126,9 +127,10 @@ fn remove(rt: &Runtime) { BookmarkCollection::get(rt.store(), coll) .map(|mut collection| { for url in scmd.values_of("urls").unwrap() { // enforced by clap - collection.remove_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)); + collection.remove_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)).ok(); } - }); + }) + .ok(); info!("Ready"); } From 49b054aeda4f4ede53fcf30a6ab503d26584f76b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:57:22 +0200 Subject: [PATCH 09/11] Deny warnings --- imag-bookmark/src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 814d1a40..88f41f7b 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -17,6 +17,21 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +#![deny( + non_camel_case_types, + non_snake_case, + path_statements, + trivial_numeric_casts, + unstable_features, + unused_allocation, + unused_import_braces, + unused_imports, + unused_must_use, + unused_mut, + unused_qualifications, + while_true, +)] + extern crate clap; #[macro_use] extern crate log; #[macro_use] extern crate version; From 9bb21e6a190e16888ad1725ebe6f7e4978189707 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 11 Oct 2016 11:17:20 +0200 Subject: [PATCH 10/11] imag-bookmark: Rewrite add() with iterator helpers --- imag-bookmark/src/main.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 88f41f7b..dd4e20a6 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -49,7 +49,9 @@ use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagbookmark::collection::BookmarkCollection; use libimagbookmark::link::Link as BookmarkLink; -use libimagerror::trace::{trace_error, trace_error_exit}; +use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit}; +use libimagutil::info_result::*; +use libimagutil::iter::*; mod ui; @@ -82,12 +84,14 @@ fn add(rt: &Runtime) { let coll = scmd.value_of("collection").unwrap(); // enforced by clap BookmarkCollection::get(rt.store(), coll) - .map(|mut collection| { - for url in scmd.values_of("urls").unwrap() { // enforced by clap - collection.add_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)).ok(); - } - }); - info!("Ready"); + .and_then(|mut collection| { + scmd.values_of("urls") + .unwrap() // enforced by clap + .fold_defresult(|url| collection.add_link(BookmarkLink::from(url))) + }) + .map_err_trace() + .map_info_str("Ready") + .ok(); } fn collection(rt: &Runtime) { From d2b4b523c4f3905140282199afe4d75445726f12 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 11 Oct 2016 18:35:34 +0200 Subject: [PATCH 11/11] Remove unused imports --- libimagref/src/lister.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs index 534698db..94eac2a6 100644 --- a/libimagref/src/lister.rs +++ b/libimagref/src/lister.rs @@ -21,12 +21,9 @@ use std::default::Default; use std::io::stdout; use std::io::Write; -use toml::Value; - use libimagentrylist::lister::Lister; use libimagentrylist::result::Result; use libimagerror::trace::trace_error; -use libimagstore::store::Entry; use libimagstore::store::FileLockEntry; use libimagerror::into::IntoError; use libimagentrylist::error::ListErrorKind as LEK;