Skip to content

Commit

Permalink
refactor: workspace lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed Feb 23, 2025
1 parent 7303f89 commit 60807ee
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 100 deletions.
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,20 @@ edition = "2024"
repository = "https://github.com/Nugine/s3s"
license = "Apache-2.0"

[workspace.lints.rust]
unsafe_code = "forbid"

[workspace.lints.clippy]
# deny
all = { level = "deny", priority = -1 }
pedantic = { level = "deny", priority = -1 }
cargo = { level = "deny", priority = -1 }
self_named_module_files = "deny"
# warn
dbg_macro = "warn"
# allow
module_name_repetitions = "allow"
multiple_crate_versions = "allow"

[profile.release]
debug = "line-tables-only"
3 changes: 3 additions & 0 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.0.0"
edition = "2021"
publish = false

[lints]
workspace = true

[dependencies]
codegen-writer = "0.2.0"
heck = "0.5.0"
Expand Down
13 changes: 0 additions & 13 deletions codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::pedantic, //
)]
#![warn(
clippy::dbg_macro, //
)]
#![allow(
clippy::single_match_else, //
clippy::wildcard_imports,
clippy::match_same_arms,
clippy::let_underscore_untyped,
)]
#![allow(
unknown_lints,
// FIXME: https://github.com/rust-lang/rust-clippy/issues/13885
clippy::literal_string_with_formatting_args,
)]

mod v1;
mod v2;
Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-aws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
async-trait = "0.1.83"
aws-sdk-s3 = "1.56.0"
Expand Down
6 changes: 0 additions & 6 deletions crates/s3s-aws/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
)]
#![allow(
clippy::module_name_repetitions,//
clippy::match_same_arms, //
Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
s3s-test = { version = "0.11.0-dev", path = "../s3s-test" }
tracing = "0.1.40"
Expand Down
12 changes: 0 additions & 12 deletions crates/s3s-e2e/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
clippy::self_named_module_files, //
)]
#![warn(
clippy::dbg_macro, //
)]
#![allow(
clippy::module_name_repetitions, //
clippy::missing_errors_doc, // TODO
clippy::missing_panics_doc, // TODO
clippy::multiple_crate_versions, // TODO: check later
clippy::wildcard_imports,
)]

Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[[bin]]
name = "s3s-fs"
required-features = ["binary"]
Expand Down
6 changes: 0 additions & 6 deletions crates/s3s-fs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
)]
#![allow(
clippy::wildcard_imports,
clippy::missing_errors_doc, // TODO: docs
Expand Down
4 changes: 0 additions & 4 deletions crates/s3s-fs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#![forbid(unsafe_code)]
#![deny(clippy::all, clippy::pedantic)]
#![allow(clippy::needless_return)]

use s3s_fs::FileSystem;
use s3s_fs::Result;

Expand Down
17 changes: 6 additions & 11 deletions crates/s3s-fs/tests/it_aws.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::must_use_candidate, //
)]

use s3s::auth::SimpleAuth;
use s3s::host::SingleDomain;
use s3s::service::S3ServiceBuilder;
Expand All @@ -26,7 +20,6 @@ use aws_sdk_s3::types::CompletedPart;
use aws_sdk_s3::types::CreateBucketConfiguration;

use anyhow::Result;
use once_cell::sync::Lazy;
use tokio::sync::Mutex;
use tokio::sync::MutexGuard;
use tracing::{debug, error};
Expand All @@ -48,11 +41,12 @@ fn setup_tracing() {
.pretty()
.with_env_filter(EnvFilter::from_default_env())
.with_test_writer()
.init()
.init();
}

fn config() -> &'static SdkConfig {
static CONFIG: Lazy<SdkConfig> = Lazy::new(|| {
use std::sync::LazyLock;
static CONFIG: LazyLock<SdkConfig> = LazyLock::new(|| {
setup_tracing();

// Fake credentials
Expand Down Expand Up @@ -85,7 +79,8 @@ fn config() -> &'static SdkConfig {
}

async fn serial() -> MutexGuard<'static, ()> {
static LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
use std::sync::LazyLock;
static LOCK: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
LOCK.lock().await
}

Expand Down Expand Up @@ -391,7 +386,7 @@ async fn test_upload_part_copy() -> Result<()> {
assert_eq!(content_length, src_content.len());
assert_eq!(body.as_ref(), src_content.as_bytes());
}
println!("{} CK3", key);
println!("{key} CK3");
{
delete_object(&c, bucket, key).await?;
delete_bucket(&c, bucket).await?;
Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-policy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
indexmap = { version = "2.6.0", features = ["serde"] }
serde = { version = "1.0.210", features = ["derive"] }
Expand Down
14 changes: 0 additions & 14 deletions crates/s3s-policy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
clippy::self_named_module_files, //
)]
#![warn(
clippy::dbg_macro, //
)]
#![allow(
clippy::module_name_repetitions, //
)]

