From 4e2758f415174705fb57d6194b59ef5fec5c62f5 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 16 Oct 2023 21:33:39 +0530 Subject: [PATCH] chore: clippy lints --- .github/workflows/linux.yml | 14 ++------------ db/db-sqlx-maria/src/lib.rs | 1 - db/db-sqlx-postgres/src/lib.rs | 1 - src/api/v1/pow/verify_pow.rs | 6 +++--- src/pages/auth/login.rs | 2 +- src/pages/auth/register.rs | 2 +- src/pages/mod.rs | 8 +++----- src/pages/panel/sitekey/edit.rs | 2 +- src/settings.rs | 4 ++-- src/tests/mod.rs | 2 +- 10 files changed, 14 insertions(+), 28 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3e33086a..27d7222b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -68,16 +68,7 @@ jobs: steps: - uses: actions/checkout@v4 - #- name: ⚡ Cache - # uses: actions/cache@v2 - # with: - # path: | - # ~/.cargo/registry - # ~/.cargo/git - # node_modules - # ./docs/openapi/node_modules - # target - # key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: configure GPG key if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha' @@ -110,8 +101,7 @@ jobs: run: make env: POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" - MARIA_DATABASE_URL: - "${{ env.MARIA_DATABASE_URL }}" + MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}" # - name: build frontend # run: make frontend diff --git a/db/db-sqlx-maria/src/lib.rs b/db/db-sqlx-maria/src/lib.rs index 7fe6ee67..94c359a3 100644 --- a/db/db-sqlx-maria/src/lib.rs +++ b/db/db-sqlx-maria/src/lib.rs @@ -49,7 +49,6 @@ pub mod dev { pub mod prelude { pub use super::*; - pub use db_core::prelude::*; } #[async_trait] diff --git a/db/db-sqlx-postgres/src/lib.rs b/db/db-sqlx-postgres/src/lib.rs index 5ccde1b4..d06dfeeb 100644 --- a/db/db-sqlx-postgres/src/lib.rs +++ b/db/db-sqlx-postgres/src/lib.rs @@ -49,7 +49,6 @@ pub mod dev { pub mod prelude { pub use super::*; - pub use db_core::prelude::*; } #[async_trait] diff --git a/src/api/v1/pow/verify_pow.rs b/src/api/v1/pow/verify_pow.rs index e8c9e8f6..0b2b7eb7 100644 --- a/src/api/v1/pow/verify_pow.rs +++ b/src/api/v1/pow/verify_pow.rs @@ -67,11 +67,11 @@ pub async fn verify_pow( let time = payload.time; let (res, difficulty_factor) = data.captcha.verify_pow(payload.into(), ip).await?; data.stats.record_solve(&data, &key).await?; - if time.is_some() && worker_type.is_some() { + if let (Some(time), Some(worker_type)) = (time, worker_type) { let analytics = db_core::CreatePerformanceAnalytics { difficulty_factor, - time: time.unwrap(), - worker_type: worker_type.unwrap(), + time, + worker_type, }; data.db.analysis_save(&key, &analytics).await?; } diff --git a/src/pages/auth/login.rs b/src/pages/auth/login.rs index e7eb184f..118ee3e2 100644 --- a/src/pages/auth/login.rs +++ b/src/pages/auth/login.rs @@ -22,7 +22,7 @@ impl Default for IndexPage { } lazy_static! { - static ref INDEX: String = IndexPage::default().render_once().unwrap(); + static ref INDEX: String = IndexPage.render_once().unwrap(); } #[get(path = "PAGES.auth.login")] diff --git a/src/pages/auth/register.rs b/src/pages/auth/register.rs index a4fe407b..ebca1696 100644 --- a/src/pages/auth/register.rs +++ b/src/pages/auth/register.rs @@ -20,7 +20,7 @@ impl Default for IndexPage { } lazy_static! { - static ref INDEX: String = IndexPage::default().render_once().unwrap(); + static ref INDEX: String = IndexPage.render_once().unwrap(); } #[my_codegen::get(path = "crate::PAGES.auth.join")] diff --git a/src/pages/mod.rs b/src/pages/mod.rs index 0fd9580d..a57887c0 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -63,8 +63,7 @@ mod tests { let edit_sitekey_url = PAGES.panel.sitekey.get_edit_advance(&token_key.key); let delete_sitekey_url = PAGES.panel.sitekey.get_delete(&token_key.key); - let urls = vec![ - PAGES.home, + let urls = [PAGES.home, PAGES.panel.sitekey.add_advance, PAGES.panel.sitekey.add_easy, PAGES.panel.sitekey.list, @@ -73,8 +72,7 @@ mod tests { PAGES.panel.settings.delete_account, PAGES.panel.settings.update_secret, &delete_sitekey_url, - &edit_sitekey_url, - ]; + &edit_sitekey_url]; for url in urls.iter() { let resp = @@ -100,7 +98,7 @@ mod tests { #[actix_rt::test] async fn public_pages_tempaltes_work() { let app = test::init_service(App::new().configure(services)).await; - let urls = vec![PAGES.auth.login, PAGES.auth.join, PAGES.sitemap]; + let urls = [PAGES.auth.login, PAGES.auth.join, PAGES.sitemap]; for url in urls.iter() { let resp = diff --git a/src/pages/panel/sitekey/edit.rs b/src/pages/panel/sitekey/edit.rs index 50509243..4dd6adc4 100644 --- a/src/pages/panel/sitekey/edit.rs +++ b/src/pages/panel/sitekey/edit.rs @@ -108,7 +108,7 @@ pub async fn easy( let pattern = TrafficPatternRequest { peak_sustainable_traffic: c.peak_sustainable_traffic, avg_traffic: c.avg_traffic, - broke_my_site_traffic: c.broke_my_site_traffic.map(|n| n), + broke_my_site_traffic: c.broke_my_site_traffic, description: config.description, publish_benchmarks, }; diff --git a/src/settings.rs b/src/settings.rs index b70aec1a..a6b4e500 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -294,7 +294,7 @@ mod tests { let env = "MCPATCHA_redis_URL"; let val = "redis://redis.example.org"; println!("Setting env var {} to {} for test", env, val); - env::set_var(env, val.to_string()); + env::set_var(env, val); new_settings = get_settings(); assert_eq!(new_settings.redis.as_ref().unwrap().url, val); assert_ne!( @@ -364,7 +364,7 @@ mod tests { ]; for env in vals.iter() { println!("Setting env var {} to {} for test", env, env); - env::set_var(env, env.to_string()); + env::set_var(env, env); } let port = 9999; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 224200a9..40e95974 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -118,7 +118,7 @@ macro_rules! get_app { .wrap(actix_middleware::NormalizePath::new( actix_middleware::TrailingSlash::Trim, )) - .configure(crate::routes::services) + .configure($crate::routes::services) //.data(std::sync::Arc::new(crate::data::Data::new().await)) .app_data(actix_web::web::Data::new($data.clone())), )