Skip to content

Commit

Permalink
chore: add workspace linting configurations for Rust and Clippy
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
  • Loading branch information
simonsan committed Nov 23, 2024
1 parent 01d7a27 commit 910306d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 25 deletions.
59 changes: 59 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/commands/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 10 additions & 11 deletions tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@

use abscissa_core::testing::prelude::*;
use once_cell::sync::Lazy;
use rustic_scheduler::config::RusticSchedulerConfig;

/// Executes your application binary via `cargo run`.
///
/// Storing this value as a [`Lazy`] static ensures that all instances of
/// 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<CmdRunner> = Lazy::new(|| CmdRunner::default());
pub static RUNNER: Lazy<CmdRunner> = 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();
Expand Down Expand Up @@ -81,11 +88,3 @@ pub static RUNNER: Lazy<CmdRunner> = 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");
}

0 comments on commit 910306d

Please sign in to comment.