chore: clippy lints

This commit is contained in:
Aravinth Manivannan 2023-10-16 21:33:39 +05:30
parent 0e75a22beb
commit 4e2758f415
No known key found for this signature in database
GPG key ID: F8F50389936984FF
10 changed files with 14 additions and 28 deletions

View file

@ -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

View file

@ -49,7 +49,6 @@ pub mod dev {
pub mod prelude {
pub use super::*;
pub use db_core::prelude::*;
}
#[async_trait]

View file

@ -49,7 +49,6 @@ pub mod dev {
pub mod prelude {
pub use super::*;
pub use db_core::prelude::*;
}
#[async_trait]

View file

@ -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?;
}

View file

@ -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")]

View file

@ -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")]

View file

@ -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 =

View file

@ -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,
};

View file

@ -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;

View file

@ -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())),
)