From 0c92bf959bd6593a21588f8e5b90051467165a2c Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Wed, 18 Dec 2024 21:54:58 +0000 Subject: [PATCH] Make lints pass --- backend/Cargo.toml | 12 ++++++++++++ backend/reconcile/Cargo.toml | 4 +++- backend/reconcile/src/lib.rs | 2 -- backend/sync_lib/Cargo.toml | 4 ++++ backend/sync_lib/src/lib.rs | 2 -- backend/sync_server/Cargo.toml | 3 +++ backend/sync_server/src/errors.rs | 5 ++++- backend/sync_server/src/main.rs | 2 -- backend/sync_server/src/server.rs | 12 ++---------- backend/sync_server/src/server/ping.rs | 4 ++-- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/backend/Cargo.toml b/backend/Cargo.toml index e3ca72a..f797468 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -7,9 +7,21 @@ members = [ "sync_lib" ] +[workspace.lints.clippy] +single_call_fn = "allow" +missing_docs_in_private_items = "allow" +question_mark_used = "allow" +implicit_return = "allow" + + [workspace.dependencies] serde = { version = "1.0.214", default-features = false, features = ["derive"] } thiserror = { version = "1.0.66", default-features = false } uuid = { version = "1.11.0", default-features = false, features = ["v4", "serde"] } log = { version = "0.4.22", default-features = false } anyhow = { version = "1.0.94", features = ["backtrace"] } + +[profile.release] +codegen-units = 1 +lto = true +opt-level = 3 diff --git a/backend/reconcile/Cargo.toml b/backend/reconcile/Cargo.toml index 97bbe11..489e781 100644 --- a/backend/reconcile/Cargo.toml +++ b/backend/reconcile/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] - # optional dependencies serde = { version = "1.0.215", optional = true } @@ -15,3 +14,6 @@ serde = [ "dep:serde" ] insta = "1.41.1" pretty_assertions = "1.4.1" test-case = "3.3.1" + +[lints] +workspace = true diff --git a/backend/reconcile/src/lib.rs b/backend/reconcile/src/lib.rs index 2677f0b..5ffc76c 100644 --- a/backend/reconcile/src/lib.rs +++ b/backend/reconcile/src/lib.rs @@ -1,5 +1,3 @@ -#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)] - mod diffs; mod operation_transformation; mod tokenizer; diff --git a/backend/sync_lib/Cargo.toml b/backend/sync_lib/Cargo.toml index 7dc07b6..15dc961 100644 --- a/backend/sync_lib/Cargo.toml +++ b/backend/sync_lib/Cargo.toml @@ -25,3 +25,7 @@ wasm-bindgen-test = "0.3.34" [features] default = ["console_error_panic_hook"] +wee_alloc = [] + +[lints] +workspace = true \ No newline at end of file diff --git a/backend/sync_lib/src/lib.rs b/backend/sync_lib/src/lib.rs index 63a160d..ff374ac 100644 --- a/backend/sync_lib/src/lib.rs +++ b/backend/sync_lib/src/lib.rs @@ -1,5 +1,3 @@ -#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)] - use core::str; use base64::{engine::general_purpose::STANDARD_NO_PAD, Engine as _}; diff --git a/backend/sync_server/Cargo.toml b/backend/sync_server/Cargo.toml index 50fab5c..2fbfeef 100644 --- a/backend/sync_server/Cargo.toml +++ b/backend/sync_server/Cargo.toml @@ -24,3 +24,6 @@ schemars = { version = "0.8.21", features = ["chrono", "uuid1"] } rand = "0.8.5" axum-extra = { version = "0.9.6", features = ["typed-header"] } tower-http = { version = "0.6.1", features = ["cors"] } + +[lints] +workspace = true diff --git a/backend/sync_server/src/errors.rs b/backend/sync_server/src/errors.rs index 586300b..778a9c5 100644 --- a/backend/sync_server/src/errors.rs +++ b/backend/sync_server/src/errors.rs @@ -26,6 +26,7 @@ pub enum SyncServerError { #[error("Unauthorized: {0}")] Unauthorized(#[source] anyhow::Error), + #[allow(dead_code)] #[error("Permission denied error: {0}")] PermissionDeniedError(#[source] anyhow::Error), } @@ -82,7 +83,9 @@ impl OperationOutput for SyncServerError { type Inner = Self; } -pub const fn init_error(error: anyhow::Error) -> SyncServerError { SyncServerError::InitError(error) } +pub const fn init_error(error: anyhow::Error) -> SyncServerError { + SyncServerError::InitError(error) +} pub fn server_error(error: anyhow::Error) -> SyncServerError { warn!("Server error: {:?}", error); diff --git a/backend/sync_server/src/main.rs b/backend/sync_server/src/main.rs index 8c861c4..f27ef5d 100644 --- a/backend/sync_server/src/main.rs +++ b/backend/sync_server/src/main.rs @@ -1,5 +1,3 @@ -#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)] - mod app_state; mod config; mod consts; diff --git a/backend/sync_server/src/server.rs b/backend/sync_server/src/server.rs index ecc7d4b..d5c7be1 100644 --- a/backend/sync_server/src/server.rs +++ b/backend/sync_server/src/server.rs @@ -8,9 +8,9 @@ use aide::{ }; use anyhow::{Context, Result}; use axum::{ - extract::{DefaultBodyLimit, WebSocketUpgrade}, + extract::DefaultBodyLimit, http::{self, HeaderValue, Method}, - response::{IntoResponse, Response}, + response::IntoResponse, Extension, Json, }; use log::info; @@ -63,7 +63,6 @@ pub async fn create_server(app_state: AppState) -> Result<()> { "/vaults/:vault_id/documents/:document_id", delete(delete_document::delete_document), ) - .api_route("/ws", get(handler)) .route("/", Scalar::new("/api.json").axum_route()) .route("/api.json", axum::routing::get(serve_api)) .layer(DefaultBodyLimit::max( @@ -96,11 +95,4 @@ pub async fn create_server(app_state: AppState) -> Result<()> { .context("Failed to start server") } -async fn handler(ws: WebSocketUpgrade) -> Response { - ws.protocols(["graphql-ws", "graphql-transport-ws"]) - .on_upgrade(|socket| async { - // ... - }) -} - async fn serve_api(Extension(api): Extension) -> impl IntoResponse { Json(api) } diff --git a/backend/sync_server/src/server/ping.rs b/backend/sync_server/src/server/ping.rs index 4ed4e64..b3a0c80 100644 --- a/backend/sync_server/src/server/ping.rs +++ b/backend/sync_server/src/server/ping.rs @@ -12,8 +12,8 @@ pub async fn ping( maybe_auth_header: Option>>, State(state): State, ) -> Result, SyncServerError> { - let is_authenticated = maybe_auth_header - .is_some_and(|auth_header| auth(&state, auth_header.token()).is_ok()); + let is_authenticated = + maybe_auth_header.is_some_and(|auth_header| auth(&state, auth_header.token()).is_ok()); Ok(Json(PingResponse { server_version: env!("CARGO_PKG_VERSION").to_string(),