From d4c4ec3df58961a93fadd4cec0caa8936de59872 Mon Sep 17 00:00:00 2001 From: Ninjani <48680156+Ninjani@users.noreply.github.com> Date: Sun, 25 Apr 2021 15:19:15 +0200 Subject: [PATCH] style(clippy): lints --- src/gooseberry/database.rs | 12 +++--------- src/gooseberry/knowledge_base.rs | 2 +- src/gooseberry/mod.rs | 2 +- src/utils.rs | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/gooseberry/database.rs b/src/gooseberry/database.rs index 2fe1677..264bebf 100644 --- a/src/gooseberry/database.rs +++ b/src/gooseberry/database.rs @@ -81,13 +81,7 @@ impl Gooseberry { ) -> color_eyre::Result<()> { let annotation_key = annotation.id.as_bytes(); annotation_batch.insert(annotation_key, utils::join_ids(&annotation.tags)?); - if annotation.tags.is_empty() - || annotation - .tags - .iter() - .find(|t| !t.trim().is_empty()) - .is_none() - { + if annotation.tags.is_empty() || !annotation.tags.iter().any(|t| !t.trim().is_empty()) { self.add_to_tag(EMPTY_TAG.as_bytes(), annotation_key)?; } else { for tag in &annotation.tags { @@ -146,12 +140,12 @@ impl Gooseberry { /// Delete an annotation ID from the annotation tree pub fn delete_from_annotations(&self, id: &str) -> color_eyre::Result> { let annotation_key = id.as_bytes(); - Ok(utils::split_ids( + utils::split_ids( &self .annotation_to_tags()? .remove(annotation_key)? .ok_or(Apologize::AnnotationNotFound { id: id.to_owned() })?, - )?) + ) } /// Delete annotation from database diff --git a/src/gooseberry/knowledge_base.rs b/src/gooseberry/knowledge_base.rs index 5319f33..41162ae 100644 --- a/src/gooseberry/knowledge_base.rs +++ b/src/gooseberry/knowledge_base.rs @@ -251,7 +251,7 @@ fn sort_annotations(sort: &[OrderBy], annotations: &mut Vec) /// functions related to generating the `mdBook` wiki impl Gooseberry { pub(crate) fn get_handlebars(&self) -> color_eyre::Result { - Ok(get_handlebars(self.config.get_templates())?) + get_handlebars(self.config.get_templates()) } fn configure_kb(&mut self) -> color_eyre::Result<()> { diff --git a/src/gooseberry/mod.rs b/src/gooseberry/mod.rs index 010220f..08a1ed6 100644 --- a/src/gooseberry/mod.rs +++ b/src/gooseberry/mod.rs @@ -39,7 +39,7 @@ impl Gooseberry { /// (makes new ones the first time). pub async fn start(cli: GooseberryCLI) -> color_eyre::Result<()> { if let GooseberrySubcommand::Config { cmd } = &cli.cmd { - return Ok(ConfigCommand::run(cmd, cli.config.as_deref()).await?); + return ConfigCommand::run(cmd, cli.config.as_deref()).await; } if let GooseberrySubcommand::Complete { shell } = &cli.cmd { GooseberryCLI::complete(*shell); diff --git a/src/utils.rs b/src/utils.rs index 6d40345..bc921dc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -63,13 +63,13 @@ pub fn user_input( /// Gets input from external editor, optionally displays default text in editor pub fn external_editor_input(default: Option<&str>, extension: &str) -> color_eyre::Result { - Ok(Editor::new() + Editor::new() .trim_newlines(false) .extension(extension) .edit(default.unwrap_or("")) .suggestion("Set your default editor using the $EDITOR or $VISUAL environment variables")? .ok_or(Apologize::EditorError) - .suggestion("Make sure to save next time!")?) + .suggestion("Make sure to save next time!") } pub fn get_spinner(message: &str) -> indicatif::ProgressBar {