Skip to content

Commit 02dafed

Browse files
mivertowskiclaude
andcommitted
fix: resolve all clippy warnings for clean build
- Fix derivable Default implementations across core modules - Add #[allow(clippy::needless_range_loop)] for algorithmic functions - Fix map_or → is_some_and, min/max → clamp patterns - Fix len() comparisons to use is_empty() - Add documentation to enum variant fields where required - Fix unused imports and variables - Update crate references from rustkernel to rustkernels - Fix collapsible if statements and map_flatten patterns 62 files modified across all domain crates to achieve clean `cargo clippy --workspace --all-targets --all-features -- -D warnings` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7d8d6d0 commit 02dafed

62 files changed

Lines changed: 593 additions & 473 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/rustkernel-audit/src/hypergraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ mod tests {
799799
let result = HypergraphConstruction::construct(&records, &config);
800800

801801
// Should only have entity nodes
802-
for (_, node) in &result.hypergraph.nodes {
802+
for node in result.hypergraph.nodes.values() {
803803
assert_eq!(node.node_type, NodeType::Entity);
804804
}
805805
}
@@ -834,7 +834,7 @@ mod tests {
834834
let result = HypergraphConstruction::construct(&records, &config);
835835

836836
// Weights should be normalized 0-1
837-
for (_, weight) in &result.edge_weights {
837+
for weight in result.edge_weights.values() {
838838
assert!(*weight >= 0.0 && *weight <= 1.0);
839839
}
840840

crates/rustkernel-behavioral/src/causal.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ mod tests {
460460
let mut events = Vec::new();
461461

462462
// Create a clear causal chain: A -> B -> C
463-
for i in 0..30 {
463+
for i in 0u64..30 {
464464
events.push(UserEvent {
465465
id: i * 3,
466466
user_id: 100,
467467
event_type: "event_a".to_string(),
468-
timestamp: base_ts + (i as u64 * 1000),
468+
timestamp: base_ts + (i * 1000),
469469
attributes: HashMap::new(),
470-
session_id: Some(i as u64),
470+
session_id: Some(i),
471471
device_id: None,
472472
ip_address: None,
473473
location: None,
@@ -476,9 +476,9 @@ mod tests {
476476
id: i * 3 + 1,
477477
user_id: 100,
478478
event_type: "event_b".to_string(),
479-
timestamp: base_ts + (i as u64 * 1000) + 10,
479+
timestamp: base_ts + (i * 1000) + 10,
480480
attributes: HashMap::new(),
481-
session_id: Some(i as u64),
481+
session_id: Some(i),
482482
device_id: None,
483483
ip_address: None,
484484
location: None,
@@ -487,9 +487,9 @@ mod tests {
487487
id: i * 3 + 2,
488488
user_id: 100,
489489
event_type: "event_c".to_string(),
490-
timestamp: base_ts + (i as u64 * 1000) + 20,
490+
timestamp: base_ts + (i * 1000) + 20,
491491
attributes: HashMap::new(),
492-
session_id: Some(i as u64),
492+
session_id: Some(i),
493493
device_id: None,
494494
ip_address: None,
495495
location: None,
@@ -615,12 +615,12 @@ mod tests {
615615
let base_ts = 1700000000u64;
616616
let mut events = Vec::new();
617617

618-
for i in 0..20 {
618+
for i in 0u64..20 {
619619
events.push(UserEvent {
620620
id: i * 2,
621621
user_id: 100,
622622
event_type: "type_a".to_string(),
623-
timestamp: base_ts + (i as u64 * 100),
623+
timestamp: base_ts + (i * 100),
624624
attributes: HashMap::new(),
625625
session_id: None,
626626
device_id: None,
@@ -631,7 +631,7 @@ mod tests {
631631
id: i * 2 + 1,
632632
user_id: 100,
633633
event_type: "type_b".to_string(),
634-
timestamp: base_ts + (i as u64 * 100) + 10,
634+
timestamp: base_ts + (i * 100) + 10,
635635
attributes: HashMap::new(),
636636
session_id: None,
637637
device_id: None,

crates/rustkernel-behavioral/src/correlation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ mod tests {
585585
events
586586
.iter()
587587
.find(|e| e.id == c.correlated_event_id)
588-
.map_or(false, |e| e.user_id == 100)
588+
.is_some_and(|e| e.user_id == 100)
589589
})
590590
.collect();
591591

@@ -703,16 +703,16 @@ mod tests {
703703
fn test_causal_correlation_detection() {
704704
let base_ts = 1700000000u64;
705705
// Create events with consistent A->B pattern
706-
let events: Vec<UserEvent> = (0..10)
706+
let events: Vec<UserEvent> = (0u64..10)
707707
.flat_map(|i| {
708708
vec![
709709
UserEvent {
710710
id: i * 2,
711711
user_id: 100,
712712
event_type: "cause".to_string(),
713-
timestamp: base_ts + (i as u64 * 1000),
713+
timestamp: base_ts + (i * 1000),
714714
attributes: HashMap::new(),
715-
session_id: Some(i as u64),
715+
session_id: Some(i),
716716
device_id: None,
717717
ip_address: None,
718718
location: None,
@@ -721,9 +721,9 @@ mod tests {
721721
id: i * 2 + 1,
722722
user_id: 100,
723723
event_type: "effect".to_string(),
724-
timestamp: base_ts + (i as u64 * 1000) + 50, // Consistent 50s delay
724+
timestamp: base_ts + (i * 1000) + 50, // Consistent 50s delay
725725
attributes: HashMap::new(),
726-
session_id: Some(i as u64),
726+
session_id: Some(i),
727727
device_id: None,
728728
ip_address: None,
729729
location: None,

crates/rustkernel-clearing/src/netting.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,10 @@ mod tests {
544544
let mut trades = create_test_trades();
545545
trades[0].status = TradeStatus::Failed;
546546

547-
let mut config = NettingConfig::default();
548-
config.include_failed = true;
547+
let config = NettingConfig {
548+
include_failed: true,
549+
..NettingConfig::default()
550+
};
549551

550552
let result = NettingCalculation::calculate(&trades, &config);
551553

crates/rustkernel-clearing/src/settlement.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ pub enum SettlementPriority {
369369
#[cfg(test)]
370370
mod tests {
371371
use super::*;
372-
use std::collections::HashSet;
373372

374373
fn create_context() -> SettlementContext {
375374
let mut ctx = SettlementContext::default();

crates/rustkernel-clearing/src/validation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ mod tests {
436436
let mut trade = create_valid_trade();
437437
trade.buyer_id = "UNKNOWN".to_string();
438438

439-
let mut config = ValidationConfig::default();
440-
config.check_counterparty = false;
439+
let config = ValidationConfig {
440+
check_counterparty: false,
441+
..ValidationConfig::default()
442+
};
441443

442444
let context = create_context();
443445

crates/rustkernel-cli/src/main.rs

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
//! Provides commands for kernel management, discovery, and validation.
44
55
use clap::{Parser, Subcommand};
6-
use rustkernels::catalog::{DomainInfo, domains, enabled_domains, total_kernel_count};
76
use rustkernel_core::{
8-
config::ProductionConfig,
9-
domain::Domain,
10-
kernel::KernelMode,
11-
registry::KernelRegistry,
12-
resilience::HealthCheckResult,
13-
runtime::LifecycleState,
14-
traits::HealthStatus,
7+
config::ProductionConfig, domain::Domain, kernel::KernelMode, registry::KernelRegistry,
8+
resilience::HealthCheckResult, runtime::LifecycleState, traits::HealthStatus,
159
};
10+
use rustkernels::catalog::{DomainInfo, domains, enabled_domains, total_kernel_count};
1611
use std::path::PathBuf;
1712
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
1813

@@ -1046,7 +1041,10 @@ fn cmd_runtime(action: RuntimeAction) -> anyhow::Result<()> {
10461041
println!("Security Settings:");
10471042
println!(" RBAC Enabled: {}", config.security.rbac_enabled);
10481043
println!(" Audit Logging: {}", config.security.audit_logging);
1049-
println!(" Multi-Tenancy: {}", config.security.multi_tenancy_enabled);
1044+
println!(
1045+
" Multi-Tenancy: {}",
1046+
config.security.multi_tenancy_enabled
1047+
);
10501048
}
10511049

10521050
RuntimeAction::Init { preset } => {
@@ -1101,7 +1099,7 @@ fn cmd_health(format: &str, component: Option<String>) -> anyhow::Result<()> {
11011099
HealthStatus::Unknown => "unknown",
11021100
};
11031101
let comma = if i < filtered.len() - 1 { "," } else { "" };
1104-
println!(" \"{}\": \"{}\"{}",name, status, comma);
1102+
println!(" \"{}\": \"{}\"{}", name, status, comma);
11051103
}
11061104
println!(" }}");
11071105
println!("}}");
@@ -1113,15 +1111,33 @@ fn cmd_health(format: &str, component: Option<String>) -> anyhow::Result<()> {
11131111
for (name, result) in &filtered {
11141112
let (icon, status, details) = match result.status {
11151113
HealthStatus::Healthy => ("✓", "Healthy", String::new()),
1116-
HealthStatus::Degraded => ("⚠", "Degraded", result.error.clone().map(|e| format!(" - {}", e)).unwrap_or_default()),
1117-
HealthStatus::Unhealthy => ("✗", "Unhealthy", result.error.clone().map(|e| format!(" - {}", e)).unwrap_or_default()),
1114+
HealthStatus::Degraded => (
1115+
"⚠",
1116+
"Degraded",
1117+
result
1118+
.error
1119+
.clone()
1120+
.map(|e| format!(" - {}", e))
1121+
.unwrap_or_default(),
1122+
),
1123+
HealthStatus::Unhealthy => (
1124+
"✗",
1125+
"Unhealthy",
1126+
result
1127+
.error
1128+
.clone()
1129+
.map(|e| format!(" - {}", e))
1130+
.unwrap_or_default(),
1131+
),
11181132
HealthStatus::Unknown => ("?", "Unknown", String::new()),
11191133
};
11201134
println!(" {} {:<15} {}{}", icon, name, status, details);
11211135
}
11221136

11231137
println!();
1124-
let all_healthy = filtered.iter().all(|(_, r)| r.status == HealthStatus::Healthy);
1138+
let all_healthy = filtered
1139+
.iter()
1140+
.all(|(_, r)| r.status == HealthStatus::Healthy);
11251141
if all_healthy {
11261142
println!("Overall: ✓ All systems healthy");
11271143
} else {
@@ -1158,8 +1174,14 @@ fn cmd_config(action: ConfigAction) -> anyhow::Result<()> {
11581174
println!(" Max Instances: {}", config.runtime.max_kernel_instances);
11591175
println!();
11601176
println!("Memory:");
1161-
println!(" Max GPU Memory: {} bytes", config.memory.max_gpu_memory);
1162-
println!(" Max Staging Memory: {} bytes", config.memory.max_staging_memory);
1177+
println!(
1178+
" Max GPU Memory: {} bytes",
1179+
config.memory.max_gpu_memory
1180+
);
1181+
println!(
1182+
" Max Staging Memory: {} bytes",
1183+
config.memory.max_staging_memory
1184+
);
11631185
}
11641186

11651187
ConfigAction::Validate { file } => {
@@ -1230,7 +1252,9 @@ fn cmd_config(action: ConfigAction) -> anyhow::Result<()> {
12301252
println!(" RUSTKERNEL_MAX_GPU_MEMORY_GB Maximum GPU memory in GB");
12311253
println!();
12321254
println!("Example:");
1233-
println!(" RUSTKERNEL_ENV=production RUSTKERNEL_GPU_ENABLED=true rustkernel runtime init");
1255+
println!(
1256+
" RUSTKERNEL_ENV=production RUSTKERNEL_GPU_ENABLED=true rustkernel runtime init"
1257+
);
12341258
}
12351259
}
12361260

crates/rustkernel-compliance/src/ring_messages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,10 @@ mod tests {
652652
id: MessageId(2),
653653
source_kernel: 111,
654654
entity_id: 500,
655-
time_window_us: 3600_000_000, // 1 hour
655+
time_window_us: 3_600_000_000, // 1 hour
656656
};
657657
assert_eq!(msg.entity_id, 500);
658-
assert_eq!(msg.time_window_us, 3600_000_000);
658+
assert_eq!(msg.time_window_us, 3_600_000_000);
659659
}
660660

661661
#[test]

crates/rustkernel-core/src/config/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ impl ProductionConfig {
187187
if self.environment == "production" {
188188
// Production should have security enabled
189189
if !self.security.rbac_enabled && self.security.auth.is_none() {
190-
tracing::warn!(
191-
"Production environment without authentication or RBAC enabled"
192-
);
190+
tracing::warn!("Production environment without authentication or RBAC enabled");
193191
}
194192
}
195193

crates/rustkernel-core/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ pub enum KernelError {
119119
K2KError(String),
120120

121121
// Enterprise errors (0.3.1)
122-
123122
/// Unauthorized access.
124123
#[error("Unauthorized: {0}")]
125124
Unauthorized(String),

0 commit comments

Comments
 (0)