diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dfd83e..80896234 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,9 @@ on: env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-D warnings" + # RUSTFLAGS can't catch Cargo's own lints (like unused dependencies), + # so fail the build on those separately. + CARGO_BUILD_WARNINGS: "deny" # Disable all permissions by default (https://docs.zizmor.sh/audits/#excessive-permissions) permissions: {} diff --git a/Cargo.lock b/Cargo.lock index ea20d903..d0c3e8c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3401,17 +3401,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-aux" -version = "4.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "207f67b28fe90fb596503a9bf0bf1ea5e831e21307658e177c5dfcdfc3ab8a0a" -dependencies = [ - "serde", - "serde-value", - "serde_json", -] - [[package]] name = "serde-value" version = "0.7.0" @@ -4171,7 +4160,6 @@ dependencies = [ "reqwest 0.13.5", "rustls", "serde", - "serde-aux", "serde_json", "serde_qs", "sqlx", diff --git a/Cargo.toml b/Cargo.toml index 2fdd5978..c8248e53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,6 @@ argon2 = "0.6.0" axum = { version = "0.8.8", features = ["macros", "tracing"] } axum-server = { version = "0.8.0", features = ["tls-rustls-no-provider"] } clap = { version = "4.6.0", features = ["derive", "env", "cargo"] } -fake = { version = "5.1.0", default-features = false } friendly-zoo = "1.1.0" garde = { version = "0.23.0", default-features = false, features = [ "derive", @@ -94,7 +93,6 @@ listenfd = "1.0.2" mime_guess = "2.0.5" rand = { version = "0.10.1" } serde = "1.0.228" -serde-aux = { version = "4.7.0", default-features = false } serde_json = "1.0.149" serde_qs = { version = "1.1.0", features = ["axum"] } sqlx = { version = "0.8.6", features = [ @@ -125,7 +123,6 @@ tower-http = { version = "0.7.1", features = ["tracing", "trace"] } tracing = "0.1.44" tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } uuid = { version = "1.22.0", features = ["v4", "serde"] } -visdom = "1.0.4" rustls = { version = "0.23.37", default-features = false, features = ["ring"] } htmf = { git = "https://github.com/raffomania/htmf", features = [ "pretty-print", @@ -139,7 +136,6 @@ async-trait = "0.1.89" chrono = "0.4.44" redact = "0.1.11" enum_delegate = "0.2.0" -tower-livereload = "0.10.3" reqwest = { version = "0.13.2", features = [ "brotli", "gzip", @@ -156,6 +152,8 @@ derive_more = { version = "2.1.1", features = ["debug"] } # For passing LogLevels to sqlx log = "0.4.29" quick-xml = { version = "0.42.0", features = ["serialize"] } +tower-livereload = { version = "0.10.3" } +fake = { version = "5.1.0", default-features = false } [patch.crates-io] activitypub_federation = { git = "https://github.com/raffomania/activitypub-federation-rust", branch = "update-axum" } @@ -167,6 +165,7 @@ regex = "1.12.3" [dev-dependencies] http-body-util = "0.1.3" +visdom = "1.0.4" serde_json = "1.0.149" test-log = { version = "0.2.19", features = [ "trace", diff --git a/Justfile b/Justfile index d0943547..50a9e1c7 100644 --- a/Justfile +++ b/Justfile @@ -207,6 +207,8 @@ ci-fast: check-database-info check-sbom && reuse-lint set -euo pipefail export RUSTFLAGS="-D warnings" + # Match CI: turn Cargo's own lint warnings into errors + export CARGO_BUILD_WARNINGS="deny" # Prevent full recompilations in the normal dev setup which has different rustflags export CARGO_TARGET_DIR="target_ci" export CARGO_TERM_QUIET="true" diff --git a/src/main.rs b/src/main.rs index 257c3eef..b2999c4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,11 @@ mod tracing_filter; mod tracing_format; use anyhow::Result; +// Shut up the cargo unused dependencies lint for this specific dependency. +// It's only used in development and there's no good alternative to fix this. +#[cfg(not(debug_assertions))] +#[expect(unused_imports)] +use fake; #[tokio::main] async fn main() -> Result<()> { diff --git a/src/routes/bookmarks.rs b/src/routes/bookmarks.rs index 8681470a..5c24e917 100644 --- a/src/routes/bookmarks.rs +++ b/src/routes/bookmarks.rs @@ -14,8 +14,7 @@ use uuid::Uuid; use crate::{ authentication::AuthUser, db::{self, bookmarks::InsertBookmark}, - extract::{self}, - federation, + extract, federation, form_errors::FormErrors, forms::{self, bookmarks::CreateBookmark}, htmf_response::HtmfResponse, diff --git a/src/routes/federation.rs b/src/routes/federation.rs index 76eccdbe..6489467b 100644 --- a/src/routes/federation.rs +++ b/src/routes/federation.rs @@ -19,8 +19,7 @@ use url::Url; use uuid::Uuid; use crate::{ - db::{self}, - extract, + db, extract, federation::{self, person::Person}, response_error::ResponseResult, server::AppState, diff --git a/src/routes/links.rs b/src/routes/links.rs index c5a1d5eb..f0860aef 100644 --- a/src/routes/links.rs +++ b/src/routes/links.rs @@ -14,7 +14,7 @@ use uuid::Uuid; use crate::{ authentication::AuthUser, db::{self, LinkDestination}, - extract::{self}, + extract, form_errors::FormErrors, forms::links::{CreateLink, PartialCreateLink}, htmf_response::HtmfResponse, diff --git a/src/routes/lists.rs b/src/routes/lists.rs index 7c98da30..c706d4b9 100644 --- a/src/routes/lists.rs +++ b/src/routes/lists.rs @@ -11,8 +11,7 @@ use uuid::Uuid; use crate::{ atom::{self, Feed}, authentication::AuthUser, - db::{self}, - extract::{self}, + db, extract, form_errors::FormErrors, forms::{ self, diff --git a/src/routes/search.rs b/src/routes/search.rs index 196edf6a..170c193d 100644 --- a/src/routes/search.rs +++ b/src/routes/search.rs @@ -3,14 +3,8 @@ use serde::{Deserialize, Serialize}; use serde_qs::web::QsQuery; use crate::{ - authentication::AuthUser, - db::{self}, - extract, - htmf_response::HtmfResponse, - response_error::ResponseResult, - server::AppState, - views, - views::layout, + authentication::AuthUser, db, extract, htmf_response::HtmfResponse, + response_error::ResponseResult, server::AppState, views, views::layout, }; pub fn router() -> Router { let router: Router = Router::new(); diff --git a/src/routes/users.rs b/src/routes/users.rs index 575fd3a7..89889fb8 100644 --- a/src/routes/users.rs +++ b/src/routes/users.rs @@ -14,10 +14,10 @@ use crate::{ authentication::{self, AuthUser}, db, db::sessions::Session, - extract::{self}, + extract, forms::users::{CreateOidcUser, Login, OidcLoginQuery, OidcSelectUsername}, htmf_response::HtmfResponse, - oidc::{self}, + oidc, response_error::{ResponseError, ResponseResult}, server::AppState, session, diff --git a/src/server.rs b/src/server.rs index e09bf7cb..50797c2d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -8,14 +8,10 @@ use listenfd::ListenFd; use sqlx::PgPool; use tower::ServiceBuilder; use tower_http::trace::TraceLayer; +use tower_livereload::LiveReloadLayer; use url::Url; -use crate::{ - archive, - cli::ListenArgs, - db::{self}, - federation, oidc, routes, -}; +use crate::{archive, cli::ListenArgs, db, federation, oidc, routes}; #[derive(Clone)] pub struct AppState { @@ -53,19 +49,10 @@ pub fn app(state: AppState) -> anyhow::Result { .layer(FederationMiddleware::new(state.federation_config.clone())), ); - #[cfg(all(debug_assertions, not(test)))] - { - use tower_livereload::LiveReloadLayer; - - fn not_htmx_request_livereload_predicate( - req: &axum::http::Request, - ) -> bool { - !req.headers().contains_key("hx-request") - } - + if cfg!(all(debug_assertions, not(test))) { router = router .layer(LiveReloadLayer::new().request_predicate(not_htmx_request_livereload_predicate)); - }; + } Ok(router.with_state(state)) } @@ -186,3 +173,8 @@ async fn wipe_all_data(pool: &PgPool) -> anyhow::Result<()> { tx.commit().await?; Ok(()) } + +/// Return true if the given request was not made by htmx. +fn not_htmx_request_livereload_predicate(req: &axum::http::Request) -> bool { + !req.headers().contains_key("hx-request") +} diff --git a/src/tests/federation.rs b/src/tests/federation.rs index 47c58cfd..1984fbfc 100644 --- a/src/tests/federation.rs +++ b/src/tests/federation.rs @@ -3,7 +3,7 @@ use anyhow::Result; use axum::http::StatusCode; use crate::{ - db::{self}, + db, federation::{self, webfinger}, forms::{ bookmarks::CreateBookmark, diff --git a/src/tests/migrations.rs b/src/tests/migrations.rs index 376a8982..e25220cc 100644 --- a/src/tests/migrations.rs +++ b/src/tests/migrations.rs @@ -8,11 +8,7 @@ use sqlx::{Postgres, Row, Transaction, query}; use url::Url; use uuid::Uuid; -use crate::{ - authentication::hash_password, - db::{self}, - forms::ap_users::CreateApUser, -}; +use crate::{authentication::hash_password, db, forms::ap_users::CreateApUser}; #[test_log::test(tokio::test)] async fn generate_missing_ap_users_migration() -> Result<()> { diff --git a/src/tests/search.rs b/src/tests/search.rs index 3bff15cd..badfeb5f 100644 --- a/src/tests/search.rs +++ b/src/tests/search.rs @@ -6,7 +6,7 @@ use crate::{ self, bookmarks::{InsertBookmark, UpdateBookmark}, }, - routes::search::{self}, + routes::search, tests::util::{request_builder::TestPage, test_app::TestApp}, }; diff --git a/ties.cdx.json b/ties.cdx.json index d2447726..626a88d7 100644 --- a/ties.cdx.json +++ b/ties.cdx.json @@ -4645,37 +4645,6 @@ "type": "library", "version": "0.40.1" }, - { - "author": "ganmin ", - "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#htmlentity@1.3.2", - "description": "A library for encoding and decoding HTML entities.", - "externalReferences": [ - { - "type": "website", - "url": "https://github.com/fefit/htmlentity" - }, - { - "type": "vcs", - "url": "https://github.com/fefit/htmlentity" - } - ], - "hashes": [ - { - "alg": "SHA-256", - "content": "dd54ae4f69adcc1a43637dcff230852832c3ad50df31a90e0cb5f001dd441359" - } - ], - "licenses": [ - { - "expression": "MIT" - } - ], - "name": "htmlentity", - "purl": "pkg:cargo/htmlentity@1.3.2", - "scope": "required", - "type": "library", - "version": "1.3.2" - }, { "author": "Carl Lerche , Lucio Franco , Sean McArthur ", "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#http-body-util@0.1.5", @@ -8358,33 +8327,6 @@ "type": "library", "version": "0.8.1" }, - { - "author": "jxz_211 ", - "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#rphtml@0.5.12", - "description": "A html parser written in rust.", - "externalReferences": [ - { - "type": "vcs", - "url": "https://github.com/fefit/rphtml" - } - ], - "hashes": [ - { - "alg": "SHA-256", - "content": "210ae0125aded7fa2ed94408d98958e2f4f65919692455510942d483b354678c" - } - ], - "licenses": [ - { - "expression": "MIT" - } - ], - "name": "rphtml", - "purl": "pkg:cargo/rphtml@0.5.12", - "scope": "required", - "type": "library", - "version": "0.5.12" - }, { "author": "RustCrypto Developers, dignifiedquire ", "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#rsa@0.9.10", @@ -8867,37 +8809,6 @@ "type": "library", "version": "1.0.28" }, - { - "author": "Victor Polevoy ", - "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#serde-aux@4.7.0", - "description": "A serde crate's auxiliary library", - "externalReferences": [ - { - "type": "documentation", - "url": "https://docs.rs/serde-aux" - }, - { - "type": "vcs", - "url": "https://github.com/iddm/serde-aux" - } - ], - "hashes": [ - { - "alg": "SHA-256", - "content": "207f67b28fe90fb596503a9bf0bf1ea5e831e21307658e177c5dfcdfc3ab8a0a" - } - ], - "licenses": [ - { - "expression": "MIT" - } - ], - "name": "serde-aux", - "purl": "pkg:cargo/serde-aux@4.7.0", - "scope": "required", - "type": "library", - "version": "4.7.0" - }, { "author": "arcnmx", "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#serde-value@0.7.0", @@ -11822,41 +11733,6 @@ "type": "library", "version": "0.9.5" }, - { - "author": "jxz_211 ", - "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#visdom@1.0.4", - "description": "A html document syntax and operation library, use APIs similar to jquery, easy to use for web scraping and confused html.", - "externalReferences": [ - { - "type": "documentation", - "url": "https://docs.rs/visdom/" - }, - { - "type": "website", - "url": "https://github.com/fefit/visdom" - }, - { - "type": "vcs", - "url": "https://github.com/fefit/visdom" - } - ], - "hashes": [ - { - "alg": "SHA-256", - "content": "05825914544c75261af9e9da127e891caad6c0a629843da743d0359edcf7437f" - } - ], - "licenses": [ - { - "expression": "MIT" - } - ], - "name": "visdom", - "purl": "pkg:cargo/visdom@1.0.4", - "scope": "required", - "type": "library", - "version": "1.0.4" - }, { "author": "Andrew Gallant ", "bom-ref": "registry+https://github.com/rust-lang/crates.io-index#walkdir@2.5.0", @@ -12530,7 +12406,6 @@ "registry+https://github.com/rust-lang/crates.io-index#reqwest@0.13.5", "registry+https://github.com/rust-lang/crates.io-index#rustls@0.23.46", "registry+https://github.com/rust-lang/crates.io-index#serde@1.0.229", - "registry+https://github.com/rust-lang/crates.io-index#serde-aux@4.7.0", "registry+https://github.com/rust-lang/crates.io-index#serde_json@1.0.154", "registry+https://github.com/rust-lang/crates.io-index#serde_qs@1.1.3", "registry+https://github.com/rust-lang/crates.io-index#sqlx@0.8.6", @@ -12544,7 +12419,6 @@ "registry+https://github.com/rust-lang/crates.io-index#tracing-subscriber@0.3.23", "registry+https://github.com/rust-lang/crates.io-index#url@2.5.8", "registry+https://github.com/rust-lang/crates.io-index#uuid@1.29.0", - "registry+https://github.com/rust-lang/crates.io-index#visdom@1.0.4", "registry+https://github.com/rust-lang/crates.io-index#walkdir@2.5.0" ] }, @@ -13551,14 +13425,6 @@ ], "ref": "registry+https://github.com/rust-lang/crates.io-index#html5ever@0.40.1" }, - { - "dependsOn": [ - "registry+https://github.com/rust-lang/crates.io-index#anyhow@1.0.104", - "registry+https://github.com/rust-lang/crates.io-index#lazy_static@1.5.0", - "registry+https://github.com/rust-lang/crates.io-index#thiserror@1.0.69" - ], - "ref": "registry+https://github.com/rust-lang/crates.io-index#htmlentity@1.3.2" - }, { "dependsOn": [ "registry+https://github.com/rust-lang/crates.io-index#bytes@1.11.1", @@ -14471,14 +14337,6 @@ ], "ref": "registry+https://github.com/rust-lang/crates.io-index#ron@0.8.1" }, - { - "dependsOn": [ - "registry+https://github.com/rust-lang/crates.io-index#htmlentity@1.3.2", - "registry+https://github.com/rust-lang/crates.io-index#lazy_static@1.5.0", - "registry+https://github.com/rust-lang/crates.io-index#thiserror@1.0.69" - ], - "ref": "registry+https://github.com/rust-lang/crates.io-index#rphtml@0.5.12" - }, { "dependsOn": [ "registry+https://github.com/rust-lang/crates.io-index#const-oid@0.9.6", @@ -14592,14 +14450,6 @@ { "ref": "registry+https://github.com/rust-lang/crates.io-index#semver@1.0.28" }, - { - "dependsOn": [ - "registry+https://github.com/rust-lang/crates.io-index#serde@1.0.229", - "registry+https://github.com/rust-lang/crates.io-index#serde-value@0.7.0", - "registry+https://github.com/rust-lang/crates.io-index#serde_json@1.0.154" - ], - "ref": "registry+https://github.com/rust-lang/crates.io-index#serde-aux@4.7.0" - }, { "dependsOn": [ "registry+https://github.com/rust-lang/crates.io-index#ordered-float@2.10.1", @@ -15356,15 +15206,6 @@ { "ref": "registry+https://github.com/rust-lang/crates.io-index#version_check@0.9.5" }, - { - "dependsOn": [ - "registry+https://github.com/rust-lang/crates.io-index#lazy_static@1.5.0", - "registry+https://github.com/rust-lang/crates.io-index#regex@1.13.1", - "registry+https://github.com/rust-lang/crates.io-index#rphtml@0.5.12", - "registry+https://github.com/rust-lang/crates.io-index#thiserror@1.0.69" - ], - "ref": "registry+https://github.com/rust-lang/crates.io-index#visdom@1.0.4" - }, { "dependsOn": [ "registry+https://github.com/rust-lang/crates.io-index#same-file@1.0.6"