From 0c7b65733954858c4a1626c57501b9d582cad143 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:08:38 -0400 Subject: [PATCH] style: fix lint warnings --- .github/workflows/ci.yml | 12 +++++++++++- .rustfmt.toml | 3 ++- crates/server/src/auth.rs | 8 ++++---- crates/server/src/certs.rs | 4 ++-- crates/server/src/config.rs | 5 +++-- crates/server/src/db/mod.rs | 7 ++++--- crates/server/src/db/models.rs | 2 +- crates/server/src/db/schema.rs | 2 +- crates/server/src/dependencies/mod.rs | 2 +- crates/server/src/globals.rs | 2 +- crates/server/src/logging/mod.rs | 2 +- crates/server/src/tray.rs | 8 +++++--- crates/server/src/web/mod.rs | 2 +- crates/server/src/web/routes/auth.rs | 8 ++++---- crates/server/src/web/routes/common.rs | 2 +- crates/server/src/web/routes/dependencies.rs | 2 +- crates/server/src/web/routes/mod.rs | 2 +- crates/server/src/web/routes/user.rs | 6 +++--- crates/server/tests/fixtures/mod.rs | 2 +- crates/server/tests/test_web/routes/dependencies.rs | 5 +++-- 20 files changed, 51 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d52939..7030d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,16 +50,20 @@ jobs: include: - target: x86_64-unknown-linux-gnu # Debian os: ubuntu-latest + container: '' shell: bash + cargo_env: '' # TODO: Fix compiling for musl # - target: x86_64-unknown-linux-musl # Alpine # os: ubuntu-latest # container: alpine:latest # shell: sh - # cargo_env: "source $HOME/.cargo/env" + # cargo_env: "source $HOME/.cargo/env" - target: aarch64-unknown-linux-gnu # Debian os: ubuntu-24.04-arm + container: '' shell: bash + cargo_env: '' # TODO: Fix cross compiling for the below targets # - target: aarch64-unknown-linux-musl # Alpine # os: ubuntu-24.04-arm @@ -84,13 +88,19 @@ jobs: # cargo_env: "source $HOME/.cargo/env" - target: x86_64-apple-darwin # macOS/Intel os: macos-latest + container: '' shell: bash + cargo_env: '' - target: aarch64-apple-darwin # macOS/Apple Silicon os: macos-latest + container: '' shell: bash + cargo_env: '' - target: x86_64-pc-windows-msvc # Windows os: windows-latest + container: '' shell: bash + cargo_env: '' name: Build (${{ matrix.target }}) needs: setup_release runs-on: ${{ matrix.os }} diff --git a/.rustfmt.toml b/.rustfmt.toml index b29faa8..af9e6d0 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,5 +1,6 @@ array_width = 30 color = "Always" +comment_width = 120 error_on_line_overflow = true error_on_unformatted = true fn_params_layout = "Vertical" @@ -11,5 +12,5 @@ normalize_doc_attributes = true reorder_impl_items = true single_line_if_else_max_width = 100 single_line_let_else_max_width = 100 -style_edition = "2021" +style_edition = "2024" wrap_comments = true diff --git a/crates/server/src/auth.rs b/crates/server/src/auth.rs index 66cb89a..cd661b7 100644 --- a/crates/server/src/auth.rs +++ b/crates/server/src/auth.rs @@ -1,10 +1,10 @@ -#![doc = "Authentication utilities for the application."] +//! Authentication utilities for the application. // lib imports -use base64::{engine::general_purpose, Engine as _}; -use bcrypt::{hash, verify, DEFAULT_COST}; +use base64::{Engine as _, engine::general_purpose}; +use bcrypt::{DEFAULT_COST, hash, verify}; use diesel::{QueryDsl, RunQueryDsl}; -use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; +use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation, decode, encode}; use once_cell::sync::Lazy; use rand::Rng; use rocket::http::Status; diff --git a/crates/server/src/certs.rs b/crates/server/src/certs.rs index 2aca7f3..cba2869 100644 --- a/crates/server/src/certs.rs +++ b/crates/server/src/certs.rs @@ -1,11 +1,11 @@ -#![doc = "Certificate utilities for the application."] +//! Certificate utilities for the application. // standard imports use std::fs; use std::path::Path; // lib imports -use rcgen::{generate_simple_self_signed, CertifiedKey}; +use rcgen::{CertifiedKey, generate_simple_self_signed}; /// Ensure that the certificates exist at the given paths. pub fn ensure_certificates_exist( diff --git a/crates/server/src/config.rs b/crates/server/src/config.rs index 0a7e22a..621f714 100644 --- a/crates/server/src/config.rs +++ b/crates/server/src/config.rs @@ -1,4 +1,4 @@ -#![doc = "Configuration module for the application."] +//! Configuration module for the application. // lib imports use config::{Config, ConfigError, Environment, File}; @@ -81,7 +81,8 @@ impl Default for ServerSettings { impl Settings { /// Create a new instance of `Settings`. pub fn new() -> Result { - // Start with defaults provided via set_default and then merge in any provided config file or environment variables. + // Start with defaults provided via set_default and then merge in any provided config file + // or environment variables. let config = Config::builder() .set_default("general.data_dir", GeneralSettings::default().data_dir)? .set_default("server.use_https", ServerSettings::default().use_https)? diff --git a/crates/server/src/db/mod.rs b/crates/server/src/db/mod.rs index 705d3ef..4719bf2 100644 --- a/crates/server/src/db/mod.rs +++ b/crates/server/src/db/mod.rs @@ -1,13 +1,14 @@ -#![doc = "Database utilities for the application."] +//! Database utilities for the application. pub(crate) mod models; pub(crate) mod schema; // lib imports -use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; +use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations}; use rocket::{ + Build, + Rocket, fairing::{Fairing, Info, Kind}, - Build, Rocket, }; use rocket_sync_db_pools::{database, diesel}; diff --git a/crates/server/src/db/models.rs b/crates/server/src/db/models.rs index 2495de9..dcea4d0 100644 --- a/crates/server/src/db/models.rs +++ b/crates/server/src/db/models.rs @@ -1,4 +1,4 @@ -#![doc = "Database models for the application."] +//! Database models for the application. // lib imports use diesel::prelude::*; diff --git a/crates/server/src/db/schema.rs b/crates/server/src/db/schema.rs index e01bf8e..f63dc8d 100644 --- a/crates/server/src/db/schema.rs +++ b/crates/server/src/db/schema.rs @@ -1,4 +1,4 @@ -#![doc = "Database schema for the application."] +//! Database schema for the application. // lib imports use diesel::table; diff --git a/crates/server/src/dependencies/mod.rs b/crates/server/src/dependencies/mod.rs index 632e5e4..1719984 100644 --- a/crates/server/src/dependencies/mod.rs +++ b/crates/server/src/dependencies/mod.rs @@ -1,4 +1,4 @@ -#![doc = "Module for everything related to dependencies."] +//! Module for everything related to dependencies. use cargo_metadata::{MetadataCommand, Package}; use std::error::Error; diff --git a/crates/server/src/globals.rs b/crates/server/src/globals.rs index 0b8ff71..d40035e 100644 --- a/crates/server/src/globals.rs +++ b/crates/server/src/globals.rs @@ -1,4 +1,4 @@ -#![doc = "Miscellaneous utilities for the application."] +//! Miscellaneous utilities for the application. // lib imports use once_cell::sync::Lazy; diff --git a/crates/server/src/logging/mod.rs b/crates/server/src/logging/mod.rs index f701c08..f650c9d 100644 --- a/crates/server/src/logging/mod.rs +++ b/crates/server/src/logging/mod.rs @@ -1,4 +1,4 @@ -#![doc = "Logging utilities for the application."] +//! Logging utilities for the application. // standard imports use std::io; diff --git a/crates/server/src/tray.rs b/crates/server/src/tray.rs index 8f69ffa..212a919 100644 --- a/crates/server/src/tray.rs +++ b/crates/server/src/tray.rs @@ -1,4 +1,4 @@ -#![doc = "Tray icon utilities for the application."] +//! Tray icon utilities for the application. // lib imports use tao::{ @@ -6,8 +6,9 @@ use tao::{ event_loop::{ControlFlow, EventLoopBuilder}, }; use tray_icon::{ + TrayIconBuilder, + TrayIconEvent, menu::{AboutMetadata, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu}, - TrayIconBuilder, TrayIconEvent, }; // local imports @@ -124,7 +125,8 @@ pub fn launch() { ); // We have to request a redraw here to have the icon actually show up. - // Tao only exposes a redraw method on the Window so we use core-foundation directly. + // Tao only exposes a redraw method on the Window so we use core-foundation + // directly. #[cfg(target_os = "macos")] { use objc2_core_foundation::CFRunLoop; diff --git a/crates/server/src/web/mod.rs b/crates/server/src/web/mod.rs index d091c87..8d7705d 100644 --- a/crates/server/src/web/mod.rs +++ b/crates/server/src/web/mod.rs @@ -1,4 +1,4 @@ -#![doc = "Web server utilities for the application."] +//! Web server utilities for the application. // modules mod routes; diff --git a/crates/server/src/web/routes/auth.rs b/crates/server/src/web/routes/auth.rs index 3d23774..84efec7 100644 --- a/crates/server/src/web/routes/auth.rs +++ b/crates/server/src/web/routes/auth.rs @@ -1,18 +1,18 @@ -#![doc = "Routes for the web server."] +//! Routes for the web server. // lib imports use diesel::QueryDsl; use diesel::RunQueryDsl; use diesel::{ExpressionMethods, SelectableHelper}; use rocket::http::Status; -use rocket::serde::{json::Json, Deserialize, Serialize}; +use rocket::serde::{Deserialize, Serialize, json::Json}; use rocket::{get, post}; -use rocket_okapi::{openapi, JsonSchema}; +use rocket_okapi::{JsonSchema, openapi}; // local imports use crate::auth::{AdminGuard, Claims}; -use crate::db::models::User; use crate::db::DbConn; +use crate::db::models::User; #[derive(Deserialize, JsonSchema)] pub struct LoginForm { diff --git a/crates/server/src/web/routes/common.rs b/crates/server/src/web/routes/common.rs index 5efbd6f..357de16 100644 --- a/crates/server/src/web/routes/common.rs +++ b/crates/server/src/web/routes/common.rs @@ -1,4 +1,4 @@ -#![doc = "Routes for the web server."] +//! Routes for the web server. // lib imports use rocket::get; diff --git a/crates/server/src/web/routes/dependencies.rs b/crates/server/src/web/routes/dependencies.rs index a014dbd..15463ab 100644 --- a/crates/server/src/web/routes/dependencies.rs +++ b/crates/server/src/web/routes/dependencies.rs @@ -1,4 +1,4 @@ -#![doc = "Routes for dependencies."] +//! Routes for dependencies. // lib imports use cargo_metadata::Package; diff --git a/crates/server/src/web/routes/mod.rs b/crates/server/src/web/routes/mod.rs index f2afe53..91b9fc2 100644 --- a/crates/server/src/web/routes/mod.rs +++ b/crates/server/src/web/routes/mod.rs @@ -1,4 +1,4 @@ -#![doc = "Common routes module for the web server."] +//! Common routes module for the web server. // modules mod auth; diff --git a/crates/server/src/web/routes/user.rs b/crates/server/src/web/routes/user.rs index c0ee13e..b8210c0 100644 --- a/crates/server/src/web/routes/user.rs +++ b/crates/server/src/web/routes/user.rs @@ -2,14 +2,14 @@ use diesel::{QueryDsl, RunQueryDsl}; use rocket::http::Status; use rocket::post; -use rocket::serde::{json::Json, Deserialize}; -use rocket_okapi::openapi; +use rocket::serde::{Deserialize, json::Json}; use rocket_okapi::JsonSchema; +use rocket_okapi::openapi; // local imports use crate::auth::AdminGuard; -use crate::db::models::User; use crate::db::DbConn; +use crate::db::models::User; #[derive(Deserialize, JsonSchema)] pub struct CreateUserForm { diff --git a/crates/server/tests/fixtures/mod.rs b/crates/server/tests/fixtures/mod.rs index cb2c184..3ad69fe 100644 --- a/crates/server/tests/fixtures/mod.rs +++ b/crates/server/tests/fixtures/mod.rs @@ -3,8 +3,8 @@ use std::fs; use std::path::Path; // lib imports -use diesel::sqlite::SqliteConnection; use diesel::Connection; +use diesel::sqlite::SqliteConnection; use diesel_migrations::MigrationHarness; use once_cell::sync::Lazy; use rocket::http::Status; diff --git a/crates/server/tests/test_web/routes/dependencies.rs b/crates/server/tests/test_web/routes/dependencies.rs index 5df8663..0215385 100644 --- a/crates/server/tests/test_web/routes/dependencies.rs +++ b/crates/server/tests/test_web/routes/dependencies.rs @@ -1,13 +1,14 @@ use crate::test_web::test_request; use rocket::http::Status; -use rocket::serde::json::{serde_json, Value}; +use rocket::serde::json::{Value, serde_json}; #[rocket::async_test] async fn test_get_dependencies_route() { let response = test_request("get", "/dependencies", None, Status::Ok, None).await; - // ensure response is a json list of dictionaries, and each dictionary has the keys name, version, and license + // ensure response is a json list of dictionaries, and each dictionary has the keys name, + // version, and license let body = response.body; let json: Value = serde_json::from_str(&body).unwrap();