mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-10 23:26:53 +00:00
fix: resolve all Clippy warnings across codebase - Fixed field reassignment warnings in ecstore/src/file_meta.rs by using struct initialization instead of default + field assignment - Fixed overly complex boolean expression in ecstore/src/utils/os/mod.rs by removing meaningless assertion - Replaced manual Default implementation with derive in crates/zip/src/lib.rs - Updated io::Error usage to use io::Error::other() instead of deprecated pattern - Removed useless assertions and clone-on-copy warnings - Fixed unwrap usage by replacing with expect() providing meaningful error messages - Fixed useless vec usage by using array repeat instead - All code now passes comprehensive Clippy check with --all-targets --all-features -- -D warnings
This commit is contained in:
@@ -279,8 +279,10 @@ mod tests {
|
||||
let result: Result<(), Error> = Err(error);
|
||||
assert!(result.is_err());
|
||||
|
||||
let err = result.unwrap_err();
|
||||
assert!(err.is::<io::Error>());
|
||||
// Test the error from the result
|
||||
if let Err(err) = result {
|
||||
assert!(err.is::<io::Error>());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -245,8 +245,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_last_minute_latency_clone() {
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
latency.last_sec = 12345;
|
||||
let mut latency = LastMinuteLatency {
|
||||
last_sec: 12345,
|
||||
..Default::default()
|
||||
};
|
||||
latency.totals[0].total = 100;
|
||||
|
||||
let cloned = latency.clone();
|
||||
@@ -257,8 +259,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_forward_to_same_time() {
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
latency.last_sec = 100;
|
||||
let mut latency = LastMinuteLatency {
|
||||
last_sec: 100,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Forward to same time should not change anything
|
||||
latency.forward_to(100);
|
||||
@@ -271,8 +275,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_forward_to_large_gap() {
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
latency.last_sec = 100;
|
||||
let mut latency = LastMinuteLatency {
|
||||
last_sec: 100,
|
||||
..Default::default()
|
||||
};
|
||||
latency.totals[0].total = 999; // Set some data
|
||||
|
||||
// Forward by more than 60 seconds should reset all totals
|
||||
@@ -289,8 +295,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_forward_to_small_gap() {
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
latency.last_sec = 100;
|
||||
let mut latency = LastMinuteLatency {
|
||||
last_sec: 100,
|
||||
..Default::default()
|
||||
};
|
||||
latency.totals[1].total = 999; // Set some data at index 1
|
||||
|
||||
// Forward by 2 seconds
|
||||
@@ -446,7 +454,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_window_index_calculation() {
|
||||
// Test that window index calculation works correctly
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
let _latency = LastMinuteLatency::default();
|
||||
|
||||
let acc_elem = AccElem {
|
||||
total: 1,
|
||||
@@ -476,10 +484,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_edge_case_boundary_conditions() {
|
||||
let mut latency = LastMinuteLatency::default();
|
||||
let mut latency = LastMinuteLatency {
|
||||
last_sec: 59,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Test boundary at 60 seconds
|
||||
latency.last_sec = 59;
|
||||
latency.forward_to(119); // Exactly 60 seconds later
|
||||
|
||||
// Should reset all totals
|
||||
|
||||
+14
-14
@@ -696,12 +696,12 @@ mod tests {
|
||||
};
|
||||
|
||||
// Test get_lock (result depends on local locker state)
|
||||
let result = mutex.get_lock(&id, &source, &opts).await;
|
||||
let _result = mutex.get_lock(&id, &source, &opts).await;
|
||||
// Just ensure the method doesn't panic and returns a boolean
|
||||
assert!(result == true || result == false);
|
||||
// assert!(result || !result); // This is always true, so removed
|
||||
|
||||
// If lock was acquired, test unlock
|
||||
if result {
|
||||
if _result {
|
||||
assert!(mutex.is_locked(), "Mutex should be in locked state");
|
||||
mutex.un_lock().await;
|
||||
assert!(!mutex.is_locked(), "Mutex should be unlocked after un_lock");
|
||||
@@ -722,12 +722,12 @@ mod tests {
|
||||
};
|
||||
|
||||
// Test get_r_lock (result depends on local locker state)
|
||||
let result = mutex.get_r_lock(&id, &source, &opts).await;
|
||||
let _result = mutex.get_r_lock(&id, &source, &opts).await;
|
||||
// Just ensure the method doesn't panic and returns a boolean
|
||||
assert!(result == true || result == false);
|
||||
// assert!(result || !result); // This is always true, so removed
|
||||
|
||||
// If read lock was acquired, test runlock
|
||||
if result {
|
||||
if _result {
|
||||
assert!(mutex.is_r_locked(), "Mutex should be in read locked state");
|
||||
mutex.un_r_lock().await;
|
||||
assert!(!mutex.is_r_locked(), "Mutex should be unlocked after un_r_lock");
|
||||
@@ -752,10 +752,10 @@ mod tests {
|
||||
// quorum = 3 - 1 = 2
|
||||
// Since it's a write lock and quorum != tolerance, quorum stays 2
|
||||
// The result depends on the actual locker implementation
|
||||
let result = mutex.get_lock(&id, &source, &opts).await;
|
||||
let _result = mutex.get_lock(&id, &source, &opts).await;
|
||||
// We don't assert success/failure here since it depends on the local locker state
|
||||
// Just ensure the method doesn't panic and returns a boolean
|
||||
assert!(result == true || result == false);
|
||||
// assert!(result || !result); // This is always true, so removed
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -795,10 +795,10 @@ mod tests {
|
||||
retry_interval: Duration::from_millis(10),
|
||||
};
|
||||
|
||||
let result = mutex.get_lock(&id, &source, &opts).await;
|
||||
let _result = mutex.get_lock(&id, &source, &opts).await;
|
||||
// The result depends on the actual locker implementation
|
||||
// Just ensure the method doesn't panic and returns a boolean
|
||||
assert!(result == true || result == false);
|
||||
// assert!(result || !result); // This is always true, so removed
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1049,8 +1049,8 @@ mod tests {
|
||||
// tolerance = 0 / 2 = 0
|
||||
// quorum = 0 - 0 = 0
|
||||
// This should fail because we can't achieve any quorum
|
||||
let result = mutex.get_lock(&id, &source, &opts).await;
|
||||
assert!(!result, "Should fail with zero lockers");
|
||||
let _result = mutex.get_lock(&id, &source, &opts).await;
|
||||
assert!(!_result, "Should fail with zero lockers");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1125,8 +1125,8 @@ mod tests {
|
||||
let mut some_locks = vec!["uid1".to_string(), "uid2".to_string()];
|
||||
let result = mutex.release_all(1, &mut some_locks, false).await;
|
||||
// This should attempt to release the locks and may succeed or fail
|
||||
// depending on the local locker state
|
||||
assert!(result || !result); // Just ensure it doesn't panic
|
||||
// depending on the local locker state - just ensure it doesn't panic
|
||||
let _ = result; // Suppress unused variable warning
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user