From cf09716727fd581242f9d8f1ea0abaf59e443e76 Mon Sep 17 00:00:00 2001 From: prk-Jr Date: Thu, 22 Jan 2026 16:40:55 +0530 Subject: [PATCH 1/7] Configure clippy lints Setup workspace lints to enforce coding standards and catch issues during development. 303 tests pass. Resolves: #189 --- .github/workflows/format.yml | 4 ++-- Cargo.toml | 20 +++++++++++++++++++ clippy.toml | 12 +++++++++++ crates/common/Cargo.toml | 3 +++ crates/common/build.rs | 2 ++ crates/common/src/cookies.rs | 1 + crates/common/src/creative.rs | 2 ++ crates/common/src/fastly_storage.rs | 1 + crates/common/src/geo.rs | 2 ++ crates/common/src/html_processor.rs | 5 ++++- crates/common/src/http_util.rs | 10 ++++++++-- crates/common/src/integrations/didomi.rs | 1 + crates/common/src/integrations/lockr.rs | 6 ++++-- .../integrations/nextjs/html_post_process.rs | 1 + crates/common/src/integrations/nextjs/mod.rs | 1 + crates/common/src/integrations/nextjs/rsc.rs | 8 +++++--- .../integrations/nextjs/rsc_placeholders.rs | 1 + .../integrations/nextjs/script_rewriter.rs | 1 + crates/common/src/integrations/permutive.rs | 7 ++++--- crates/common/src/integrations/prebid.rs | 1 + crates/common/src/integrations/registry.rs | 11 ++++++++++ crates/common/src/integrations/testlight.rs | 2 +- crates/common/src/openrtb.rs | 2 +- .../common/src/request_signing/discovery.rs | 1 + .../common/src/request_signing/endpoints.rs | 6 ++++++ crates/common/src/request_signing/jwks.rs | 3 +++ crates/common/src/request_signing/rotation.rs | 2 ++ crates/common/src/settings.rs | 5 ++++- crates/common/src/streaming_processor.rs | 10 ++++++---- crates/common/src/streaming_replacer.rs | 7 +++++-- crates/common/src/test_support.rs | 2 ++ crates/common/src/tsjs.rs | 2 ++ crates/fastly/Cargo.toml | 3 +++ crates/js/Cargo.toml | 3 +++ crates/js/build.rs | 2 ++ crates/js/src/bundle.rs | 6 ++++++ 36 files changed, 134 insertions(+), 22 deletions(-) create mode 100644 clippy.toml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 45ab1aea..8021f2c5 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -41,8 +41,8 @@ jobs: - name: Run cargo fmt uses: actions-rust-lang/rustfmt@v1 - - name: Run cargo clipply - run: cargo clippy --all-targets --all-features + - name: Run cargo clippy + run: cargo clippy --all-targets --all-features -- -D warnings format-typescript: runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 9545c847..9af3807f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,26 @@ default-members = [ "crates/fastly", ] +[workspace.lints.clippy] +# Correctness +unwrap_used = "warn" +expect_used = "allow" +panic = "warn" + +# Style +module_name_repetitions = "allow" +must_use_candidate = "warn" + +# Pedantic (selective) +doc_markdown = "warn" +# missing_errors_doc = "warn" +# missing_panics_doc = "warn" + +# Restriction (selective) +print_stdout = "warn" +print_stderr = "warn" +dbg_macro = "warn" + [profile.release] debug = 1 diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..17f78bc6 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,12 @@ +# Clippy configuration for trusted-server +# See: https://doc.rust-lang.org/clippy/configuration.html + +# Cognitive complexity threshold for functions +cognitive-complexity-threshold = 30 + +# Maximum number of lines in a function +too-many-lines-threshold = 200 + +# Allow module name repetitions in reexports +allow-expect-in-tests = true +allow-unwrap-in-tests = true diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ab3058ce..17a0e04b 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -8,6 +8,9 @@ edition = "2021" publish = false license = "Apache-2.0" +[lints] +workspace = true + [dependencies] base64 = { workspace = true } brotli = { workspace = true } diff --git a/crates/common/build.rs b/crates/common/build.rs index d7b020b2..c8facdda 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -1,3 +1,5 @@ +#![allow(clippy::unwrap_used, clippy::panic)] + #[path = "src/error.rs"] mod error; diff --git a/crates/common/src/cookies.rs b/crates/common/src/cookies.rs index de78b109..48f397bb 100644 --- a/crates/common/src/cookies.rs +++ b/crates/common/src/cookies.rs @@ -62,6 +62,7 @@ pub fn handle_request_cookies( /// /// Generates a properly formatted cookie with security attributes /// for storing the synthetic ID. +#[must_use] pub fn create_synthetic_cookie(settings: &Settings, synthetic_id: &str) -> String { format!( "synthetic_id={}; Domain={}; Path=/; Secure; SameSite=Lax; Max-Age={}", diff --git a/crates/common/src/creative.rs b/crates/common/src/creative.rs index 02041dd9..7cf1cad5 100644 --- a/crates/common/src/creative.rs +++ b/crates/common/src/creative.rs @@ -291,6 +291,7 @@ pub(super) fn proxied_attr_value(settings: &Settings, attr_val: Option) /// Rewrite a full CSS stylesheet body by normalizing url(...) references to the /// unified first-party proxy. Relative URLs are left unchanged. +#[must_use] pub fn rewrite_css_body(css: &str, settings: &Settings) -> String { rewrite_style_urls(css, settings) } @@ -301,6 +302,7 @@ pub fn rewrite_css_body(css: &str, settings: &Settings) -> String { /// - `