mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
chore(lint): clippy rules needless_collect (#2522)
This commit is contained in:
@@ -73,6 +73,7 @@ unsafe_code = "deny"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
all = "warn"
|
||||
needless_collect = "warn"
|
||||
|
||||
[workspace.dependencies]
|
||||
# RustFS Internal Crates
|
||||
|
||||
@@ -281,8 +281,11 @@ async fn test_select_object_content_csv_limit() -> Result<(), Box<dyn Error>> {
|
||||
println!("CSV Limit result: {result_str}");
|
||||
|
||||
// Verify only first 2 records are returned
|
||||
let lines: Vec<&str> = result_str.lines().filter(|line| !line.trim().is_empty()).collect();
|
||||
assert_eq!(lines.len(), 2, "Should return exactly 2 records");
|
||||
assert_eq!(
|
||||
result_str.lines().filter(|line| !line.trim().is_empty()).count(),
|
||||
2,
|
||||
"Should return exactly 2 records"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -321,8 +324,10 @@ async fn test_select_object_content_csv_order_by() -> Result<(), Box<dyn Error>>
|
||||
println!("CSV Order By result: {result_str}");
|
||||
|
||||
// Verify ordered by age descending
|
||||
let lines: Vec<&str> = result_str.lines().filter(|line| !line.trim().is_empty()).collect();
|
||||
assert!(lines.len() >= 2, "Should return at least 2 records");
|
||||
assert!(
|
||||
result_str.lines().filter(|line| !line.trim().is_empty()).count() >= 2,
|
||||
"Should return at least 2 records"
|
||||
);
|
||||
|
||||
// Check if contains highest age records
|
||||
assert!(result_str.contains("Charlie,35"));
|
||||
|
||||
@@ -1488,12 +1488,12 @@ mod test {
|
||||
}
|
||||
|
||||
// Verify stable ordering
|
||||
let original_order: Vec<_> = fm.versions.iter().map(|v| v.header.version_id).collect();
|
||||
let original_order = fm.versions.iter().map(|v| v.header.version_id).len();
|
||||
fm.sort_by_mod_time();
|
||||
let sorted_order: Vec<_> = fm.versions.iter().map(|v| v.header.version_id).collect();
|
||||
let sorted_order = fm.versions.iter().map(|v| v.header.version_id).len();
|
||||
|
||||
// Sorting should remain stable for identical timestamps
|
||||
assert_eq!(original_order.len(), sorted_order.len());
|
||||
assert_eq!(original_order, sorted_order);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -293,8 +293,7 @@ where
|
||||
|
||||
if !self.args.auth_token.is_empty() {
|
||||
// Split auth_token string to check if the authentication type is included
|
||||
let tokens: Vec<&str> = self.args.auth_token.split_whitespace().collect();
|
||||
match tokens.len() {
|
||||
match self.args.auth_token.split_whitespace().count() {
|
||||
2 => {
|
||||
// Already include authentication type and token, such as "Bearer token123"
|
||||
req_builder = req_builder.header("Authorization", &self.args.auth_token);
|
||||
|
||||
@@ -454,8 +454,11 @@ impl ConditionalCorsLayer {
|
||||
let allowed_origin = match (origin, &self.cors_origins) {
|
||||
(Some(orig), Some(config)) if config == "*" => Some(orig),
|
||||
(Some(orig), Some(config)) => {
|
||||
let origins: Vec<&str> = config.split(',').map(|s| s.trim()).collect();
|
||||
if origins.contains(&orig.as_str()) { Some(orig) } else { None }
|
||||
if config.split(',').map(|s| s.trim()).any(|x| x == orig.as_str()) {
|
||||
Some(orig)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
(Some(orig), None) => Some(orig), // Default: allow all if not configured
|
||||
_ => None,
|
||||
|
||||
Reference in New Issue
Block a user