Ver código fonte

chore: clippy fixes at workspace

thesimplekid 1 mês atrás
pai
commit
8b1f037666

+ 11 - 11
Cargo.toml

@@ -6,22 +6,22 @@ resolver = "2"
 
 [workspace.lints.rust]
 unsafe_code = "forbid"
-unreachable_pub = "warn"
-missing_debug_implementations = "warn"
+# unreachable_pub = "warn"
+# missing_debug_implementations = "warn"
 
 [workspace.lints.clippy]
 # pedantic = { level = "warn", priority = -1 }
 unwrap_used = "deny"
-clone_on_ref_ptr = "warn"
-missing_errors_doc = "warn"
-missing_panics_doc = "warn"
-missing_safety_doc = "warn"
+# clone_on_ref_ptr = "warn"
+# missing_errors_doc = "warn"
+# missing_panics_doc = "warn"
+# missing_safety_doc = "warn"
 # nursery = { level = "warn", priority = -1 }
-redundant_else = "warn"
-redundant_closure_for_method_calls = "warn"
-unneeded_field_pattern = "warn"
-use_debug = "warn"
-large_enum_variant = "warn"
+# redundant_else = "warn"
+# redundant_closure_for_method_calls = "warn"
+# unneeded_field_pattern = "warn"
+# use_debug = "warn"
+# large_enum_variant = "warn"
 
 [workspace.lints.rustdoc]
 missing_docs = "warn"

+ 3 - 0
crates/cashu/Cargo.toml

@@ -44,3 +44,6 @@ uuid = { workspace = true, features = ["js"], optional = true }
 
 [dev-dependencies]
 bip39.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-axum/Cargo.toml

