chore: Clippy fixes

This commit is contained in:
Gerald Pinder 2025-04-28 20:57:23 -04:00
parent 6bae48bd88
commit 5f648af104
15 changed files with 74 additions and 78 deletions

View file

@ -146,7 +146,7 @@ fn get_config_file(title: &str, message: &str) -> Result<String> {
Ok(requestty::Answer::String(path)) => Ok(path),
Ok(_) => unreachable!(),
Err(e) => {
trace!("Failed to get file: {}", e);
trace!("Failed to get file: {e}");
Err(e).into_diagnostic()
}
}

View file

@ -1,4 +1,5 @@
use std::{
fmt::Write,
fs::OpenOptions,
io::{BufReader, Read},
path::{Path, PathBuf},
@ -66,10 +67,13 @@ impl BlueBuildCommand for ValidateCommand {
ASYNC_RUNTIME.block_on(self.setup_validators())?;
if let Err(errors) = self.validate_recipe() {
let errors = errors.into_iter().fold(String::new(), |mut full, err| {
full.push_str(&format!("{err:?}"));
full
});
let errors = errors.into_iter().try_fold(
String::new(),
|mut full, err| -> miette::Result<String> {
write!(&mut full, "{err:?}").into_diagnostic()?;
Ok(full)
},
)?;
let main_err = format!("Recipe {recipe_path_display} failed to validate");
if self.all_errors {

View file

@ -6,9 +6,8 @@ use std::{
use blue_build_process_management::ASYNC_RUNTIME;
use blue_build_recipe::ModuleTypeVersion;
use blue_build_utils::{
constants::{CUSTOM_MODULE_SCHEMA, IMPORT_MODULE_SCHEMA, JSON_SCHEMA, STAGE_SCHEMA},
retry_async,
use blue_build_utils::constants::{
CUSTOM_MODULE_SCHEMA, IMPORT_MODULE_SCHEMA, JSON_SCHEMA, STAGE_SCHEMA,
};
use bon::bon;
use cached::proc_macro::cached;
@ -337,24 +336,22 @@ async fn cache_retrieve(uri: &Uri<String>) -> miette::Result<Value> {
};
log::debug!("Retrieving schema from {}", uri.bold().italic());
tokio::spawn(
retry_async(3, 2, async move || {
let response = reqwest::get(&*uri)
.await
.into_diagnostic()
.with_context(|| format!("Failed to retrieve schema from {uri}"))?;
let raw_output = response.bytes().await.into_diagnostic()?;
serde_json::from_slice(&raw_output)
.into_diagnostic()
.with_context(|| {
format!(
"Failed to parse json from {uri}, contents:\n{}",
String::from_utf8_lossy(&raw_output)
)
})
.inspect(|value| trace!("{}:\n{value}", uri.bold().italic()))
})
)
tokio::spawn(blue_build_utils::retry_async(3, 2, async move || {
let response = reqwest::get(&*uri)
.await
.into_diagnostic()
.with_context(|| format!("Failed to retrieve schema from {uri}"))?;
let raw_output = response.bytes().await.into_diagnostic()?;
serde_json::from_slice(&raw_output)
.into_diagnostic()
.with_context(|| {
format!(
"Failed to parse json from {uri}, contents:\n{}",
String::from_utf8_lossy(&raw_output)
)
})
.inspect(|value| trace!("{}:\n{value}", uri.bold().italic()))
}))
.await
.expect("Should join task")
}

View file

@ -1,3 +1,4 @@
#![allow(clippy::needless_continue)]
use std::sync::Arc;
use bon::bon;
@ -79,7 +80,7 @@ where
P: Iterator<Item = LocationSegment<'b>>,
{
#[builder]
pub fn new(events: &'a mut I, path: &'b mut P) -> Self {
pub const fn new(events: &'a mut I, path: &'b mut P) -> Self {
Self { events, path }
}
@ -103,11 +104,9 @@ where
match event {
Event::StreamStart if !stream_start && !document_start => {
stream_start = true;
continue;
}
Event::DocumentStart if stream_start && !document_start => {
document_start = true;
continue;
}
Event::MappingStart(_, _) if stream_start && document_start => {
break self.key(key)?.into();
@ -182,8 +181,8 @@ where
Event::Scalar(value, _, _, _) => {
last_index = marker.index() + value.len();
}
_ => continue,
};
_ => (),
}
}
}
@ -203,7 +202,7 @@ where
last_index = marker.index() + value.len();
}
_ => continue,
};
}
}
}