Skip to content

Commit 6544ec8

Browse files
committed
Fix lint
1 parent 83c7003 commit 6544ec8

30 files changed

Lines changed: 618 additions & 691 deletions

crates/vespera/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod openapi {
2020
pub use vespera_core::openapi::OpenApi;
2121

2222
// Re-export macros from vespera_macro
23-
pub use vespera_macro::{export_app, route, schema, schema_type, vespera, Schema};
23+
pub use vespera_macro::{Schema, export_app, route, schema, schema_type, vespera};
2424

2525
// Re-export serde_json for merge feature (runtime spec merging)
2626
pub use serde_json;

crates/vespera_core/src/route.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ mod tests {
566566
#[test]
567567
fn test_http_method_clone() {
568568
let method = HttpMethod::Get;
569-
let cloned = method.clone();
569+
let cloned = method;
570570
assert_eq!(method, cloned);
571571
}
572572

crates/vespera_macro/src/args.rs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,12 @@ mod tests {
136136
if let Some(exp_method) = expected_method {
137137
assert!(
138138
route_args.method.is_some(),
139-
"Expected method {} but got None for input: {}",
140-
exp_method,
141-
input
139+
"Expected method {exp_method} but got None for input: {input}"
142140
);
143141
assert_eq!(
144142
route_args.method.as_ref().unwrap().to_string(),
145143
exp_method,
146-
"Method mismatch for input: {}",
147-
input
144+
"Method mismatch for input: {input}"
148145
);
149146
} else {
150147
assert!(
@@ -159,15 +156,12 @@ mod tests {
159156
if let Some(exp_path) = expected_path {
160157
assert!(
161158
route_args.path.is_some(),
162-
"Expected path {} but got None for input: {}",
163-
exp_path,
164-
input
159+
"Expected path {exp_path} but got None for input: {input}"
165160
);
166161
assert_eq!(
167162
route_args.path.as_ref().unwrap().value(),
168163
exp_path,
169-
"Path mismatch for input: {}",
170-
input
164+
"Path mismatch for input: {input}"
171165
);
172166
} else {
173167
assert!(
@@ -182,9 +176,7 @@ mod tests {
182176
if let Some(exp_status) = expected_error_status {
183177
assert!(
184178
route_args.error_status.is_some(),
185-
"Expected error_status {:?} but got None for input: {}",
186-
exp_status,
187-
input
179+
"Expected error_status {exp_status:?} but got None for input: {input}"
188180
);
189181
let array = route_args.error_status.as_ref().unwrap();
190182
let mut status_codes = Vec::new();
@@ -200,8 +192,7 @@ mod tests {
200192
}
201193
assert_eq!(
202194
status_codes, exp_status,
203-
"Error status mismatch for input: {}",
204-
input
195+
"Error status mismatch for input: {input}"
205196
);
206197
} else {
207198
assert!(
@@ -216,13 +207,10 @@ mod tests {
216207
// Expected error, test passes
217208
}
218209
(true, Err(e)) => {
219-
panic!(
220-
"Expected successful parse but got error: {} for input: {}",
221-
e, input
222-
);
210+
panic!("Expected successful parse but got error: {e} for input: {input}");
223211
}
224212
(false, Ok(_)) => {
225-
panic!("Expected parse error but got success for input: {}", input);
213+
panic!("Expected parse error but got success for input: {input}");
226214
}
227215
}
228216
}
@@ -258,8 +246,7 @@ mod tests {
258246
} else {
259247
assert!(
260248
route_args.tags.is_some(),
261-
"Expected tags but got None for input: {}",
262-
input
249+
"Expected tags but got None for input: {input}"
263250
);
264251
let tags_array = route_args.tags.as_ref().unwrap();
265252
let mut parsed_tags = Vec::new();
@@ -274,22 +261,18 @@ mod tests {
274261
}
275262
assert_eq!(
276263
parsed_tags, expected_tags,
277-
"Tags mismatch for input: {}",
278-
input
264+
"Tags mismatch for input: {input}"
279265
);
280266
}
281267
}
282268
(false, Err(_)) => {
283269
// Expected error, test passes
284270
}
285271
(true, Err(e)) => {
286-
panic!(
287-
"Expected successful parse but got error: {} for input: {}",
288-
e, input
289-
);
272+
panic!("Expected successful parse but got error: {e} for input: {input}");
290273
}
291274
(false, Ok(_)) => {
292-
panic!("Expected parse error but got success for input: {}", input);
275+
panic!("Expected parse error but got success for input: {input}");
293276
}
294277
}
295278
}

crates/vespera_macro/src/collector.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,12 @@ pub fn get_users() -> String {
274274
create_temp_file(
275275
&temp_dir,
276276
"user.rs",
277-
r#"
277+
r"
278278
pub struct User {
279279
pub id: i32,
280280
pub name: String,
281281
}
282-
"#,
282+
",
283283
);
284284

285285
let metadata = collect_metadata(temp_dir.path(), folder_name).unwrap();
@@ -382,29 +382,29 @@ pub fn get_posts() -> String {
382382
create_temp_file(
383383
&temp_dir,
384384
"user.rs",
385-
r#"
385+
r"
386386
use vespera::Schema;
387387
388388
#[derive(Schema)]
389389
pub struct User {
390390
pub id: i32,
391391
pub name: String,
392392
}
393-
"#,
393+
",
394394
);
395395

396396
create_temp_file(
397397
&temp_dir,
398398
"post.rs",
399-
r#"
399+
r"
400400
use vespera::Schema;
401401
402402
#[derive(Schema)]
403403
pub struct Post {
404404
pub id: i32,
405405
pub title: String,
406406
}
407-
"#,
407+
",
408408
);
409409

410410
let metadata = collect_metadata(temp_dir.path(), folder_name).unwrap();
@@ -786,12 +786,12 @@ pub fn get_users() -> String {
786786
create_temp_file(
787787
&temp_dir,
788788
"user.rs",
789-
r#"
789+
r"
790790
pub struct User {
791791
pub id: i32,
792792
pub name: String,
793793
}
794-
"#,
794+
",
795795
);
796796

797797
let metadata = collect_metadata(temp_dir.path(), folder_name).unwrap();
@@ -811,13 +811,13 @@ pub struct User {
811811
create_temp_file(
812812
&temp_dir,
813813
"user.rs",
814-
r#"
814+
r"
815815
#[derive(Debug, Clone)]
816816
pub struct User {
817817
pub id: i32,
818818
pub name: String,
819819
}
820-
"#,
820+
",
821821
);
822822

823823
let metadata = collect_metadata(temp_dir.path(), folder_name).unwrap();

crates/vespera_macro/src/file_utils.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub fn collect_files(folder_path: &Path) -> io::Result<Vec<PathBuf>> {
5353
}
5454

5555
pub fn file_to_segments(file: &Path, base_path: &Path) -> Vec<String> {
56-
let file_stem = file.strip_prefix(base_path).map_or_else(|_| file.display().to_string(), |file_stem| file_stem.display().to_string());
56+
let file_stem = file.strip_prefix(base_path).map_or_else(
57+
|_| file.display().to_string(),
58+
|file_stem| file_stem.display().to_string(),
59+
);
5760
let file_stem = file_stem.replace(".rs", "").replace('\\', "/");
5861
let mut segments: Vec<String> = file_stem
5962
.split('/')
@@ -117,16 +120,18 @@ mod tests {
117120
) {
118121
// Normalize paths by replacing backslashes with forward slashes
119122
// This ensures tests work cross-platform (Windows uses \, Unix uses /)
120-
let normalized_file_path = file_path.replace("\\", "/");
121-
let normalized_base_path = base_path.replace("\\", "/");
123+
let normalized_file_path = file_path.replace('\\', "/");
124+
let normalized_base_path = base_path.replace('\\', "/");
122125
let file = PathBuf::from(normalized_file_path);
123126
let base = PathBuf::from(normalized_base_path);
124127
let result = file_to_segments(&file, &base);
125-
let expected_vec: Vec<String> = expected.iter().map(|s| s.to_string()).collect();
128+
let expected_vec: Vec<String> = expected
129+
.iter()
130+
.map(std::string::ToString::to_string)
131+
.collect();
126132
assert_eq!(
127133
result, expected_vec,
128-
"Failed for file: {}, base: {}",
129-
file_path, base_path
134+
"Failed for file: {file_path}, base: {base_path}"
130135
);
131136
}
132137

@@ -156,7 +161,7 @@ mod tests {
156161
p.strip_prefix(base)
157162
.unwrap_or(p)
158163
.to_string_lossy()
159-
.replace("\\", "/")
164+
.replace('\\', "/")
160165
})
161166
.collect();
162167
normalized.sort();
@@ -236,14 +241,15 @@ mod tests {
236241
let mut normalized_result = normalize_paths(&result, temp_dir.path());
237242
normalized_result.sort();
238243

239-
let mut expected_normalized: Vec<String> =
240-
expected_files.iter().map(|s| s.to_string()).collect();
244+
let mut expected_normalized: Vec<String> = expected_files
245+
.iter()
246+
.map(std::string::ToString::to_string)
247+
.collect();
241248
expected_normalized.sort();
242249

243250
assert_eq!(
244251
normalized_result, expected_normalized,
245-
"Failed for structure: {:?}",
246-
structure
252+
"Failed for structure: {structure:?}"
247253
);
248254

249255
temp_dir.close().expect("Failed to close temp dir");
@@ -263,7 +269,7 @@ mod tests {
263269
// Create a very deep nested structure
264270
let mut path = temp_dir.path().to_path_buf();
265271
for i in 0..5 {
266-
path = path.join(format!("level{}", i));
272+
path = path.join(format!("level{i}"));
267273
fs::create_dir_all(&path).expect("Failed to create nested dir");
268274
}
269275

crates/vespera_macro/src/http.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ mod tests {
7878
for method in HTTP_METHODS {
7979
assert!(
8080
is_http_method(method),
81-
"Method {} should be recognized",
82-
method
81+
"Method {method} should be recognized"
8382
);
8483
}
8584
}

crates/vespera_macro/src/method.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,25 @@ mod tests {
4242
// quote! generates "vespera :: axum :: routing :: get" format
4343
assert!(
4444
code.contains(expected_method_name),
45-
"Code should contain method name: {}, got: {}",
46-
expected_method_name,
47-
code
45+
"Code should contain method name: {expected_method_name}, got: {code}"
4846
);
4947

5048
// Check that it contains the routing path
5149
assert!(
5250
code.contains("routing"),
53-
"Code should contain 'routing', got: {}",
54-
code
51+
"Code should contain 'routing', got: {code}"
5552
);
5653

5754
// Check that it contains the axum path
5855
assert!(
5956
code.contains("axum"),
60-
"Code should contain 'axum', got: {}",
61-
code
57+
"Code should contain 'axum', got: {code}"
6258
);
6359

6460
// Check that it contains the vespera path
6561
assert!(
6662
code.contains("vespera"),
67-
"Code should contain 'vespera', got: {}",
68-
code
63+
"Code should contain 'vespera', got: {code}"
6964
);
7065
}
7166

@@ -84,20 +79,17 @@ mod tests {
8479
];
8580

8681
for method in methods {
87-
let result = http_method_to_token_stream(method.clone());
82+
let result = http_method_to_token_stream(method);
8883
let code = result.to_string();
8984

9085
// Each should generate a valid TokenStream
9186
assert!(
9287
!code.is_empty(),
93-
"TokenStream should not be empty for {:?}",
94-
method
88+
"TokenStream should not be empty for {method:?}"
9589
);
9690
assert!(
9791
code.contains("routing"),
98-
"TokenStream should contain 'routing' for {:?}, got: {}",
99-
method,
100-
code
92+
"TokenStream should contain 'routing' for {method:?}, got: {code}"
10193
);
10294
}
10395
}

0 commit comments

Comments
 (0)