Skip to content

Commit e92adeb

Browse files
mivertowskiclaude
andcommitted
Fix clippy warnings and formatting issues
- Replace manual Default impls with #[derive(Default)] and #[default] on enum variants - Rename ambiguous `from_str` methods to `parse` to avoid confusion with FromStr trait - Prefix unused struct fields with underscore (audit, auth, tenancy) - Add #[allow(dead_code)] to internal diagnostic methods in rate_limiting - Add #[allow(clippy::field_reassign_with_default)] where struct mutation is necessary - Remove useless format! macro in observability - Fix effective_level to use longest prefix match (most specific) All 457 tests pass, clippy reports no warnings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9d6aea2 commit e92adeb

16 files changed

Lines changed: 453 additions & 336 deletions

File tree

Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ringkernel-core/src/alerting.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ impl AlertSeverity {
6565
/// Get a color for display (hex format).
6666
pub fn color(&self) -> &'static str {
6767
match self {
68-
Self::Info => "#2196F3", // Blue
69-
Self::Warning => "#FF9800", // Orange
70-
Self::Error => "#F44336", // Red
68+
Self::Info => "#2196F3", // Blue
69+
Self::Warning => "#FF9800", // Orange
70+
Self::Error => "#F44336", // Red
7171
Self::Critical => "#9C27B0", // Purple
7272
}
7373
}
@@ -199,7 +199,11 @@ impl Alert {
199199
let tags_str = if self.tags.is_empty() {
200200
String::new()
201201
} else {
202-
let tags: Vec<String> = self.tags.iter().map(|t| format!(r#""{}""#, escape_json(t))).collect();
202+
let tags: Vec<String> = self
203+
.tags
204+
.iter()
205+
.map(|t| format!(r#""{}""#, escape_json(t)))
206+
.collect();
203207
format!(r#","tags":[{}]"#, tags.join(","))
204208
};
205209

@@ -723,11 +727,7 @@ impl AlertRouter {
723727
for sink in &self.sinks {
724728
if sink.accepts_severity(alert.severity) {
725729
if let Err(e) = sink.send(&alert).await {
726-
tracing::error!(
727-
"Alert sink {} failed: {}",
728-
sink.sink_name(),
729-
e
730-
);
730+
tracing::error!("Alert sink {} failed: {}", sink.sink_name(), e);
731731
}
732732
}
733733
}
@@ -740,12 +740,7 @@ impl AlertRouter {
740740
self.alert_count.fetch_add(1, Ordering::Relaxed);
741741

742742
let source = alert.source.as_deref().unwrap_or("unknown");
743-
let msg = format!(
744-
"[ALERT] {} | {} | {}",
745-
alert.severity,
746-
source,
747-
alert.title
748-
);
743+
let msg = format!("[ALERT] {} | {} | {}", alert.severity, source, alert.title);
749744

750745
match alert.severity {
751746
AlertSeverity::Info => tracing::info!("{}", msg),
@@ -814,8 +809,7 @@ mod tests {
814809

815810
#[test]
816811
fn test_alert_json() {
817-
let alert = Alert::new(AlertSeverity::Error, "Test")
818-
.with_source("kernel_1");
812+
let alert = Alert::new(AlertSeverity::Error, "Test").with_source("kernel_1");
819813

820814
let json = alert.to_json();
821815
assert!(json.contains("ERROR"));
@@ -837,8 +831,7 @@ mod tests {
837831

838832
#[tokio::test]
839833
async fn test_in_memory_sink_severity_filter() {
840-
let sink = InMemorySink::new(10)
841-
.with_severity_filter(AlertSeverity::Error);
834+
let sink = InMemorySink::new(10).with_severity_filter(AlertSeverity::Error);
842835

843836
// Info alert should be filtered
844837
let info = Alert::new(AlertSeverity::Info, "Info");
@@ -854,11 +847,14 @@ mod tests {
854847
#[tokio::test]
855848
async fn test_alert_router() {
856849
let sink = Arc::new(InMemorySink::new(100));
857-
let router = AlertRouter::new()
858-
.with_sink_arc(sink.clone());
850+
let router = AlertRouter::new().with_sink_arc(sink.clone());
859851

860-
router.send(Alert::new(AlertSeverity::Warning, "Alert 1")).await;
861-
router.send(Alert::new(AlertSeverity::Error, "Alert 2")).await;
852+
router
853+
.send(Alert::new(AlertSeverity::Warning, "Alert 1"))
854+
.await;
855+
router
856+
.send(Alert::new(AlertSeverity::Error, "Alert 2"))
857+
.await;
862858

863859
assert_eq!(sink.count(), 2);
864860
assert_eq!(router.stats().total_alerts, 2);
@@ -876,10 +872,11 @@ mod tests {
876872

877873
// Send same alert multiple times with dedup key
878874
for _ in 0..5 {
879-
router.send(
880-
Alert::new(AlertSeverity::Warning, "Repeated alert")
881-
.with_dedup_key("same-key")
882-
).await;
875+
router
876+
.send(
877+
Alert::new(AlertSeverity::Warning, "Repeated alert").with_dedup_key("same-key"),
878+
)
879+
.await;
883880
}
884881

885882
// Only first should get through
@@ -889,8 +886,7 @@ mod tests {
889886

890887
#[tokio::test]
891888
async fn test_log_sink() {
892-
let sink = LogSink::new()
893-
.with_severity_filter(AlertSeverity::Warning);
889+
let sink = LogSink::new().with_severity_filter(AlertSeverity::Warning);
894890

895891
let info = Alert::new(AlertSeverity::Info, "Info");
896892
assert!(!sink.accepts_severity(info.severity));

crates/ringkernel-core/src/audit.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,12 @@ impl ElasticsearchSink {
946946

947947
let hlc_json = event
948948
.hlc
949-
.map(|h| format!(r#","hlc":{{"physical":{},"logical":{}}}"#, h.physical, h.logical))
949+
.map(|h| {
950+
format!(
951+
r#","hlc":{{"physical":{},"logical":{}}}"#,
952+
h.physical, h.logical
953+
)
954+
})
950955
.unwrap_or_default();
951956

952957
let target_json = event
@@ -996,17 +1001,21 @@ impl ElasticsearchSink {
9961001
}
9971002

9981003
let url = format!("{}/_bulk", self.config.url);
999-
let mut request = self.client.post(&url).body(bulk_body).header(
1000-
reqwest::header::CONTENT_TYPE,
1001-
"application/x-ndjson",
1002-
);
1004+
let mut request = self
1005+
.client
1006+
.post(&url)
1007+
.body(bulk_body)
1008+
.header(reqwest::header::CONTENT_TYPE, "application/x-ndjson");
10031009

10041010
if let Some((user, pass)) = &self.config.auth {
10051011
request = request.basic_auth(user, Some(pass));
10061012
}
10071013

10081014
request.send().map_err(|e| {
1009-
std::io::Error::new(std::io::ErrorKind::Other, format!("ES request failed: {}", e))
1015+
std::io::Error::new(
1016+
std::io::ErrorKind::Other,
1017+
format!("ES request failed: {}", e),
1018+
)
10101019
})?;
10111020

10121021
Ok(())
@@ -1075,7 +1084,7 @@ impl Default for CloudWatchConfig {
10751084
pub struct CloudWatchSink {
10761085
config: CloudWatchConfig,
10771086
buffer: Mutex<Vec<(u64, String)>>, // (timestamp_ms, message)
1078-
sequence_token: Mutex<Option<String>>,
1087+
_sequence_token: Mutex<Option<String>>,
10791088
}
10801089

10811090
impl CloudWatchSink {
@@ -1084,7 +1093,7 @@ impl CloudWatchSink {
10841093
Self {
10851094
config,
10861095
buffer: Mutex::new(Vec::new()),
1087-
sequence_token: Mutex::new(None),
1096+
_sequence_token: Mutex::new(None),
10881097
}
10891098
}
10901099

0 commit comments

Comments
 (0)