chore(workspace): fix all clippy warnings in test code
Resolves 15 violations found by `cargo clippy --workspace --tests -D warnings`:
- Remove unused imports (Card, Rank) in cursor_plugin tests
- Replace absurd i32::MAX comparison with a meaningful >= 0 check
- Use range .contains() instead of manual >= && <= (manual_range_contains)
- Move impl FromRequestParts before test module in middleware.rs (items_after_test_module)
- Move _VEC3_REFERENCED const before test module in input_plugin.rs
- Convert runtime assert on constant to const { assert!(...) }
- Use .contains() instead of .iter().any() for slice membership
- Replace .get(...).is_none() with !.contains_key(...) in HashMap checks
- Collapse Default::default() + field assignment into struct literal initializers
across solitaire_sync, solitaire_data, and solitaire_engine test helpers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -775,8 +775,7 @@ mod tests {
|
||||
let mut app = App::new();
|
||||
app.add_plugins(MinimalPlugins).add_plugins(AnimationPlugin);
|
||||
|
||||
let mut fast_settings = Settings::default();
|
||||
fast_settings.animation_speed = AnimSpeed::Fast;
|
||||
let fast_settings = Settings { animation_speed: AnimSpeed::Fast, ..Default::default() };
|
||||
app.world_mut().send_event(SettingsChangedEvent(fast_settings));
|
||||
app.update();
|
||||
|
||||
|
||||
@@ -214,7 +214,6 @@ fn point_in_rect(point: Vec2, center: Vec2, size: Vec2) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use solitaire_core::card::{Card, Rank};
|
||||
|
||||
#[test]
|
||||
fn point_in_rect_center_is_inside() {
|
||||
|
||||
@@ -988,6 +988,11 @@ pub fn find_hint(game: &GameState) -> Option<(PileType, PileType, usize)> {
|
||||
all_hints(game).into_iter().next()
|
||||
}
|
||||
|
||||
// `Vec3` is referenced only via the `DRAG_Z` constant; keep the import silenced
|
||||
// when the compiler can't see it used.
|
||||
#[allow(dead_code)]
|
||||
const _VEC3_REFERENCED: Option<Vec3> = None;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1428,7 +1433,7 @@ mod tests {
|
||||
/// window actually opens on the first G press.
|
||||
#[test]
|
||||
fn forfeit_confirm_window_is_positive() {
|
||||
assert!(FORFEIT_CONFIRM_WINDOW > 0.0, "FORFEIT_CONFIRM_WINDOW must be > 0");
|
||||
const { assert!(FORFEIT_CONFIRM_WINDOW > 0.0, "FORFEIT_CONFIRM_WINDOW must be > 0"); }
|
||||
}
|
||||
|
||||
/// Simulate the first G press: countdown was 0, so it should become
|
||||
@@ -1616,7 +1621,3 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// `Vec3` is referenced only via the `DRAG_Z` constant; keep the import silenced
|
||||
// when the compiler can't see it used.
|
||||
#[allow(dead_code)]
|
||||
const _VEC3_REFERENCED: Option<Vec3> = None;
|
||||
|
||||
@@ -792,7 +792,7 @@ mod tests {
|
||||
.collect();
|
||||
|
||||
assert!(
|
||||
messages.iter().any(|m| *m == "Streak of 3 broken!"),
|
||||
messages.contains(&"Streak of 3 broken!"),
|
||||
"expected 'Streak of 3 broken!' in toasts, got: {messages:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -403,8 +403,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn build_payload_clones_stats() {
|
||||
let mut stats = StatsSnapshot::default();
|
||||
stats.games_played = 42;
|
||||
let stats = StatsSnapshot { games_played: 42, ..Default::default() };
|
||||
let payload = build_payload(&stats, &[], &PlayerProgress::default());
|
||||
assert_eq!(payload.stats.games_played, 42);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ mod tests {
|
||||
assert_eq!(p.weekly_goal_progress.get("weekly_5_wins"), Some(&1));
|
||||
// No-undo + slow win → no_undo goal also ticked, fast goal NOT ticked.
|
||||
assert_eq!(p.weekly_goal_progress.get("weekly_3_no_undo"), Some(&1));
|
||||
assert!(p.weekly_goal_progress.get("weekly_3_fast").is_none());
|
||||
assert!(!p.weekly_goal_progress.contains_key("weekly_3_fast"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -188,7 +188,7 @@ mod tests {
|
||||
app.update();
|
||||
let p = &app.world().resource::<ProgressResource>().0;
|
||||
assert_eq!(p.weekly_goal_progress.get("weekly_5_wins"), Some(&1));
|
||||
assert!(p.weekly_goal_progress.get("weekly_3_no_undo").is_none());
|
||||
assert!(!p.weekly_goal_progress.contains_key("weekly_3_no_undo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user