From 5d80f46e6eb34f8dd8e9f756a877fd25bd212c93 Mon Sep 17 00:00:00 2001 From: Lucas Colombo Date: Thu, 28 Mar 2024 15:33:12 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=94=A8=20linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 58 +++++++++++++++++++------------------- Taskfile.yaml | 9 ++++-- app/main.rs | 2 +- entities/src/market/svc.rs | 5 +--- grpc/src/server.rs | 9 +++--- 5 files changed, 42 insertions(+), 41 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c0cebc9..68b20b9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,38 +1,38 @@ { "files.exclude": { - // // ๐Ÿงฉ modules - // "migration": true, - // // "entities": true, + // ๐Ÿงฉ modules + "migration": true, + // "entities": true, - // // โš™๏ธ - // ".env": true, - // "Taskfile.yaml": true, - // ".cocorc": true, - // ".task": true, - // ".cargo": true, - // ".github": true, - // "rustfmt.toml": true, - // // "**/**/Cargo.toml": true, + // โš™๏ธ + ".env": true, + "Taskfile.yaml": true, + ".cocorc": true, + ".task": true, + ".cargo": true, + ".github": true, + "rustfmt.toml": true, + // "**/**/Cargo.toml": true, - // // ๐Ÿ“ฆ - // "Cargo.lock": true, - // "target": true, + // ๐Ÿ“ฆ + "Cargo.lock": true, + "target": true, - // // ๐Ÿ“ readmes - // "**/**/README.md": true, - // "LICENSE": true, + // ๐Ÿ“ readmes + "**/**/README.md": true, + "LICENSE": true, - // // ๐Ÿ—‘๏ธ - // "check_size.py": true, - // "*.code-workspace": true, - // // ".gitignore": true, - // ".vscode": true, - // ".git": true, + // ๐Ÿ—‘๏ธ + "check_size.py": true, + "*.code-workspace": true, + // ".gitignore": true, + ".vscode": true, + ".git": true, - // // ๐Ÿ—„๏ธ database - // "rustler.db": true, - // "rustler.db-shm": true, - // "rustler.db-wal": true, - // "rustler.db.bkp": true, + // ๐Ÿ—„๏ธ database + "rustler.db": true, + "rustler.db-shm": true, + "rustler.db-wal": true, + "rustler.db.bkp": true, } } \ No newline at end of file diff --git a/Taskfile.yaml b/Taskfile.yaml index 36e0f51..08376da 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -30,6 +30,11 @@ tasks: - python check_size.py fmt: - desc: ๐Ÿš€ format rustler + desc: ๐ŸŽจ format rustler cmds: - - cargo +nightly fmt --all \ No newline at end of file + - cargo +nightly fmt --all + + lint: + desc: ๐Ÿงถ lint rustler + cmds: + - cargo clippy --fix --workspace --allow-dirty \ No newline at end of file diff --git a/app/main.rs b/app/main.rs index 12f320e..320c72f 100644 --- a/app/main.rs +++ b/app/main.rs @@ -2,7 +2,7 @@ use { dotenvy::dotenv, entities::sea_orm::{ConnectionTrait, Database, DbBackend, Statement}, eyre::Result, - std::sync::{Arc, Mutex}, + std::sync::Arc, }; // TODO: here we will trigger the start of both the grpc server and the websocket gateway diff --git a/entities/src/market/svc.rs b/entities/src/market/svc.rs index cbe464d..ba63b10 100644 --- a/entities/src/market/svc.rs +++ b/entities/src/market/svc.rs @@ -2,10 +2,7 @@ use { super::{Entity as MarketEntity, Model as MarketModel}, eyre::Result, sea_orm::{DatabaseConnection, EntityTrait, IntoActiveModel}, - std::{ - sync::{Arc, Mutex}, - time::Instant, - }, + std::{sync::Arc, time::Instant}, }; pub struct Service { diff --git a/grpc/src/server.rs b/grpc/src/server.rs index 9153c2a..bf5a4f9 100644 --- a/grpc/src/server.rs +++ b/grpc/src/server.rs @@ -1,8 +1,7 @@ use { - core::time, entities::{market, sea_orm::DatabaseConnection}, eyre::Result, - std::{env, sync::Arc, thread, time::Instant}, + std::{sync::Arc, time::Instant}, tonic::{transport::Server, Request, Response, Status}, }; @@ -57,10 +56,10 @@ pub struct GrpcServer { impl MarketApi for GrpcServer { async fn get_all(&self, _: Request) -> Result, Status> { let start = Instant::now(); - if let Some(mkts) = self.svc.get_all().await.ok() { + if let Ok(mkts) = self.svc.get_all().await { println!("get_all took {:?}", start.elapsed()); Ok(Response::new(Markets { - markets: mkts.into_iter().map(|m| Market::from_model(m)).collect(), + markets: mkts.into_iter().map(Market::from_model).collect(), })) } else { println!("get_all took {:?}", start.elapsed()); @@ -72,7 +71,7 @@ impl MarketApi for GrpcServer { let start = Instant::now(); let mkt = market.into_inner().into_model(); - if let Some(m) = self.svc.create(mkt).await.ok() { + if let Ok(m) = self.svc.create(mkt).await { println!("create took {:?}", start.elapsed()); Ok(Response::new(Market::from_model(m))) } else {