Skip to content

Commit 00d8d5d

Browse files
committed
fix clippy warning failing on CI (#2353)
# Objective - CI jobs are starting to fail due to `clippy::bool-assert-comparison` and `clippy::single_component_path_imports` being triggered. ## Solution - Fix all uses where `asset_eq!(<condition>, <bool>)` could be replace by `assert!` - Move the `#[allow()]` for `single_component_path_imports` to `#![allow()]` at the start of the files.
1 parent 71bf07f commit 00d8d5d

File tree

7 files changed

+32
-36
lines changed

7 files changed

+32
-36
lines changed

crates/bevy_core/src/time/timer.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -375,37 +375,37 @@ mod tests {
375375
t.tick(Duration::from_secs_f32(0.25));
376376
assert_eq!(t.elapsed_secs(), 0.25);
377377
assert_eq!(t.duration(), Duration::from_secs_f32(10.0));
378-
assert_eq!(t.finished(), false);
379-
assert_eq!(t.just_finished(), false);
378+
assert!(!t.finished());
379+
assert!(!t.just_finished());
380380
assert_eq!(t.times_finished(), 0);
381-
assert_eq!(t.repeating(), false);
381+
assert!(!t.repeating());
382382
assert_eq!(t.percent(), 0.025);
383383
assert_eq!(t.percent_left(), 0.975);
384384
// Ticking while paused changes nothing
385385
t.pause();
386386
t.tick(Duration::from_secs_f32(500.0));
387387
assert_eq!(t.elapsed_secs(), 0.25);
388388
assert_eq!(t.duration(), Duration::from_secs_f32(10.0));
389-
assert_eq!(t.finished(), false);
390-
assert_eq!(t.just_finished(), false);
389+
assert!(!t.finished());
390+
assert!(!t.just_finished());
391391
assert_eq!(t.times_finished(), 0);
392-
assert_eq!(t.repeating(), false);
392+
assert!(!t.repeating());
393393
assert_eq!(t.percent(), 0.025);
394394
assert_eq!(t.percent_left(), 0.975);
395395
// Tick past the end and make sure elapsed doesn't go past 0.0 and other things update
396396
t.unpause();
397397
t.tick(Duration::from_secs_f32(500.0));
398398
assert_eq!(t.elapsed_secs(), 10.0);
399-
assert_eq!(t.finished(), true);
400-
assert_eq!(t.just_finished(), true);
399+
assert!(t.finished());
400+
assert!(t.just_finished());
401401
assert_eq!(t.times_finished(), 1);
402402
assert_eq!(t.percent(), 1.0);
403403
assert_eq!(t.percent_left(), 0.0);
404404
// Continuing to tick when finished should only change just_finished
405405
t.tick(Duration::from_secs_f32(1.0));
406406
assert_eq!(t.elapsed_secs(), 10.0);
407-
assert_eq!(t.finished(), true);
408-
assert_eq!(t.just_finished(), false);
407+
assert!(t.finished());
408+
assert!(!t.just_finished());
409409
assert_eq!(t.times_finished(), 0);
410410
assert_eq!(t.percent(), 1.0);
411411
assert_eq!(t.percent_left(), 0.0);
@@ -418,25 +418,25 @@ mod tests {
418418
t.tick(Duration::from_secs_f32(0.75));
419419
assert_eq!(t.elapsed_secs(), 0.75);
420420
assert_eq!(t.duration(), Duration::from_secs_f32(2.0));
421-
assert_eq!(t.finished(), false);
422-
assert_eq!(t.just_finished(), false);
421+
assert!(!t.finished());
422+
assert!(!t.just_finished());
423423
assert_eq!(t.times_finished(), 0);
424-
assert_eq!(t.repeating(), true);
424+
assert!(t.repeating());
425425
assert_eq!(t.percent(), 0.375);
426426
assert_eq!(t.percent_left(), 0.625);
427427
// Tick past the end and make sure elapsed wraps
428428
t.tick(Duration::from_secs_f32(1.5));
429429
assert_eq!(t.elapsed_secs(), 0.25);
430-
assert_eq!(t.finished(), true);
431-
assert_eq!(t.just_finished(), true);
430+
assert!(t.finished());
431+
assert!(t.just_finished());
432432
assert_eq!(t.times_finished(), 1);
433433
assert_eq!(t.percent(), 0.125);
434434
assert_eq!(t.percent_left(), 0.875);
435435
// Continuing to tick should turn off both finished & just_finished for repeating timers
436436
t.tick(Duration::from_secs_f32(1.0));
437437
assert_eq!(t.elapsed_secs(), 1.25);
438-
assert_eq!(t.finished(), false);
439-
assert_eq!(t.just_finished(), false);
438+
assert!(!t.finished());
439+
assert!(!t.just_finished());
440440
assert_eq!(t.times_finished(), 0);
441441
assert_eq!(t.percent(), 0.625);
442442
assert_eq!(t.percent_left(), 0.375);

crates/bevy_dylib/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::single_component_path_imports)]
2+
13
//! Forces dynamic linking of Bevy.
24
//!
35
//! Dynamically linking Bevy makes the "link" step much faster. This can be achieved by adding
@@ -8,5 +10,4 @@
810
911
// Force linking of the main bevy crate
1012
#[allow(unused_imports)]
11-
#[allow(clippy::single_component_path_imports)]
1213
use bevy_internal;

crates/bevy_ecs/src/system/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ mod tests {
324324
run_system(&mut world, sys.system());
325325

326326
// ensure the system actually ran
327-
assert_eq!(*world.get_resource::<bool>().unwrap(), true);
327+
assert!(*world.get_resource::<bool>().unwrap());
328328
}
329329

330330
#[test]
@@ -353,7 +353,7 @@ mod tests {
353353
}
354354

355355
run_system(&mut world, validate_removed.system());
356-
assert_eq!(*world.get_resource::<bool>().unwrap(), true, "system ran");
356+
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
357357
}
358358

