Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
cart committed Jul 2, 2021
1 parent d0c3185 commit 9a79b79
Show file tree
Hide file tree
Showing 27 changed files with 1,347 additions and 1,335 deletions.
12 changes: 5 additions & 7 deletions crates/bevy_app/src/ci_testing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use serde::Deserialize;

use crate::{app::AppExit, AppBuilder};
use crate::app::{App, AppExit};
use bevy_ecs::system::IntoSystem;
use serde::Deserialize;

/// Configuration for automated testing on CI
#[derive(Deserialize)]
Expand All @@ -23,16 +22,15 @@ fn ci_testing_exit_after(
*current_frame += 1;
}

pub(crate) fn setup_app(app_builder: &mut AppBuilder) -> &mut AppBuilder {
pub(crate) fn setup_app(app: &mut App) -> &mut App {
let filename =
std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string());
let config: CiTestingConfig = ron::from_str(
&std::fs::read_to_string(filename).expect("error reading CI testing configuration file"),
)
.expect("error deserializing CI testing configuration file");
app_builder
.insert_resource(config)
app.insert_resource(config)
.add_system(ci_testing_exit_after.system());

app_builder
app
}
34 changes: 17 additions & 17 deletions crates/bevy_core/src/time/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,37 +375,37 @@ mod tests {
t.tick(Duration::from_secs_f32(0.25));
assert_eq!(t.elapsed_secs(), 0.25);
assert_eq!(t.duration(), Duration::from_secs_f32(10.0));
assert_eq!(t.finished(), false);
assert_eq!(t.just_finished(), false);
assert!(!t.finished());
assert!(!t.just_finished());
assert_eq!(t.times_finished(), 0);
assert_eq!(t.repeating(), false);
assert!(!t.repeating());
assert_eq!(t.percent(), 0.025);
assert_eq!(t.percent_left(), 0.975);
// Ticking while paused changes nothing
t.pause();
t.tick(Duration::from_secs_f32(500.0));
assert_eq!(t.elapsed_secs(), 0.25);
assert_eq!(t.duration(), Duration::from_secs_f32(10.0));
assert_eq!(t.finished(), false);
assert_eq!(t.just_finished(), false);
assert!(!t.finished());
assert!(!t.just_finished());
assert_eq!(t.times_finished(), 0);
assert_eq!(t.repeating(), false);
assert!(!t.repeating());
assert_eq!(t.percent(), 0.025);
assert_eq!(t.percent_left(), 0.975);
// Tick past the end and make sure elapsed doesn't go past 0.0 and other things update
t.unpause();
t.tick(Duration::from_secs_f32(500.0));
assert_eq!(t.elapsed_secs(), 10.0);
assert_eq!(t.finished(), true);
assert_eq!(t.just_finished(), true);
assert!(t.finished());
assert!(t.just_finished());
assert_eq!(t.times_finished(), 1);
assert_eq!(t.percent(), 1.0);
assert_eq!(t.percent_left(), 0.0);
// Continuing to tick when finished should only change just_finished
t.tick(Duration::from_secs_f32(1.0));
assert_eq!(t.elapsed_secs(), 10.0);
assert_eq!(t.finished(), true);
assert_eq!(t.just_finished(), false);
assert!(t.finished());
assert!(!t.just_finished());
assert_eq!(t.times_finished(), 0);
assert_eq!(t.percent(), 1.0);
assert_eq!(t.percent_left(), 0.0);
Expand All @@ -418,25 +418,25 @@ mod tests {
t.tick(Duration::from_secs_f32(0.75));
assert_eq!(t.elapsed_secs(), 0.75);
assert_eq!(t.duration(), Duration::from_secs_f32(2.0));
assert_eq!(t.finished(), false);
assert_eq!(t.just_finished(), false);
assert!(!t.finished());
assert!(!t.just_finished());
assert_eq!(t.times_finished(), 0);
assert_eq!(t.repeating(), true);
assert!(t.repeating());
assert_eq!(t.percent(), 0.375);
assert_eq!(t.percent_left(), 0.625);
// Tick past the end and make sure elapsed wraps
t.tick(Duration::from_secs_f32(1.5));
assert_eq!(t.elapsed_secs(), 0.25);
assert_eq!(t.finished(), true);
assert_eq!(t.just_finished(), true);
assert!(t.finished());
assert!(t.just_finished());
assert_eq!(t.times_finished(), 1);
assert_eq!(t.percent(), 0.125);
assert_eq!(t.percent_left(), 0.875);
// Continuing to tick should turn off both finished & just_finished for repeating timers
t.tick(Duration::from_secs_f32(1.0));
assert_eq!(t.elapsed_secs(), 1.25);
assert_eq!(t.finished(), false);
assert_eq!(t.just_finished(), false);
assert!(!t.finished());
assert!(!t.just_finished());
assert_eq!(t.times_finished(), 0);
assert_eq!(t.percent(), 0.625);
assert_eq!(t.percent_left(), 0.375);
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_dylib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::single_component_path_imports)]

//! Forces dynamic linking of Bevy.
//!
//! Dynamically linking Bevy makes the "link" step much faster. This can be achieved by adding
Expand All @@ -8,5 +10,4 @@

// Force linking of the main bevy crate
#[allow(unused_imports)]
#[allow(clippy::single_component_path_imports)]
use bevy_internal;
5 changes: 5 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ impl Entities {

/// Allocates space for entities previously reserved with `reserve_entity` or
/// `reserve_entities`, then initializes each one using the supplied function.
///
/// # Safety
/// Flush _must_ set the entity location to the correct ArchetypeId for the given Entity
/// each time init is called. This _can_ be ArchetypeId::invalid(), provided the Entity has
/// not been assigned to an Archetype.
pub unsafe fn flush(&mut self, mut init: impl FnMut(Entity, &mut EntityLocation)) {
let free_cursor = self.free_cursor.get_mut();
let current_free_cursor = *free_cursor;
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ mod tests {
run_system(&mut world, sys.system());

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

#[test]
Expand Down Expand Up @@ -353,7 +353,7 @@ mod tests {
}

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

#[test]
Expand All @@ -371,7 +371,7 @@ mod tests {
);

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

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

#[test]
Expand Down
10 changes: 4 additions & 6 deletions crates/bevy_render/src/camera/visible_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,12 @@ mod rendering_mask_tests {
"default masks match each other"
);

assert_eq!(
RenderLayers::layer(0).intersects(&RenderLayers::layer(1)),
false,
assert!(
!RenderLayers::layer(0).intersects(&RenderLayers::layer(1)),
"masks with differing layers do not match"
);
assert_eq!(
RenderLayers(0).intersects(&RenderLayers(0)),
false,
assert!(
!RenderLayers(0).intersects(&RenderLayers(0)),
"empty masks don't match"
);
assert_eq!(
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_tasks/src/countdown_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ mod tests {
let listener3 = event.listen();

// Verify that we are still blocked
assert_eq!(
false,
listener2.wait_timeout(instant::Duration::from_millis(10))
);
assert!(!listener2.wait_timeout(instant::Duration::from_millis(10)));

// Notify all and verify the remaining listener is notified
event.notify(std::usize::MAX);
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_transform/src/hierarchy/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ mod tests {

{
let children = world.get::<Children>(grandparent_entity).unwrap();
assert_eq!(
children.iter().any(|&i| i == parent_entity),
false,
assert!(
!children.iter().any(|&i| i == parent_entity),
"grandparent should no longer know about its child which has been removed"
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_window/src/raw_window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl RawWindowHandleWrapper {
/// have constraints on where/how this handle can be used. For example, some platforms don't support doing window
/// operations off of the main thread. The caller must ensure the [`RawWindowHandle`] is only used in valid contexts.
pub unsafe fn get_handle(&self) -> HasRawWindowHandleWrapper {
HasRawWindowHandleWrapper(self.0.clone())
HasRawWindowHandleWrapper(self.0)
}
}

Expand All @@ -32,6 +32,6 @@ pub struct HasRawWindowHandleWrapper(RawWindowHandle);
// SAFE: the caller has validated that this is a valid context to get RawWindowHandle
unsafe impl HasRawWindowHandle for HasRawWindowHandleWrapper {
fn raw_window_handle(&self) -> RawWindowHandle {
self.0.clone()
self.0
}
}
6 changes: 1 addition & 5 deletions crates/crevice/crevice-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ impl EmitOptions {

// For testing purposes, we can optionally generate type layout
// information using the type-layout crate.
let type_layout_derive = if cfg!(feature = "test_type_layout") {
quote!(#[derive(::type_layout::TypeLayout)])
} else {
quote!()
};
let type_layout_derive = quote!();

quote! {
#[allow(non_snake_case)]
Expand Down
2 changes: 2 additions & 0 deletions crates/crevice/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::all)]

/*!
[![GitHub CI Status](https://github.com/LPGhatguy/crevice/workflows/CI/badge.svg)](https://github.com/LPGhatguy/crevice/actions)
[![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice)
Expand Down
2 changes: 1 addition & 1 deletion examples/2d/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {

fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
_asset_server: Res<AssetServer>,
// mut materials: ResMut<Assets<ColorMaterial>>,
) {
// let texture_handle = asset_server.load("branding/icon.png");
Expand Down
8 changes: 4 additions & 4 deletions examples/tools/bevymark_pipelined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy::{
use rand::Rng;

const BIRDS_PER_SECOND: u32 = 10000;
const BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0);
const _BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0);
const GRAVITY: f32 = -9.8 * 100.0;
const MAX_VELOCITY: f32 = 750.;
const BIRD_SCALE: f32 = 0.15;
Expand Down Expand Up @@ -66,8 +66,8 @@ struct BirdTexture(Handle<Image>);

fn setup(
mut commands: Commands,
window: Res<WindowDescriptor>,
mut counter: ResMut<BevyCounter>,
_window: Res<WindowDescriptor>,
_counter: ResMut<BevyCounter>,
asset_server: Res<AssetServer>,
) {
// spawn_birds(&mut commands, &window, &mut counter, 10);
Expand Down Expand Up @@ -129,7 +129,7 @@ fn setup(
#[allow(clippy::too_many_arguments)]
fn mouse_handler(
mut commands: Commands,
asset_server: Res<AssetServer>,
_asset_server: Res<AssetServer>,
time: Res<Time>,
mouse_button_input: Res<Input<MouseButton>>,
window: Res<WindowDescriptor>,
Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_pbr2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use bevy_render2::{

pub mod draw_3d_graph {
pub mod node {
pub const SHADOW_PASS: &'static str = "shadow_pass";
pub const SHADOW_PASS: &str = "shadow_pass";
}
}

Expand Down
10 changes: 5 additions & 5 deletions pipelined/bevy_pbr2/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn extract_lights(
intensity: light.intensity,
range: light.range,
radius: light.radius,
transform: transform.clone(),
transform: *transform,
});
}
}
Expand Down Expand Up @@ -341,8 +341,8 @@ pub fn prepare_lights(
// premultiply color by intensity
// we don't use the alpha at all, so no reason to multiply only [0..3]
color: (light.color.as_rgba_linear() * light.intensity).into(),
radius: light.radius.into(),
position: light.transform.translation.into(),
radius: light.radius,
position: light.transform.translation,
inverse_square_range: 1.0 / (light.range * light.range),
near: 0.1,
far: light.range,
Expand All @@ -360,7 +360,7 @@ pub fn prepare_lights(
aspect: TextureAspect::All,
base_mip_level: 0,
mip_level_count: None,
base_array_layer: 0 as u32,
base_array_layer: 0,
array_layer_count: None,
});

Expand Down Expand Up @@ -412,7 +412,7 @@ impl Node for ShadowPassNode {
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.get_input_entity(Self::IN_VIEW)?;
if let Some(view_lights) = self.main_view_query.get_manual(world, view_entity).ok() {
if let Ok(view_lights) = self.main_view_query.get_manual(world, view_entity) {
for view_light_entity in view_lights.lights.iter().copied() {
let (view_light, shadow_phase) = self
.view_light_query
Expand Down
5 changes: 3 additions & 2 deletions pipelined/bevy_pbr2/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ impl FromWorld for PbrShaders {
};
PbrShaders {
pipeline,
shader_module,
view_layout,
material_layout,
mesh_layout,
shader_module,
dummy_white_gpu_image,
}
}
Expand Down Expand Up @@ -466,6 +466,7 @@ fn image_handle_to_view_sampler<'a>(
)
}

#[allow(clippy::too_many_arguments)]
pub fn queue_meshes(
mut commands: Commands,
draw_functions: Res<DrawFunctions>,
Expand All @@ -488,7 +489,7 @@ pub fn queue_meshes(
) {
let mesh_meta = mesh_meta.into_inner();

if view_meta.uniforms.len() == 0 {
if view_meta.uniforms.is_empty() {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/camera/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn extract_cameras(
},
ExtractedView {
projection: camera.projection_matrix,
transform: transform.clone(),
transform: *transform,
width: window.physical_width(),
height: window.physical_height(),
},
Expand Down
Loading

0 comments on commit 9a79b79

Please sign in to comment.