Skip to content

Commit

Permalink
chore: fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Oct 10, 2023
1 parent 17f98dc commit 9cd0644
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/command/bump/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn ensure_tag_is_greater_than_previous(current: &Tag, next: &Tag) -> Result<()>
fn tag_or_fallback_to_zero(tag: Result<Tag, TagError>) -> Result<Tag> {
match tag {
Ok(ref tag) => Ok(tag.clone()),
Err(ref err) if err == &TagError::NoTag => Ok(Tag::default()),
Err(TagError::NoTag) => Ok(Tag::default()),
Err(err) => Err(anyhow!(err)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/conventional/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl fmt::Display for Commit {

impl PartialOrd for Commit {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.message.scope.partial_cmp(&other.message.scope)
Some(self.message.scope.cmp(&other.message.scope))
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/conventional/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ impl From<Increment> for IncrementCommand {

impl Ord for Increment {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap()
match (self, other) {
(increment, other) if increment == other => Ordering::Equal,
(Increment::Major, _) => Ordering::Greater,
(_, Increment::Major) => Ordering::Less,
(Increment::Minor, _) => Ordering::Greater,
(_, Increment::Minor) => Ordering::Less,
(Increment::Patch, Increment::Patch) => Ordering::Equal,
(Increment::NoBump, Increment::NoBump) => Ordering::Equal,
(Increment::Patch, Increment::NoBump) => Ordering::Greater,
(Increment::NoBump, Increment::Patch) => Ordering::Less,
}
}
}

impl PartialOrd for Increment {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(increment, other) if increment == other => Some(Ordering::Equal),
(Increment::Major, _) => Some(Ordering::Greater),
(_, Increment::Major) => Some(Ordering::Less),
(Increment::Minor, _) => Some(Ordering::Greater),
(_, Increment::Minor) => Some(Ordering::Less),
(Increment::Patch, Increment::Patch) => Some(Ordering::Equal),
(Increment::NoBump, Increment::NoBump) => Some(Ordering::Equal),
(Increment::Patch, Increment::NoBump) => Some(Ordering::Greater),
(Increment::NoBump, Increment::Patch) => Some(Ordering::Less),
}
Some(self.cmp(other))
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/git/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub struct Tag {

impl Ord for Tag {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap_or(Ordering::Less)
self.version.cmp(&other.version)
}
}

Expand All @@ -137,15 +137,7 @@ impl PartialEq for Tag {

impl PartialOrd<Tag> for Tag {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
if self.package != other.package {
return None;
}

if self.prefix != other.prefix {
return None;
}

self.version.partial_cmp(&other.version)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/lib_tests/bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;

use crate::helpers::*;

#[sealed_test]
fn bump_ok() -> Result<()> {
// Arrange
Expand Down

0 comments on commit 9cd0644

Please sign in to comment.