Skip to content

Commit 0328643

Browse files
authored
chore(internal events): Enable pedantic Clippy lints (#26613)
1 parent 7477209 commit 0328643

22 files changed

Lines changed: 100 additions & 29 deletions

‎src/internal_events/adaptive_concurrency.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ registered_event! {
2525
}
2626

2727
fn emit(&self, data: AdaptiveConcurrencyLimitData) {
28+
// https://github.com/vectordotdev/vector/issues/23659
29+
#[allow(
30+
clippy::cast_precision_loss,
31+
reason = "Metrics use f64"
32+
)]
2833
self.limit.record(data.concurrency as f64);
2934
let reached_limit = if data.reached_limit { 1.0 } else { Default::default() };
3035
self.reached_limit.record(reached_limit);
@@ -41,6 +46,11 @@ registered_event! {
4146
}
4247

4348
fn emit(&self, in_flight: u64) {
49+
// https://github.com/vectordotdev/vector/issues/23659
50+
#[allow(
51+
clippy::cast_precision_loss,
52+
reason = "Metrics use f64"
53+
)]
4454
self.in_flight.record(in_flight as f64);
4555
}
4656
}

‎src/internal_events/aggregate.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ mod tests {
7474
}
7575

7676
#[test]
77+
// https://github.com/vectordotdev/vector/issues/23659
78+
#[allow(clippy::float_cmp, reason = "Counters are exact integers")]
7779
fn emits_total_and_legacy_counters() {
7880
let metrics = capture_metrics(|| AggregateUpdateFailed.emit());
7981

‎src/internal_events/aws_sqs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod s3 {
2020
use vector_lib::histogram;
2121
use vector_lib::internal_event::HistogramName;
2222

23-
use super::*;
23+
use super::{CounterName, InternalEvent, NamedInternalEvent, counter, error_stage, error_type};
2424
use crate::sources::aws_s3::sqs::ProcessingError;
2525

2626
#[derive(Debug, NamedInternalEvent)]

‎src/internal_events/doris.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub struct DorisRowsLoaded {
1111
}
1212

1313
impl InternalEvent for DorisRowsLoaded {
14+
// https://github.com/vectordotdev/vector/issues/23659
15+
#[allow(clippy::cast_sign_loss, reason = "Input bounds audit deferred")]
1416
fn emit(self) {
1517
trace!(
1618
message = "Doris rows loaded successfully.",
@@ -33,6 +35,8 @@ pub struct DorisRowsFiltered {
3335
}
3436

3537
impl InternalEvent for DorisRowsFiltered {
38+
// https://github.com/vectordotdev/vector/issues/23659
39+
#[allow(clippy::cast_sign_loss, reason = "Input bounds audit deferred")]
3640
fn emit(self) {
3741
warn!(
3842
message = "Doris rows filtered during loading.",

‎src/internal_events/exec.rs‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,34 +148,30 @@ pub enum ExecFailedToSignalChild {
148148

149149
impl ExecFailedToSignalChild {
150150
fn to_error_code(&self) -> String {
151-
use ExecFailedToSignalChild::*;
152-
153151
match self {
154152
#[cfg(unix)]
155-
SignalError(err) => format!("errno_{err}"),
153+
Self::SignalError(err) => format!("errno_{err}"),
156154
#[cfg(unix)]
157-
FailedToMarshalPid(_) => String::from("failed_to_marshal_pid"),
155+
Self::FailedToMarshalPid(_) => String::from("failed_to_marshal_pid"),
158156
#[cfg(unix)]
159-
NoPid => String::from("no_pid"),
157+
Self::NoPid => String::from("no_pid"),
160158
#[cfg(windows)]
161-
IoError(err) => err.to_string(),
159+
Self::IoError(err) => err.to_string(),
162160
}
163161
}
164162
}
165163

166164
impl std::fmt::Display for ExecFailedToSignalChild {
167165
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
168-
use ExecFailedToSignalChild::*;
169-
170166
match self {
171167
#[cfg(unix)]
172-
SignalError(err) => write!(f, "errno: {err}"),
168+
Self::SignalError(err) => write!(f, "errno: {err}"),
173169
#[cfg(unix)]
174-
FailedToMarshalPid(err) => write!(f, "failed to marshal pid to i32: {err}"),
170+
Self::FailedToMarshalPid(err) => write!(f, "failed to marshal pid to i32: {err}"),
175171
#[cfg(unix)]
176-
NoPid => write!(f, "child had no pid"),
172+
Self::NoPid => write!(f, "child had no pid"),
177173
#[cfg(windows)]
178-
IoError(err) => write!(f, "io error: {err}"),
174+
Self::IoError(err) => write!(f, "io error: {err}"),
179175
}
180176
}
181177
}

‎src/internal_events/file.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub struct FileOpen {
3636
}
3737

3838
impl InternalEvent for FileOpen {
39+
// https://github.com/vectordotdev/vector/issues/23659
40+
#[allow(clippy::cast_precision_loss, reason = "Metrics use f64")]
3941
fn emit(self) {
4042
gauge!(GaugeName::OpenFiles).set(self.count as f64);
4143
}
@@ -502,6 +504,11 @@ mod source {
502504
}
503505

504506
impl InternalEvent for FileCheckpointed {
507+
// https://github.com/vectordotdev/vector/issues/23659
508+
#[allow(
509+
clippy::cast_possible_truncation,
510+
reason = "Bounds and overflow audit deferred"
511+
)]
505512
fn emit(self) {
506513
debug!(
507514
message = "Files checkpointed.",

‎src/internal_events/heartbeat.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub struct Heartbeat {
1313
}
1414

1515
impl InternalEvent for Heartbeat {
16+
// https://github.com/vectordotdev/vector/issues/23659
17+
#[allow(clippy::cast_precision_loss, reason = "Metrics use f64")]
1618
fn emit(self) {
1719
trace!(target: "vector", message = "Beep.");
1820
gauge!(GaugeName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64);

‎src/internal_events/http.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub struct HttpEventsReceived<'a> {
6969
}
7070

7171
impl InternalEvent for HttpEventsReceived<'_> {
72+
// https://github.com/vectordotdev/vector/issues/23659
73+
#[allow(clippy::cast_precision_loss, reason = "Metrics use f64")]
7274
fn emit(self) {
7375
trace!(
7476
message = "Events received.",
@@ -104,6 +106,7 @@ pub struct HttpBadRequest<'a> {
104106

105107
#[cfg(feature = "sources-utils-http")]
106108
impl<'a> HttpBadRequest<'a> {
109+
#[must_use]
107110
pub fn new(code: u16, message: &'a str) -> Self {
108111
Self {
109112
code,

‎src/internal_events/http_client.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn remove_sensitive(
296296
HeaderName::from_static("x-api-key"),
297297
HeaderName::from_static("api-key"),
298298
];
299-
for (name, value) in headers.iter_mut() {
299+
for (name, value) in &mut headers {
300300
if sensitive.contains(name) || extra.contains(name) {
301301
value.set_sensitive(true);
302302
}

‎src/internal_events/kafka.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ pub struct KafkaStatisticsReceived<'a> {
151151
}
152152

153153
impl InternalEvent for KafkaStatisticsReceived<'_> {
154+
// https://github.com/vectordotdev/vector/issues/23659
155+
#[allow(clippy::cast_precision_loss, reason = "Metrics use f64")]
156+
#[allow(clippy::cast_sign_loss, reason = "Input bounds audit deferred")]
154157
fn emit(self) {
155158
gauge!(GaugeName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64);
156159
gauge!(GaugeName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64);

0 commit comments

Comments
 (0)