Skip to content

Commit

Permalink
style(clippy): lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjani committed Apr 25, 2021
1 parent afc0085 commit d4c4ec3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions src/gooseberry/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Vec<String>> {
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
Expand Down
2 changes: 1 addition & 1 deletion src/gooseberry/knowledge_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn sort_annotations(sort: &[OrderBy], annotations: &mut Vec<AnnotationTemplate>)
/// functions related to generating the `mdBook` wiki
impl Gooseberry {
pub(crate) fn get_handlebars(&self) -> color_eyre::Result<Handlebars> {
Ok(get_handlebars(self.config.get_templates())?)
get_handlebars(self.config.get_templates())
}

fn configure_kb(&mut self) -> color_eyre::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/gooseberry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
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 {
Expand Down

0 comments on commit d4c4ec3

Please sign in to comment.