From 910306d8d06c8864e92224d826d3d5bd182d09ab Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Sat, 23 Nov 2024 20:16:48 +0100 Subject: [PATCH] chore: add workspace linting configurations for Rust and Clippy Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- Cargo.toml | 59 ++++++++++++++++++++++++++++++++++++++++++ src/commands.rs | 2 +- src/commands/server.rs | 4 +-- src/lib.rs | 11 -------- tests/acceptance.rs | 21 +++++++-------- 5 files changed, 72 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa12b4f..7d9c9e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,3 +112,62 @@ codegen-units = 1 [profile.dist] inherits = "release" lto = "thin" + +[workspace.lints.rust] +unsafe_code = "forbid" +missing_docs = "warn" +rust_2018_idioms = { level = "warn", priority = -1 } +trivial_casts = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +bad_style = "warn" +dead_code = "allow" # TODO: "warn" +improper_ctypes = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_shorthand_field_patterns = "warn" +no_mangle_generic_items = "warn" +overflowing_literals = "warn" +path_statements = "warn" +patterns_in_fns_without_body = "warn" +trivial_numeric_casts = "warn" +unused_results = "warn" +unused_extern_crates = "warn" +unused_import_braces = "warn" +unconditional_recursion = "warn" +unused = { level = "warn", priority = -1 } +unused_allocation = "warn" +unused_comparisons = "warn" +unused_parens = "warn" +while_true = "warn" +unreachable_pub = "allow" + +[workspace.lints.clippy] +redundant_pub_crate = "allow" +pedantic = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +# expect_used = "warn" # TODO! +# unwrap_used = "warn" # TODO! +enum_glob_use = "warn" +correctness = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +cast_lossless = "warn" +default_trait_access = "warn" +doc_markdown = "warn" +manual_string_new = "warn" +match_same_arms = "warn" +semicolon_if_nothing_returned = "warn" +trivially_copy_pass_by_ref = "warn" +module_name_repetitions = "allow" +# TODO: Remove when Windows support landed +# mostly Windows-related functionality is missing `const` +# as it's only OK(()), but doesn't make it reasonable to +# have a breaking change in the future. They won't be const. +missing_const_for_fn = "allow" +needless_raw_string_hashes = "allow" + +[workspace.lints.rustdoc] +# We run rustdoc with `--document-private-items` so we can document private items +private_intra_doc_links = "allow" diff --git a/src/commands.rs b/src/commands.rs index 3cbc8e0..0a48e85 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -17,7 +17,7 @@ use crate::{ commands::{client::ClientCmd, server::ServerCmd}, config::RusticSchedulerConfig, }; -use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Runnable}; +use abscissa_core::{Command, Configurable, FrameworkError, Runnable}; use std::path::PathBuf; /// RusticScheduler Configuration Filename diff --git a/src/commands/server.rs b/src/commands/server.rs index 51aaf6b..5dbfae0 100644 --- a/src/commands/server.rs +++ b/src/commands/server.rs @@ -24,10 +24,10 @@ use tokio::{ }; use crate::{ - config::{AllBackupOptions, RusticSchedulerConfig}, + config::AllBackupOptions, message::{BackupMessage, BackupResultMessage, ClientMessage, HandshakeMessage, NotifyMessage}, prelude::RUSTIC_SCHEDULER_APP, - scheduler::{Client, ClientStats, Clients, Source, SourceBackupStatus}, + scheduler::{Client, Clients, Source, SourceBackupStatus}, }; /// `server` subcommand diff --git a/src/lib.rs b/src/lib.rs index 377ec18..35d9b55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,17 +4,6 @@ //! //! [Abscissa]: https://github.com/iqlusioninc/abscissa -// Tip: Deny warnings with `RUSTFLAGS="-D warnings"` environment variable in CI - -#![forbid(unsafe_code)] -#![warn( - missing_docs, - rust_2018_idioms, - trivial_casts, - unused_lifetimes, - unused_qualifications -)] - pub mod application; pub mod commands; pub mod config; diff --git a/tests/acceptance.rs b/tests/acceptance.rs index b52f8d7..ea0511a 100644 --- a/tests/acceptance.rs +++ b/tests/acceptance.rs @@ -20,7 +20,6 @@ use abscissa_core::testing::prelude::*; use once_cell::sync::Lazy; -use rustic_scheduler::config::RusticSchedulerConfig; /// Executes your application binary via `cargo run`. /// @@ -28,9 +27,17 @@ use rustic_scheduler::config::RusticSchedulerConfig; /// the runner acquire a mutex when executing commands and inspecting /// exit statuses, serializing what would otherwise be multithreaded /// invocations as `cargo test` executes tests in parallel by default. -pub static RUNNER: Lazy = Lazy::new(|| CmdRunner::default()); +pub static RUNNER: Lazy = Lazy::new(CmdRunner::default); -/// Use `RusticSchedulerConfig::default()` value if no config or args +/// Example of a test which matches a regular expression +#[test] +fn version_no_args() { + let mut runner = RUNNER.clone(); + let mut cmd = runner.arg("--version").capture_stdout().run(); + cmd.stdout().expect_regex(r"\A\w+ [\d\.\-]+\z"); +} + +// /// Use `RusticSchedulerConfig::default()` value if no config or args // #[test] // fn start_no_args() { // let mut runner = RUNNER.clone(); @@ -81,11 +88,3 @@ pub static RUNNER: Lazy = Lazy::new(|| CmdRunner::default()); // cmd.stdout().expect_line("Hello, acceptance test!"); // cmd.wait().unwrap().expect_success(); // } - -/// Example of a test which matches a regular expression -#[test] -fn version_no_args() { - let mut runner = RUNNER.clone(); - let mut cmd = runner.arg("--version").capture_stdout().run(); - cmd.stdout().expect_regex(r"\A\w+ [\d\.\-]+\z"); -}