fix: clippy warnings

This commit is contained in:
Austin Bonander
2024-06-05 20:15:44 -07:00
parent 41089f3655
commit bae083cf79
110 changed files with 513 additions and 480 deletions

View File

@@ -129,16 +129,15 @@ where
.build(),
|| {
connect(db_url).map_err(|e| -> backoff::Error<anyhow::Error> {
match e {
sqlx::Error::Io(ref ioe) => match ioe.kind() {
if let sqlx::Error::Io(ref ioe) = e {
match ioe.kind() {
io::ErrorKind::ConnectionRefused
| io::ErrorKind::ConnectionReset
| io::ErrorKind::ConnectionAborted => {
return backoff::Error::transient(e.into());
}
_ => (),
},
_ => (),
}
}
backoff::Error::permanent(e.into())

View File

@@ -83,7 +83,7 @@ impl Metadata {
self.packages.get(id)
}
pub fn entries<'this>(&'this self) -> btree_map::Iter<'this, MetadataId, Package> {
pub fn entries(&self) -> btree_map::Iter<'_, MetadataId, Package> {
self.packages.iter()
}

View File

@@ -20,7 +20,7 @@ fn create_file(
use std::path::PathBuf;
let mut file_name = file_prefix.to_string();
file_name.push_str("_");
file_name.push('_');
file_name.push_str(&description.replace(' ', "_"));
file_name.push_str(migration_type.suffix());
@@ -120,20 +120,20 @@ pub async fn add(
if migration_type.is_reversible() {
create_file(
migration_source,
&file_prefix,
file_prefix,
description,
MigrationType::ReversibleUp,
)?;
create_file(
migration_source,
&file_prefix,
file_prefix,
description,
MigrationType::ReversibleDown,
)?;
} else {
create_file(
migration_source,
&file_prefix,
file_prefix,
description,
MigrationType::Simple,
)?;
@@ -194,7 +194,7 @@ fn short_checksum(checksum: &[u8]) -> String {
pub async fn info(migration_source: &str, connect_opts: &ConnectOpts) -> anyhow::Result<()> {
let migrator = Migrator::new(Path::new(migration_source)).await?;
let mut conn = crate::connect(&connect_opts).await?;
let mut conn = crate::connect(connect_opts).await?;
conn.ensure_migrations_table().await?;
@@ -300,7 +300,7 @@ pub async fn run(
let latest_version = applied_migrations
.iter()
.max_by(|x, y| x.version.cmp(&y.version))
.and_then(|migration| Some(migration.version))
.map(|migration| migration.version)
.unwrap_or(0);
if let Some(target_version) = target_version {
if target_version < latest_version {
@@ -326,10 +326,8 @@ pub async fn run(
}
}
None => {
let skip = match target_version {
Some(target_version) if migration.version > target_version => true,
_ => false,
};
let skip =
target_version.is_some_and(|target_version| migration.version > target_version);
let elapsed = if dry_run || skip {
Duration::new(0, 0)
@@ -380,7 +378,7 @@ pub async fn revert(
}
}
let mut conn = crate::connect(&connect_opts).await?;
let mut conn = crate::connect(connect_opts).await?;
conn.ensure_migrations_table().await?;
@@ -395,7 +393,7 @@ pub async fn revert(
let latest_version = applied_migrations
.iter()
.max_by(|x, y| x.version.cmp(&y.version))
.and_then(|migration| Some(migration.version))
.map(|migration| migration.version)
.unwrap_or(0);
if let Some(target_version) = target_version {
if target_version > latest_version {
@@ -417,10 +415,9 @@ pub async fn revert(
}
if applied_migrations.contains_key(&migration.version) {
let skip = match target_version {
Some(target_version) if migration.version <= target_version => true,
_ => false,
};
let skip =
target_version.is_some_and(|target_version| migration.version <= target_version);
let elapsed = if dry_run || skip {
Duration::new(0, 0)
} else {
@@ -447,7 +444,7 @@ pub async fn revert(
// Only a single migration will be reverted at a time if no target
// version is supplied, so we break.
if let None = target_version {
if target_version.is_none() {
break;
}
}