Kaynağa Gözat

chore: fix clippy docs in all crates and ci (#1541)

tsk 1 hafta önce
ebeveyn
işleme
a52bbe6d59

+ 1 - 1
Cargo.toml

@@ -11,6 +11,7 @@ resolver = "2"
 unsafe_code = "forbid"
 # unreachable_pub = "warn"
 missing_debug_implementations = "warn"
+missing_docs = "warn"
 
 [workspace.lints.clippy]
 # pedantic = { level = "warn", priority = -1 }
@@ -27,7 +28,6 @@ use_debug = "warn"
 large_enum_variant = "warn"
 
 [workspace.lints.rustdoc]
-missing_docs = "warn"
 bare_urls = "warn"
 
 [workspace.package]

+ 1 - 1
crates/cashu/Cargo.toml

@@ -52,6 +52,7 @@ nostr-sdk.workspace = true
 unsafe_code = "forbid"
 unreachable_pub = "warn"
 missing_debug_implementations = "warn"
+missing_docs = "warn"
 
 [lints.clippy]
 # pedantic = { level = "warn", priority = -1 }
@@ -68,5 +69,4 @@ unneeded_field_pattern = "warn"
 use_debug = "warn"
 
 [lints.rustdoc]
-missing_docs = "warn"
 bare_urls = "warn"

+ 2 - 0
crates/cdk-cli/src/main.rs

@@ -1,3 +1,5 @@
+//! CDK CLI
+
 use std::fs;
 use std::path::PathBuf;
 use std::str::FromStr;

+ 1 - 0
crates/cdk-ffi/src/bin/uniffi-bindgen.rs

@@ -1,3 +1,4 @@
+//! Bindgen binary
 fn main() {
     uniffi::uniffi_bindgen_main()
 }

+ 1 - 0
crates/cdk-ffi/src/lib.rs

@@ -3,6 +3,7 @@
 //! UniFFI bindings for the CDK Wallet and related types.
 
 #![warn(clippy::unused_async)]
+#![allow(missing_docs)]
 #![allow(missing_debug_implementations)]
 
 pub mod database;

+ 2 - 0
crates/cdk-lnd/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 fn main() -> Result<(), Box<dyn std::error::Error>> {

+ 2 - 0
crates/cdk-mint-rpc/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 fn main() -> Result<(), Box<dyn std::error::Error>> {

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

@@ -1,3 +1,5 @@
+//! Mint RPC CLI
+
 use std::path::PathBuf;
 
 use anyhow::{anyhow, Result};

+ 2 - 0
crates/cdk-mintd/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 fn main() {

+ 1 - 0
crates/cdk-mintd/src/env_vars/mod.rs

@@ -1,3 +1,4 @@
+#![allow(missing_docs)]
 //! Environment variables module
 //!
 //! This module contains all environment variable definitions and parsing logic

+ 1 - 0
crates/cdk-mintd/src/lib.rs

@@ -1,3 +1,4 @@
+#![allow(missing_docs)]
 //! Cdk mintd lib
 
 // std

+ 2 - 0
crates/cdk-payment-processor/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 fn main() -> Result<(), Box<dyn std::error::Error>> {

+ 1 - 0
crates/cdk-payment-processor/src/bin/payment_processor.rs

@@ -1,3 +1,4 @@
+#![allow(missing_docs)]
 #[cfg(feature = "fake")]
 use std::collections::HashSet;
 use std::env;

+ 6 - 0
crates/cdk-postgres/src/lib.rs

@@ -1,3 +1,5 @@
+//! CDK Postgres
+
 use std::fmt::Debug;
 use std::sync::atomic::AtomicBool;
 use std::sync::{Arc, OnceLock};
@@ -20,11 +22,15 @@ mod db;
 mod value;
 
 #[derive(Debug)]
+/// Postgres connection pool
 pub struct PgConnectionPool;
 
 #[derive(Clone)]
+/// SSL Mode
 pub enum SslMode {
+    /// No TLS
     NoTls(NoTls),
+    /// Native TLS
     NativeTls(postgres_native_tls::MakeTlsConnector),
 }
 const SSLMODE_VERIFY_FULL: &str = "sslmode=verify-full";

+ 3 - 0
crates/cdk-prometheus/src/error.rs

@@ -6,8 +6,10 @@ pub enum PrometheusError {
     /// Server binding error
     #[error("Failed to bind to address {address}: {source}")]
     ServerBind {
+        /// Address that failed to bind
         address: String,
         #[source]
+        /// Underlying I/O error
         source: std::io::Error,
     },
 
@@ -19,6 +21,7 @@ pub enum PrometheusError {
     #[error("Registry error: {source}")]
     Registry {
         #[from]
+        /// Underlying Prometheus error
         source: prometheus::Error,
     },
 

+ 4 - 0
crates/cdk-prometheus/src/lib.rs

@@ -1,10 +1,14 @@
 //! # CDK Prometheus
 
+/// Error definitions
 pub mod error;
+/// Metrics definitions
 pub mod metrics;
+/// Server implementation
 pub mod server;
 
 #[cfg(feature = "system-metrics")]
+/// System metrics
 pub mod process;
 
 // Re-exports for convenience

+ 14 - 0
crates/cdk-prometheus/src/metrics.rs

@@ -274,12 +274,14 @@ impl CdkMetrics {
     }
 
     // HTTP metrics methods
+    /// Record an HTTP request
     pub fn record_http_request(&self, endpoint: &str, status: &str) {
         self.http_requests_total
             .with_label_values(&[endpoint, status])
             .inc();
     }
 
+    /// Record HTTP request duration
     pub fn record_http_request_duration(&self, duration_seconds: f64, endpoint: &str) {
         self.http_request_duration
             .with_label_values(&[endpoint])
@@ -287,15 +289,18 @@ impl CdkMetrics {
     }
 
     // Authentication metrics methods
+    /// Record an authentication attempt
     pub fn record_auth_attempt(&self) {
         self.auth_attempts_total.inc();
     }
 
+    /// Record a successful authentication
     pub fn record_auth_success(&self) {
         self.auth_successes_total.inc();
     }
 
     // Lightning metrics methods
+    /// Record a Lightning payment
     pub fn record_lightning_payment(&self, amount: f64, fee: f64) {
         self.lightning_payments_total.inc();
         self.lightning_payment_amount.observe(amount);
@@ -303,6 +308,7 @@ impl CdkMetrics {
     }
 
     // Database metrics methods
+    /// Record a database operation
     pub fn record_db_operation(&self, duration_seconds: f64, op: &str) {
         self.db_operations_total.inc();
         self.db_operation_duration
@@ -310,22 +316,27 @@ impl CdkMetrics {
             .observe(duration_seconds);
     }
 
+    /// Set the number of active database connections
     pub fn set_db_connections_active(&self, count: i64) {
         self.db_connections_active.set(count);
     }
 
     // Error metrics methods
+    /// Record an error
     pub fn record_error(&self) {
         self.errors_total.inc();
     }
 
     // Mint metrics methods
+    /// Record a mint operation
     pub fn record_mint_operation(&self, operation: &str, success: bool) {
         let status = if success { "success" } else { "error" };
         self.mint_operations_total
             .with_label_values(&[operation, status])
             .inc();
     }
+
+    /// Record a mint operation with duration
     pub fn record_mint_operation_histogram(
         &self,
         operation: &str,
@@ -337,12 +348,15 @@ impl CdkMetrics {
             .with_label_values(&[operation, status])
             .observe(duration_seconds);
     }
+
+    /// Increment in-flight mint requests
     pub fn inc_in_flight_requests(&self, operation: &str) {
         self.mint_in_flight_requests
             .with_label_values(&[operation])
             .inc();
     }
 
+    /// Decrement in-flight mint requests
     pub fn dec_in_flight_requests(&self, operation: &str) {
         self.mint_in_flight_requests
             .with_label_values(&[operation])

+ 2 - 0
crates/cdk-signatory/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 fn main() {

+ 3 - 0
crates/cdk-signatory/src/bin/signatory.rs

@@ -1,9 +1,12 @@
+//! Signatory Binary
+
 #[cfg(not(target_arch = "wasm32"))]
 mod cli;
 
 fn main() {
     #[cfg(target_arch = "wasm32")]
     println!("Not supported in wasm32");
+
     #[cfg(not(target_arch = "wasm32"))]
     {
         use tokio::runtime::Runtime;

+ 2 - 0
crates/cdk-sql-common/build.rs

@@ -1,3 +1,5 @@
+//! Build script
+
 #![allow(clippy::unwrap_used)]
 
 use std::cmp::Ordering;

+ 1 - 0
crates/cdk/benches/dhke_benchmarks.rs

@@ -1,3 +1,4 @@
+#![allow(missing_docs)]
 use cdk::dhke;
 use cdk::nuts::nut01::{PublicKey, SecretKey};
 use cdk::util::hex;

+ 1 - 1
crates/cdk/examples/mint-token-bolt12-with-custom-http.rs

@@ -19,7 +19,7 @@ use ureq::Agent;
 use url::Url;
 
 #[derive(Debug, Clone)]
-pub struct CustomHttp {
+struct CustomHttp {
     agent: Agent,
 }
 

+ 10 - 0
justfile

@@ -537,16 +537,21 @@ check-docs:
     "-p cdk"
     "-p cdk-redb"
     "-p cdk-sqlite"
+    "-p cdk-postgres"
     "-p cdk-axum"
     "-p cdk-cln"
     "-p cdk-lnd"
     "-p cdk-lnbits"
+    "-p cdk-ldk-node"
     "-p cdk-fake-wallet"
     "-p cdk-mint-rpc"
+    "-p cdk-npubcash"
+    "-p cdk-prometheus"
     "-p cdk-payment-processor"
     "-p cdk-signatory"
     "-p cdk-cli"
     "-p cdk-mintd"
+    "-p cdk-ffi"
   )
 
   for arg in "${args[@]}"; do
@@ -566,16 +571,21 @@ docs-strict:
     "-p cdk"
     "-p cdk-redb"
     "-p cdk-sqlite"
+    "-p cdk-postgres"
     "-p cdk-axum"
     "-p cdk-cln"
     "-p cdk-lnd"
     "-p cdk-lnbits"
+    "-p cdk-ldk-node"
     "-p cdk-fake-wallet"
     "-p cdk-mint-rpc"
+    "-p cdk-npubcash"
+    "-p cdk-prometheus"
     "-p cdk-payment-processor"
     "-p cdk-signatory"
     "-p cdk-cli"
     "-p cdk-mintd"
+    "-p cdk-ffi"
   )
 
   for arg in "${args[@]}"; do