Skip to content

Commit ef9eeb4

Browse files
committed
Fix lint
1 parent 6df4696 commit ef9eeb4

6 files changed

Lines changed: 21 additions & 23 deletions

File tree

crates/vespera_jni/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ mod jni_impl {
6464
unowned_env
6565
.with_env(|env| -> jni::errors::Result<JObject<'local>> {
6666
let Ok(input) = request_json.try_to_string(env) else {
67-
let err =
68-
vespera_inprocess::serialize_error("invalid request envelope string");
67+
let err = vespera_inprocess::serialize_error("invalid request envelope string");
6968
return Ok(env.new_string(err)?.into());
7069
};
7170

crates/vespera_macro/src/collector.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,11 @@ pub fn collect_file_fingerprints(folder_path: &Path) -> MacroResult<HashMap<Stri
173173
}
174174
let mtime = std::fs::metadata(&file)
175175
.and_then(|m| m.modified())
176-
.map(|t| {
176+
.map_or(0, |t| {
177177
t.duration_since(std::time::UNIX_EPOCH)
178178
.unwrap_or_default()
179179
.as_secs()
180-
})
181-
.unwrap_or(0);
180+
});
182181
fingerprints.insert(file.display().to_string(), mtime);
183182
}
184183
Ok(fingerprints)

crates/vespera_macro/src/parser/schema/struct_schema.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,7 @@ mod tests {
364364
)
365365
.unwrap();
366366
let schema = parse_struct_to_schema(&struct_item, &HashSet::new(), &HashMap::new());
367-
assert_eq!(
368-
schema.description,
369-
Some("Struct description".to_string())
370-
);
367+
assert_eq!(schema.description, Some("Struct description".to_string()));
371368
let props = schema.properties.unwrap();
372369
if let SchemaRef::Inline(id_schema) = props.get("id").unwrap() {
373370
assert_eq!(id_schema.description, Some("Field description".to_string()));

crates/vespera_macro/src/schema_macro/seaorm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,11 @@ mod tests {
715715
let ty: syn::Type = syn::parse_str("Json").unwrap();
716716
let tokens = convert_type_with_chrono(
717717
&ty,
718-
&["crate".to_string(), "models".to_string(), "json_case".to_string()],
718+
&[
719+
"crate".to_string(),
720+
"models".to_string(),
721+
"json_case".to_string(),
722+
],
719723
);
720724
let output = tokens.to_string();
721725
assert_eq!(output.trim(), "vespera :: serde_json :: Value");

crates/vespera_macro/src/schema_macro/type_utils.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,14 @@ fn render_path_arguments(args: &PathArguments, source_module_path: &[String]) ->
212212
let rendered_args: Vec<_> = angle_args
213213
.args
214214
.iter()
215-
.map(|arg| match arg {
216-
GenericArgument::Type(inner_ty) => {
217-
let resolved = normalize_known_type_in_generic(inner_ty, source_module_path);
215+
.map(|arg| {
216+
if let GenericArgument::Type(inner_ty) = arg {
217+
let resolved =
218+
normalize_known_type_in_generic(inner_ty, source_module_path);
218219
quote! { #resolved }
220+
} else {
221+
quote! { #arg }
219222
}
220-
_ => quote! { #arg },
221223
})
222224
.collect();
223225

crates/vespera_macro/src/vespera_impl.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ pub fn generate_and_write_openapi(
181181
if let Some(parent) = file_path.parent() {
182182
std::fs::create_dir_all(parent).map_err(|e| err_call_site(format!("OpenAPI output: failed to create directory '{}'. Error: {}. Ensure the path is valid and writable.", parent.display(), e)))?;
183183
}
184-
let should_write = std::fs::read_to_string(file_path)
185-
.map(|existing| existing != json_pretty)
186-
.unwrap_or(true);
184+
let should_write =
185+
std::fs::read_to_string(file_path).map_or(true, |existing| existing != json_pretty);
187186
if should_write {
188187
std::fs::write(file_path, &json_pretty).map_err(|e| err_call_site(format!("OpenAPI output: failed to write file '{openapi_file_name}'. Error: {e}. Ensure the file path is writable.")))?;
189188
}
@@ -302,9 +301,8 @@ pub fn ensure_openapi_files_from_cache(
302301
};
303302
for openapi_file_name in openapi_file_names {
304303
let file_path = Path::new(openapi_file_name);
305-
let should_write = std::fs::read_to_string(file_path)
306-
.map(|existing| existing != *pretty)
307-
.unwrap_or(true);
304+
let should_write =
305+
std::fs::read_to_string(file_path).map_or(true, |existing| existing != *pretty);
308306
if should_write {
309307
if let Some(parent) = file_path.parent() {
310308
std::fs::create_dir_all(parent).map_err(|e| {
@@ -351,9 +349,8 @@ fn write_spec_for_embedding(
351349
)
352350
})?;
353351
let spec_file = vespera_dir.join("vespera_spec.json");
354-
let should_write = std::fs::read_to_string(&spec_file)
355-
.map(|existing| existing != json)
356-
.unwrap_or(true);
352+
let should_write =
353+
std::fs::read_to_string(&spec_file).map_or(true, |existing| existing != json);
357354
if should_write {
358355
std::fs::write(&spec_file, &json).map_err(|e| {
359356
syn::Error::new(

0 commit comments

Comments
 (0)