359359
#[test]
@@ -371,7 +371,7 @@ mod tests {
371371
);
372372

373373
// ensure the system actually ran
374-
assert_eq!(*world.get_resource::<bool>().unwrap(), true);
374+
assert!(*world.get_resource::<bool>().unwrap());
375375
}
376376
#[test]
377377
fn world_collections_system() {
@@ -414,7 +414,7 @@ mod tests {
414414
run_system(&mut world, sys.system());
415415

416416
// ensure the system actually ran
417-
assert_eq!(*world.get_resource::<bool>().unwrap(), true);
417+
assert!(*world.get_resource::<bool>().unwrap());
418418
}
419419

420420
#[test]

crates/bevy_render/src/camera/visible_entities.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,12 @@ mod rendering_mask_tests {
167167
"default masks match each other"
168168
);
169169

170-
assert_eq!(
171-
RenderLayers::layer(0).intersects(&RenderLayers::layer(1)),
172-
false,
170+
assert!(
171+
!RenderLayers::layer(0).intersects(&RenderLayers::layer(1)),
173172
"masks with differing layers do not match"
174173
);
175-
assert_eq!(
176-
RenderLayers(0).intersects(&RenderLayers(0)),
177-
false,
174+
assert!(
175+
!RenderLayers(0).intersects(&RenderLayers(0)),
178176
"empty masks don't match"
179177
);
180178
assert_eq!(

crates/bevy_tasks/src/countdown_event.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ mod tests {
125125
let listener3 = event.listen();
126126

127127
// Verify that we are still blocked
128-
assert_eq!(
129-
false,
130-
listener2.wait_timeout(instant::Duration::from_millis(10))
131-
);
128+
assert!(!listener2.wait_timeout(instant::Duration::from_millis(10)));
132129

133130
// Notify all and verify the remaining listener is notified
134131
event.notify(std::usize::MAX);

crates/bevy_transform/src/hierarchy/hierarchy.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ mod tests {
123123

124124
{
125125
let children = world.get::<Children>(grandparent_entity).unwrap();
126-
assert_eq!(
127-
children.iter().any(|&i| i == parent_entity),
128-
false,
126+
assert!(
127+
!children.iter().any(|&i| i == parent_entity),
129128
"grandparent should no longer know about its child which has been removed"
130129
);
131130
}

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::single_component_path_imports)]
2+
13
//! [![](https://bevyengine.org/assets/bevy_logo_docs.svg)](https://bevyengine.org)
24
//!
35
//! Bevy is an open-source modular game engine built in Rust, with a focus on developer productivity
@@ -45,5 +47,4 @@ pub use bevy_internal::*;
4547

4648
#[cfg(feature = "dynamic")]
4749
#[allow(unused_imports)]
48-
#[allow(clippy::single_component_path_imports)]
4950
use bevy_dylib;

0 commit comments

Comments
 (0)