From 8c99ee1b1fc2c17cda343d9ffbea4255566f4040 Mon Sep 17 00:00:00 2001 From: Pauline Date: Fri, 27 Sep 2024 06:59:27 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20clippy=20lints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pauline --- Cargo.toml | 35 ++++++++++++++++++ apps/desktop/Cargo.toml | 3 ++ .../ui/components/content/FormattedLog.tsx | 4 +- .../ui/components/content/ProviderIcon.tsx | 2 +- packages/core/Cargo.toml | 3 ++ packages/core/src/api/proxy/mod.rs | 5 ++- packages/core/src/lib.rs | 37 ------------------- packages/core/src/store/processor.rs | 24 ++---------- packages/gamemode/Cargo.toml | 3 ++ packages/gamemode/src/lib.rs | 33 ----------------- packages/macros/Cargo.toml | 3 ++ packages/macros/src/lib.rs | 34 ----------------- packages/utils/Cargo.toml | 3 ++ packages/utils/src/lib.rs | 34 ----------------- 14 files changed, 60 insertions(+), 163 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fe98a9c7..e2e7df77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -206,6 +206,41 @@ features = [ ] default-features = false +[workspace.lints.clippy] +all = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +correctness = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +style = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +unnecessary_cast = "warn" +cast_lossless = "warn" +cast_possible_truncation = "warn" +cast_possible_wrap = "warn" +cast_sign_loss = "warn" +dbg_macro = "warn" +deprecated_cfg_attr = "warn" +separated_literal_suffix = "warn" +missing_errors_doc = "allow" +future_not_send = "allow" +module_name_repetitions = "allow" +struct_field_names = "allow" +cast_precision_loss = "allow" +missing_panics_doc = "allow" + +[workspace.lints.rust] +unused_qualifications = "warn" +rust_2018_idioms = { level = "warn", priority = -1 } +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unused_allocation = "warn" +unused_import_braces = "warn" +deprecated = "warn" +deprecated_in_future = "forbid" +unused_must_use = "deny" + [patch.crates-io] # rspc = { git = "https://github.com/oscartbeaumont/rspc", rev = "9f26d6400affdb501837cb023678268ad72feb9b" } # rspc-tauri2 = { git = "https://github.com/specta-rs/tauri2", rev = "6b9419566e2a826fb2a62538c7647f4524ab0fea" } diff --git a/apps/desktop/Cargo.toml b/apps/desktop/Cargo.toml index 8b5c3b40..12eb05c3 100644 --- a/apps/desktop/Cargo.toml +++ b/apps/desktop/Cargo.toml @@ -15,6 +15,9 @@ authors = { workspace = true } name = "onelauncher_gui" crate-type = [ "staticlib", "cdylib", "lib" ] +[lints] +workspace = true + [build-dependencies] tauri-build = { workspace = true } diff --git a/apps/frontend/src/ui/components/content/FormattedLog.tsx b/apps/frontend/src/ui/components/content/FormattedLog.tsx index 12b8ae72..b789dad3 100644 --- a/apps/frontend/src/ui/components/content/FormattedLog.tsx +++ b/apps/frontend/src/ui/components/content/FormattedLog.tsx @@ -1,8 +1,8 @@ +import type { Ref } from '@solid-primitives/refs'; +import type { OnUpdatedEventListenerArgs, OverlayScrollbars } from 'overlayscrollbars'; import { ChevronDownDoubleIcon } from '@untitled-theme/icons-solid'; import { OverlayScrollbarsComponent, type OverlayScrollbarsComponentRef } from 'overlayscrollbars-solid'; import { createEffect, createMemo, createSignal, Index, Show, untrack } from 'solid-js'; -import type { Ref } from '@solid-primitives/refs'; -import type { OnUpdatedEventListenerArgs, OverlayScrollbars } from 'overlayscrollbars'; import Button from '../base/Button'; import styles from './FormattedLog.module.scss'; diff --git a/apps/frontend/src/ui/components/content/ProviderIcon.tsx b/apps/frontend/src/ui/components/content/ProviderIcon.tsx index 4c16a8be..b112319a 100644 --- a/apps/frontend/src/ui/components/content/ProviderIcon.tsx +++ b/apps/frontend/src/ui/components/content/ProviderIcon.tsx @@ -1,6 +1,6 @@ +import type { ManagedPackage, Providers } from '@onelauncher/client/bindings'; import ModrinthImage from '~assets/logos/modrinth.svg?component-solid'; import { type Component, type JSX, Match, Show, splitProps, Switch } from 'solid-js'; -import type { ManagedPackage, Providers } from '@onelauncher/client/bindings'; export function getProviderLogoElement(provider: ManagedPackage | Providers): string | Component { const providerName = (typeof provider === 'string' ? provider : provider.provider)?.toLowerCase() as Lowercase; diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 276d8bac..4037a1eb 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -18,6 +18,9 @@ tauri = [ "dep:tauri", "dep:tauri-specta", "specta" ] specta = [ "dep:specta" ] cli = [ "dep:indicatif" ] +[lints] +workspace = true + [dependencies] # features[default] onelauncher_macros = { workspace = true } diff --git a/packages/core/src/api/proxy/mod.rs b/packages/core/src/api/proxy/mod.rs index 2c4e5904..2f10a1d8 100644 --- a/packages/core/src/api/proxy/mod.rs +++ b/packages/core/src/api/proxy/mod.rs @@ -119,7 +119,10 @@ impl ProxyState { Ok(value.app.get_webview_window("main").unwrap()) } - #[allow(clippy::unused_async, reason = "clippy doesn't take into account the features")] + #[allow( + clippy::unused_async, + reason = "clippy doesn't take into account the features" + )] #[cfg(feature = "tauri")] pub async fn get() -> crate::Result> { Ok(PROXY_STATE.get().ok_or(ProxyError::NotInitialized)?.clone()) diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 8b3c8049..bc756b2a 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -2,43 +2,6 @@ //! //! A library used as a core for our launcher and Rust APIs. -#![warn( - clippy::all, - clippy::pedantic, - clippy::correctness, - clippy::perf, - clippy::style, - clippy::suspicious, - clippy::complexity, - clippy::nursery, - clippy::unwrap_used, - unused_qualifications, - rust_2018_idioms, - trivial_casts, - trivial_numeric_casts, - unused_allocation, - clippy::unnecessary_cast, - clippy::cast_lossless, - clippy::cast_possible_truncation, - clippy::cast_possible_wrap, - clippy::cast_sign_loss, - clippy::dbg_macro, - unused_import_braces, - clippy::deprecated_cfg_attr, - clippy::separated_literal_suffix, - deprecated -)] -#![forbid(deprecated_in_future)] -#![deny(unused_must_use)] -#![allow( - clippy::missing_errors_doc, - clippy::future_not_send, - clippy::module_name_repetitions, - clippy::struct_field_names, - clippy::cast_precision_loss, - clippy::significant_drop_tightening //tmp -)] - #[macro_use] pub mod utils; diff --git a/packages/core/src/store/processor.rs b/packages/core/src/store/processor.rs index fac6d534..9a527249 100644 --- a/packages/core/src/store/processor.rs +++ b/packages/core/src/store/processor.rs @@ -297,13 +297,7 @@ impl Processor { if let Some(process) = self.get(key) { let process = process.clone(); let process = process.write().await; - if process - .current_child - .write() - .await - .try_wait()? - .is_none() - { + if process.current_child.write().await.try_wait()?.is_none() { keys.push(key); } } @@ -334,13 +328,7 @@ impl Processor { if let Some(process) = self.get(key) { let process = process.clone(); let process = process.write().await; - if process - .current_child - .write() - .await - .try_wait()? - .is_none() - { + if process.current_child.write().await.try_wait()?.is_none() { clusters.push(process.cluster_path.clone()); } } @@ -355,13 +343,7 @@ impl Processor { if let Some(process) = self.get(key) { let process = process.clone(); let process = process.write().await; - if process - .current_child - .write() - .await - .try_wait()? - .is_none() - { + if process.current_child.write().await.try_wait()?.is_none() { if let Some(cluster) = cluster::get(&process.cluster_path.clone()).await? { clusters.push(cluster); } diff --git a/packages/gamemode/Cargo.toml b/packages/gamemode/Cargo.toml index e6154353..b24ae4c6 100644 --- a/packages/gamemode/Cargo.toml +++ b/packages/gamemode/Cargo.toml @@ -10,6 +10,9 @@ readme = { workspace = true } homepage = { workspace = true } authors = { workspace = true } +[lints] +workspace = true + [target.'cfg(target_os = "linux")'.dependencies] libc = { workspace = true } diff --git a/packages/gamemode/src/lib.rs b/packages/gamemode/src/lib.rs index 7d31cd48..77969b26 100644 --- a/packages/gamemode/src/lib.rs +++ b/packages/gamemode/src/lib.rs @@ -1,37 +1,4 @@ #![cfg(target_os = "linux")] -#![warn( - clippy::all, - clippy::pedantic, - clippy::correctness, - clippy::perf, - clippy::style, - clippy::suspicious, - clippy::complexity, - clippy::nursery, - clippy::unwrap_used, - unused_qualifications, - rust_2018_idioms, - trivial_casts, - trivial_numeric_casts, - unused_allocation, - clippy::unnecessary_cast, - clippy::cast_lossless, - clippy::cast_possible_truncation, - clippy::cast_possible_wrap, - clippy::cast_sign_loss, - clippy::dbg_macro, - unused_import_braces, - clippy::deprecated_cfg_attr, - clippy::separated_literal_suffix, - deprecated -)] -#![forbid(deprecated_in_future)] -#![deny(unused_must_use)] -#![allow( - clippy::missing_errors_doc, - clippy::future_not_send, - clippy::module_name_repetitions -)] use libc::pid_t; use std::ffi::c_int; diff --git a/packages/macros/Cargo.toml b/packages/macros/Cargo.toml index b6417147..492bb79a 100644 --- a/packages/macros/Cargo.toml +++ b/packages/macros/Cargo.toml @@ -10,6 +10,9 @@ readme = { workspace = true } homepage = { workspace = true } authors = { workspace = true } +[lints] +workspace = true + [lib] proc-macro = true diff --git a/packages/macros/src/lib.rs b/packages/macros/src/lib.rs index ba080f97..87a2687c 100644 --- a/packages/macros/src/lib.rs +++ b/packages/macros/src/lib.rs @@ -1,37 +1,3 @@ -#![warn( - clippy::all, - clippy::pedantic, - clippy::correctness, - clippy::perf, - clippy::style, - clippy::suspicious, - clippy::complexity, - clippy::nursery, - clippy::unwrap_used, - unused_qualifications, - rust_2018_idioms, - trivial_casts, - trivial_numeric_casts, - unused_allocation, - clippy::unnecessary_cast, - clippy::cast_lossless, - clippy::cast_possible_truncation, - clippy::cast_possible_wrap, - clippy::cast_sign_loss, - clippy::dbg_macro, - unused_import_braces, - clippy::deprecated_cfg_attr, - clippy::separated_literal_suffix, - deprecated -)] -#![forbid(deprecated_in_future)] -#![deny(unused_must_use)] -#![allow( - clippy::missing_errors_doc, - clippy::future_not_send, - clippy::module_name_repetitions -)] - use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, ItemFn}; diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index a8075405..9ede110b 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -10,6 +10,9 @@ readme = { workspace = true } homepage = { workspace = true } authors = { workspace = true } +[lints] +workspace = true + [dependencies] onelauncher_prisma = { workspace = true } serde = { workspace = true } diff --git a/packages/utils/src/lib.rs b/packages/utils/src/lib.rs index 17ead8de..19c004f0 100644 --- a/packages/utils/src/lib.rs +++ b/packages/utils/src/lib.rs @@ -5,40 +5,6 @@ //! - [`platform`]: Async utilities for managing OS-specific [`interpulse`] operations and rules. //! - [`io`]: Async wrapper around [`tokio::fs`] and [`std::io::Error`] for our error system. -#![warn( - clippy::all, - clippy::pedantic, - clippy::correctness, - clippy::perf, - clippy::style, - clippy::suspicious, - clippy::complexity, - clippy::nursery, - clippy::unwrap_used, - unused_qualifications, - rust_2018_idioms, - trivial_casts, - trivial_numeric_casts, - unused_allocation, - clippy::unnecessary_cast, - clippy::cast_lossless, - clippy::cast_possible_truncation, - clippy::cast_possible_wrap, - clippy::cast_sign_loss, - clippy::dbg_macro, - unused_import_braces, - clippy::deprecated_cfg_attr, - clippy::separated_literal_suffix, - deprecated -)] -#![forbid(deprecated_in_future)] -#![deny(unused_must_use)] -#![allow( - clippy::missing_errors_doc, - clippy::future_not_send, - clippy::module_name_repetitions -)] - pub mod io; pub mod logging; pub mod platform;