pub mod model;
pub mod pattern;

Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
aws-config = { version = "1.5.8", default-features = false, features = [
"behavior-version-latest",
Expand Down
4 changes: 0 additions & 4 deletions crates/s3s-proxy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#![forbid(unsafe_code)]
#![deny(clippy::all, clippy::pedantic)]
#![allow(clippy::needless_return)]

use s3s::auth::SimpleAuth;
use s3s::host::SingleDomain;
use s3s::service::S3ServiceBuilder;
Expand Down
3 changes: 3 additions & 0 deletions crates/s3s-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[dependencies]
serde = { version = "1.0.210", features = ["derive"] }
tokio = { version = "1.40.0", features = ["full"] }
Expand Down
12 changes: 0 additions & 12 deletions crates/s3s-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
clippy::self_named_module_files, //
)]
#![warn(
clippy::dbg_macro, //
)]
#![allow(
clippy::module_name_repetitions, //
clippy::missing_errors_doc, // TODO
clippy::missing_panics_doc, // TODO
clippy::multiple_crate_versions, // TODO: check later
)]

mod error;
Expand Down
3 changes: 3 additions & 0 deletions crates/s3s/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ edition.workspace = true
repository.workspace = true
license.workspace = true

[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
11 changes: 0 additions & 11 deletions crates/s3s/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![forbid(unsafe_code)]
#![deny(
clippy::all, //
clippy::cargo, //
clippy::pedantic, //
clippy::self_named_module_files, //
)]
#![warn(
clippy::dbg_macro, //
)]
#![allow(
clippy::bool_assert_comparison, // I don't like `assert!(!expression)`. It's very misleading.
clippy::multiple_crate_versions, // Sometimes not fixable
Expand All @@ -19,7 +9,6 @@
clippy::inline_always,
clippy::needless_continue,
)]
#![allow(clippy::needless_return)]

#[macro_use]
mod utils;
Expand Down
4 changes: 2 additions & 2 deletions crates/s3s/src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub async fn call(req: &mut Request, ccx: &CallContext<'_>) -> S3Result<Response
}
Err(err) => {
debug!(op = %op.name(), ?err, "op returns error");
return serialize_error(err, false);
serialize_error(err, false)
}
}
}
Expand All @@ -225,7 +225,7 @@ pub async fn call(req: &mut Request, ccx: &CallContext<'_>) -> S3Result<Response
}),
Err(err) => {
debug!(?err, "custom route returns error");
return serialize_error(err, false);
serialize_error(err, false)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/s3s/tests/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn minio_versioning_configuration() {
return;
}

let xml = r#"
let xml = r"
<VersioningConfiguration>
<Status>Enabled</Status>
<ExcludedPrefixes>
Expand All @@ -308,7 +308,7 @@ fn minio_versioning_configuration() {
</ExcludedPrefixes>
<ExcludeFolders>true</ExcludeFolders>
</VersioningConfiguration>
"#;
";
let val = deserialize::<s3s::dto::VersioningConfiguration>(xml.as_bytes()).unwrap();
test_serde(&val);
}
Expand All @@ -319,7 +319,7 @@ fn minio_delete_replication() {
return;
}

let xml = r#"
let xml = r"
<ReplicationConfiguration>
<Rule>
<ID>cte4oalu3vqltovlh28g</ID>
Expand Down Expand Up @@ -351,7 +351,7 @@ fn minio_delete_replication() {
<Role>
</Role>
</ReplicationConfiguration>
"#;
";
let val = deserialize::<s3s::dto::ReplicationConfiguration>(xml.as_bytes()).unwrap();
test_serde(&val);
}
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fmt:

lint:
uvx ruff check
cargo clippy --all-features --all-targets
cargo clippy --all-features --all-targets --tests --benches

test:
cargo test --all-features
Expand Down

0 comments on commit 60807ee

Please sign in to comment.