@@ -40,3 +40,6 @@ redis = { version = "0.31.0", features = [
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 uuid = { workspace = true, features = ["js"] }
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-cli/Cargo.toml

@@ -36,3 +36,6 @@ reqwest.workspace = true
 url.workspace = true
 serde_with.workspace = true
 lightning.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-cln/Cargo.toml

@@ -25,3 +25,6 @@ serde_json.workspace = true
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 uuid = { workspace = true, features = ["js"] }
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-common/Cargo.toml

@@ -58,3 +58,6 @@ criterion.workspace = true
 [[bench]]
 name = "transaction_id_benchmark"
 harness = false
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-fake-wallet/Cargo.toml

@@ -26,3 +26,6 @@ lightning.workspace = true
 tokio-stream.workspace = true
 reqwest.workspace = true
 uuid.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-ffi/Cargo.toml

@@ -40,3 +40,6 @@ postgres = ["cdk-postgres"]
 [[bin]]
 name = "uniffi-bindgen"
 path = "src/bin/uniffi-bindgen.rs"
+
+[lints]
+workspace = true

+ 10 - 0
crates/cdk-integration-tests/Cargo.toml

@@ -67,3 +67,13 @@ cdk-axum = { workspace = true }
 cdk-fake-wallet = { workspace = true }
 cdk-ffi = { workspace = true }
 tower-http = { workspace = true, features = ["cors"] }
+
+[lints.rust]
+unsafe_code = "forbid"
+
+[lints.clippy]
+unwrap_used = "allow"
+
+[lints.rustdoc]
+missing_docs = "warn"
+bare_urls = "warn"

+ 3 - 0
crates/cdk-ldk-node/Cargo.toml

@@ -29,3 +29,6 @@ tower-http.workspace = true
 rust-embed = "8.5.0"
 serde_urlencoded = "0.7"
 urlencoding = "2.1"
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-lnbits/Cargo.toml

@@ -23,3 +23,6 @@ thiserror.workspace = true
 lnbits-rs = "0.9.1"
 serde_json.workspace = true
 rustls.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-lnd/Cargo.toml

@@ -31,3 +31,6 @@ rustls-pemfile = "2.2.0"
 
 [build-dependencies]
 tonic-build.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-mint-rpc/Cargo.toml

@@ -39,3 +39,6 @@ rustls.workspace = true
 
 [build-dependencies]
 tonic-build.workspace = true
+
+[lints]
+workspace = true

+ 1 - 1
crates/cdk-mint-rpc/src/bin/mint_rpc_cli.rs

@@ -127,7 +127,7 @@ async fn main() -> Result<()> {
         }
 
         // TLS directory exists, configure TLS
-        let server_root_ca_cert = std::fs::read_to_string(work_dir.join("tls/ca.pem")).unwrap();
+        let server_root_ca_cert = std::fs::read_to_string(work_dir.join("tls/ca.pem"))?;
         let server_root_ca_cert = Certificate::from_pem(server_root_ca_cert);
         let client_cert = std::fs::read_to_string(work_dir.join("tls/client.pem"))?;
         let client_key = std::fs::read_to_string(work_dir.join("tls/client.key"))?;

+ 3 - 0
crates/cdk-mintd/Cargo.toml

@@ -69,4 +69,7 @@ home.workspace = true
 utoipa = { workspace = true, optional = true }
 utoipa-swagger-ui = { version = "9.0.0", features = ["axum"], optional = true }
 
+[lints]
+workspace = true
+
 [build-dependencies]

+ 3 - 0
crates/cdk-payment-processor/Cargo.toml

@@ -70,3 +70,6 @@ bip39.workspace = true
 
 [build-dependencies]
 tonic-build.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-postgres/Cargo.toml

@@ -33,3 +33,6 @@ futures-util = "0.3.31"
 postgres-native-tls = "0.5.1"
 native-tls = "0.2"
 once_cell.workspace = true
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-redb/Cargo.toml

@@ -33,3 +33,6 @@ tokio.workspace = true
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 uuid = { workspace = true, features = ["js"] }
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk-signatory/Cargo.toml

@@ -45,3 +45,6 @@ getrandom = { version = "0.2", features = ["js"] }
 
 [build-dependencies]
 tonic-build = { workspace = true, features = ["prost"], optional = true }
+
+[lints]
+workspace = true

+ 2 - 2
crates/cdk-signatory/src/bin/cli/mod.rs

@@ -8,7 +8,7 @@ use std::str::FromStr;
 use std::sync::Arc;
 use std::{env, fs};
 
-use anyhow::{bail, Result};
+use anyhow::{anyhow, bail, Result};
 use bip39::rand::{thread_rng, Rng};
 use bip39::Mnemonic;
 use cdk_common::database::MintKeysDatabase;
@@ -114,7 +114,7 @@ pub async fn cli_main() -> Result<()> {
     let work_dir = match &args.work_dir {
         Some(work_dir) => work_dir.clone(),
         None => {
-            let home_dir = home::home_dir().unwrap();
+            let home_dir = home::home_dir().ok_or(anyhow!("Unknown how"))?;
             home_dir.join(DEFAULT_WORK_DIR)
         }
     };

+ 2 - 2
crates/cdk-signatory/src/bin/signatory.rs

@@ -7,9 +7,9 @@ fn main() {
     #[cfg(not(target_arch = "wasm32"))]
     {
         use tokio::runtime::Runtime;
-        let rt = Runtime::new().unwrap();
+        let rt = Runtime::new().expect("Runtime created");
         rt.block_on(async {
-            cli::cli_main().await.unwrap();
+            cli::cli_main().await.expect("cli error");
         });
     }
 }

+ 3 - 0
crates/cdk-sql-common/Cargo.toml

@@ -30,3 +30,6 @@ serde_json.workspace = true
 lightning-invoice.workspace = true
 once_cell.workspace = true
 uuid.workspace = true
+
+[lints]
+workspace = true

+ 4 - 0
crates/cdk-sql-common/src/mint/mod.rs

@@ -135,6 +135,8 @@ where
 {
     type Err = Error;
 
+    // FIXME: Replace unwrap with proper error handling
+    #[allow(clippy::unwrap_used)]
     async fn add_proofs(
         &mut self,
         proofs: Proofs,
@@ -2455,6 +2457,8 @@ fn sql_row_to_mint_quote(
     ))
 }
 
+// FIXME: Replace unwrap with proper error handling
+#[allow(clippy::unwrap_used)]
 fn sql_row_to_melt_quote(row: Vec<Column>) -> Result<mint::MeltQuote, Error> {
     unpack_into!(
         let (

+ 2 - 0
crates/cdk-sql-common/src/stmt.rs

@@ -72,6 +72,8 @@ pub enum SqlParseError {
 ///
 /// This function does not validate the SQL statement, it only extracts the placeholder to be
 /// database agnostic.
+// FIXME: Replace unwraps with proper error handling
+#[allow(clippy::unwrap_used)]
 pub fn split_sql_parts(input: &str) -> Result<Vec<SqlPart>, SqlParseError> {
     let mut parts = Vec::new();
     let mut current = String::new();

+ 4 - 0
crates/cdk-sql-common/src/wallet/mod.rs

@@ -67,6 +67,8 @@ where
         Ok(())
     }
 
+    // FIXME: Replace unwrap with proper error handling
+    #[allow(clippy::unwrap_used)]
     async fn add_keyset_u32<T>(conn: &T) -> Result<(), Error>
     where
         T: DatabaseExecutor,
@@ -711,6 +713,8 @@ ON CONFLICT(id) DO UPDATE SET
         Ok(())
     }
 
+    // FIXME: Replace unwrap with proper error handling
+    #[allow(clippy::unwrap_used)]
     async fn update_proofs(
         &self,
         added: Vec<ProofInfo>,

+ 3 - 0
crates/cdk-sqlite/Cargo.toml

@@ -35,3 +35,6 @@ uuid.workspace = true
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 uuid = { workspace = true, features = ["js"] }
+
+[lints]
+workspace = true

+ 3 - 0
crates/cdk/Cargo.toml

@@ -166,3 +166,6 @@ tokio = { workspace = true, features = ["full"] }
 [[bench]]
 name = "dhke_benchmarks"
 harness = false
+
+[lints]
+workspace = true