treewide: fix clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I411be69ff31f9cb39cd4cdebc8985b366a6a6964
This commit is contained in:
parent
b93b234fc2
commit
61ced09d25
43 changed files with 558 additions and 464 deletions
|
|
@ -17,8 +17,8 @@ pub async fn execute(
|
|||
lockfile_path: &Path,
|
||||
config_path: &Path,
|
||||
) -> Result<()> {
|
||||
let lockfile_dir = lockfile_path.parent().unwrap_or(Path::new("."));
|
||||
let config_dir = config_path.parent().unwrap_or(Path::new("."));
|
||||
let lockfile_dir = lockfile_path.parent().unwrap_or_else(|| Path::new("."));
|
||||
let config_dir = config_path.parent().unwrap_or_else(|| Path::new("."));
|
||||
|
||||
let lockfile = LockFile::load(lockfile_dir)?;
|
||||
let config = Config::load(config_dir)?;
|
||||
|
|
@ -67,7 +67,6 @@ pub async fn execute(
|
|||
}
|
||||
|
||||
// Log info level summary
|
||||
let _info_severity = ErrorSeverity::Info;
|
||||
log::info!(
|
||||
"Update check completed with {} warning(s) and {} error(s)",
|
||||
warnings.len(),
|
||||
|
|
@ -138,6 +137,10 @@ struct FileUpdate {
|
|||
new_filename: String,
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::expect_used,
|
||||
reason = "progress bar template is a string literal and is always valid"
|
||||
)]
|
||||
async fn check_updates_sequential(
|
||||
lockfile: &LockFile,
|
||||
) -> Result<(Vec<ProjectUpdate>, Vec<(String, String)>)> {
|
||||
|
|
@ -150,7 +153,7 @@ async fn check_updates_sequential(
|
|||
pb.set_style(
|
||||
ProgressStyle::default_bar()
|
||||
.template("{spinner:.green} [{bar:40.cyan/blue}] {pos}/{len} {msg}")
|
||||
.unwrap()
|
||||
.expect("progress bar template is valid")
|
||||
.progress_chars("#>-"),
|
||||
);
|
||||
pb.set_message("Checking for updates...");
|
||||
|
|
@ -160,8 +163,8 @@ async fn check_updates_sequential(
|
|||
.name
|
||||
.values()
|
||||
.next()
|
||||
.unwrap_or(&"Unknown".to_string())
|
||||
.clone();
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Unknown".to_string());
|
||||
pb.set_message(format!("Checking {project_name}..."));
|
||||
|
||||
match check_project_update(project, lockfile).await {
|
||||
|
|
@ -184,6 +187,11 @@ async fn check_updates_sequential(
|
|||
Ok((updates, errors))
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::expect_used,
|
||||
reason = "progress bar template and semaphore acquire are infallible in \
|
||||
this context"
|
||||
)]
|
||||
async fn check_updates_parallel(
|
||||
lockfile: &LockFile,
|
||||
) -> Result<(Vec<ProjectUpdate>, Vec<(String, String)>)> {
|
||||
|
|
@ -196,7 +204,7 @@ async fn check_updates_parallel(
|
|||
pb.set_style(
|
||||
ProgressStyle::default_bar()
|
||||
.template("{spinner:.green} [{bar:40.cyan/blue}] {pos}/{len} {msg}")
|
||||
.unwrap()
|
||||
.expect("progress bar template is valid")
|
||||
.progress_chars("#>-"),
|
||||
);
|
||||
pb.set_message("Checking for updates (parallel)...");
|
||||
|
|
@ -208,7 +216,7 @@ async fn check_updates_parallel(
|
|||
let lockfile_clone = lockfile.clone();
|
||||
|
||||
futures.push(async move {
|
||||
let _permit = sem.acquire().await.unwrap();
|
||||
let _permit = sem.acquire().await.expect("semaphore closed unexpectedly");
|
||||
let result = check_project_update(&project, &lockfile_clone).await;
|
||||
pb_clone.inc(1);
|
||||
(project, result)
|
||||
|
|
@ -230,8 +238,8 @@ async fn check_updates_parallel(
|
|||
.name
|
||||
.values()
|
||||
.next()
|
||||
.unwrap_or(&"Unknown".to_string())
|
||||
.clone();
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Unknown".to_string());
|
||||
errors.push((project_name, e.to_string()));
|
||||
},
|
||||
}
|
||||
|
|
@ -260,37 +268,30 @@ async fn check_project_update(
|
|||
// Try each platform in project
|
||||
for platform_name in project.id.keys() {
|
||||
let api_key = get_api_key(platform_name);
|
||||
let platform = match create_platform(platform_name, api_key) {
|
||||
Ok(p) => p,
|
||||
Err(_) => continue,
|
||||
let Ok(platform) = create_platform(platform_name, api_key) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let loaders: Vec<String> = lockfile.loaders.keys().cloned().collect();
|
||||
|
||||
match platform
|
||||
if let Ok(updated_project) = platform
|
||||
.request_project_with_files(&slug, &lockfile.mc_versions, &loaders)
|
||||
.await
|
||||
{
|
||||
Ok(updated_project) => {
|
||||
// Compare files to detect updates
|
||||
let file_updates = detect_file_updates(project, &updated_project);
|
||||
// Compare files to detect updates
|
||||
let file_updates = detect_file_updates(project, &updated_project);
|
||||
|
||||
if !file_updates.is_empty() {
|
||||
return Ok(Some(ProjectUpdate {
|
||||
slug: project.slug.clone(),
|
||||
name: project.name.values().next().cloned().unwrap_or_default(),
|
||||
project_type: format!("{:?}", project.r#type),
|
||||
side: format!("{:?}", project.side),
|
||||
file_updates,
|
||||
}));
|
||||
}
|
||||
if !file_updates.is_empty() {
|
||||
return Ok(Some(ProjectUpdate {
|
||||
slug: project.slug.clone(),
|
||||
name: project.name.values().next().cloned().unwrap_or_default(),
|
||||
project_type: format!("{:?}", project.r#type),
|
||||
side: format!("{:?}", project.side),
|
||||
file_updates,
|
||||
}));
|
||||
}
|
||||
|
||||
return Ok(None); // No updates
|
||||
},
|
||||
Err(_) => {
|
||||
// Try next platform
|
||||
continue;
|
||||
},
|
||||
return Ok(None); // No updates
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue