From fb093bac476bc0752962beff285c3607fc09dd9e Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 13 Sep 2023 20:22:42 +0700 Subject: [PATCH] Allow `clippy::type_complexity` in more places. --- crates/bevy_asset/src/lib.rs | 2 ++ docs/linters.md | 3 +-- examples/3d/anti_aliasing.rs | 4 ++++ examples/3d/shadow_caster_receiver.rs | 4 ++++ examples/3d/ssao.rs | 4 ++++ examples/ecs/custom_query_param.rs | 4 ++++ examples/ecs/state.rs | 4 ++++ examples/games/alien_cake_addict.rs | 4 ++++ examples/games/game_menu.rs | 4 ++++ examples/input/text_input.rs | 4 ++++ examples/mobile/src/lib.rs | 4 ++++ examples/tools/scene_viewer/scene_viewer_plugin.rs | 4 ++++ examples/ui/button.rs | 4 ++++ tools/ci/src/main.rs | 1 - 14 files changed, 47 insertions(+), 3 deletions(-) diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index fcf4b09f19ba31..18da8603eecdaf 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + pub mod io; pub mod meta; pub mod processor; diff --git a/docs/linters.md b/docs/linters.md index 307e68cb7970dc..d53a4c59cd5ef8 100644 --- a/docs/linters.md +++ b/docs/linters.md @@ -13,13 +13,12 @@ cargo fmt --all Can be automatically run with [`cargo run -p ci`](../tools/ci) (which also runs other checks) or manually with this command: ```bash -cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity +cargo clippy --workspace --all-targets --all-features -- -D warnings ``` Explanation: * `-D warnings`: No warnings are allowed in the codebase. -* `-A clippy::type_complexity`: type complexity must be ignored because we use huge templates for queries. ## [super-linter](https://github.com/github/super-linter) diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index a297858401680e..bf3677918d8518 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -1,5 +1,9 @@ //! This example compares MSAA (Multi-Sample Anti-aliasing), FXAA (Fast Approximate Anti-aliasing), and TAA (Temporal Anti-aliasing). +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use std::f32::consts::PI; use bevy::{ diff --git a/examples/3d/shadow_caster_receiver.rs b/examples/3d/shadow_caster_receiver.rs index 922aa3b02137ee..e97d29fd09b159 100644 --- a/examples/3d/shadow_caster_receiver.rs +++ b/examples/3d/shadow_caster_receiver.rs @@ -1,5 +1,9 @@ //! Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use std::f32::consts::PI; use bevy::{ diff --git a/examples/3d/ssao.rs b/examples/3d/ssao.rs index 415741a8e59632..a175900763efde 100644 --- a/examples/3d/ssao.rs +++ b/examples/3d/ssao.rs @@ -1,5 +1,9 @@ //! A scene showcasing screen space ambient occlusion. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{ core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin}, pbr::{ diff --git a/examples/ecs/custom_query_param.rs b/examples/ecs/custom_query_param.rs index 8cc5f172073b95..81a6d8cfa718a8 100644 --- a/examples/ecs/custom_query_param.rs +++ b/examples/ecs/custom_query_param.rs @@ -12,6 +12,10 @@ //! //! For more details on the `WorldQuery` derive macro, see the trait documentation. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{ecs::query::WorldQuery, prelude::*}; use std::fmt::Debug; diff --git a/examples/ecs/state.rs b/examples/ecs/state.rs index c4603196f461b8..5b220c7851efa4 100644 --- a/examples/ecs/state.rs +++ b/examples/ecs/state.rs @@ -5,6 +5,10 @@ //! //! In this case, we're transitioning from a `Menu` state to an `InGame` state. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::prelude::*; fn main() { diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 12b2753229b581..f01769f2fc1c77 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -1,5 +1,9 @@ //! Eat the cakes. Eat them all. An example 3D game. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use std::f32::consts::PI; use bevy::prelude::*; diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index c6ee0a6e52e2a4..4beaa03c603f10 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -2,6 +2,10 @@ //! change some settings or quit. There is no actual game, it will just display the current //! settings for 5 seconds before going back to the menu. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::prelude::*; const TEXT_COLOR: Color = Color::rgb(0.9, 0.9, 0.9); diff --git a/examples/input/text_input.rs b/examples/input/text_input.rs index 8e317157f63341..fa33e3dae8cf14 100644 --- a/examples/input/text_input.rs +++ b/examples/input/text_input.rs @@ -4,6 +4,10 @@ //! Clicking toggle IME (Input Method Editor) support, but the font used as limited support of characters. //! You should change the provided font with another one to test other languages input. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{input::keyboard::KeyboardInput, prelude::*}; fn main() { diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index e08e6804705ccb..5dcac8aceb6774 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -1,3 +1,7 @@ +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{input::touch::TouchPhase, prelude::*, window::WindowMode}; // the `bevy_main` proc_macro generates the required boilerplate for iOS and Android diff --git a/examples/tools/scene_viewer/scene_viewer_plugin.rs b/examples/tools/scene_viewer/scene_viewer_plugin.rs index 3dd6b1273c8345..3a41efe069cb0c 100644 --- a/examples/tools/scene_viewer/scene_viewer_plugin.rs +++ b/examples/tools/scene_viewer/scene_viewer_plugin.rs @@ -3,6 +3,10 @@ //! - Copy the code for the `SceneViewerPlugin` and add the plugin to your App. //! - Insert an initialized `SceneHandle` resource into your App's `AssetServer`. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{ asset::LoadState, gltf::Gltf, input::common_conditions::input_just_pressed, prelude::*, scene::InstanceId, diff --git a/examples/ui/button.rs b/examples/ui/button.rs index 27ab4a19a12d59..5e37068572b6ae 100644 --- a/examples/ui/button.rs +++ b/examples/ui/button.rs @@ -1,6 +1,10 @@ //! This example illustrates how to create a button that changes color and text based on its //! interaction state. +// This lint usually gives bad advice in the context of Bevy -- hiding complex queries behind +// type aliases tends to obfuscate code while offering no improvement in code cleanliness. +#![allow(clippy::type_complexity)] + use bevy::{prelude::*, winit::WinitSettings}; fn main() { diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 703c1e062bd95f..9f8a9c0eb1e127 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -18,7 +18,6 @@ bitflags! { } const CLIPPY_FLAGS: [&str; 7] = [ - "-Aclippy::type_complexity", "-Wclippy::doc_markdown", "-Wclippy::redundant_else", "-Wclippy::match_same_arms",