Skip to content

Commit 4ab01ea

Browse files
committed
Fix clippy warnings
1 parent d55aba9 commit 4ab01ea

23 files changed

Lines changed: 58 additions & 68 deletions

File tree

quickwit/quickwit-actors/src/registry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ impl ActorRegistry {
166166

167167
pub fn get_one<A: Actor>(&self) -> Option<Mailbox<A>> {
168168
let mut lock = self.actors.write().unwrap();
169-
let opt = get_iter::<A>(&mut lock).next();
170-
opt
169+
get_iter::<A>(&mut lock).next()
171170
}
172171

173172
fn gc(&self) {

quickwit/quickwit-cli/src/index.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,12 @@ impl IndexStats {
785785
tables.push(size_stats_table);
786786
}
787787

788-
let table = Table::builder(tables.into_iter().map(|table| table.to_string()))
788+
Table::builder(tables.into_iter().map(|table| table.to_string()))
789789
.build()
790790
.with(Modify::new(Segment::all()).with(Alignment::center_vertical()))
791791
.with(Disable::row(FirstRow))
792792
.with(Style::empty())
793-
.to_string();
794-
795-
table
793+
.to_string()
796794
}
797795
}
798796

quickwit/quickwit-common/src/io.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ impl IoControls {
125125

126126
pub fn check_if_alive(&self) -> io::Result<ProtectedZoneGuard> {
127127
if self.kill_switch.is_dead() {
128-
return Err(io::Error::new(
129-
io::ErrorKind::Other,
130-
"Directory kill switch was activated.",
131-
));
128+
return Err(io::Error::other("directory kill switch was activated"));
132129
}
133130
let guard = self.progress.protect_zone();
134131
Ok(guard)

quickwit/quickwit-common/src/net.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,9 @@ fn _get_hostname(hostname: OsString) -> io::Result<String> {
327327
if is_valid_hostname(&hostname_lossy) {
328328
Ok(hostname_lossy.to_string())
329329
} else {
330-
Err(io::Error::new(
331-
io::ErrorKind::Other,
332-
format!("invalid hostname: `{hostname_lossy}`"),
333-
))
330+
Err(io::Error::other(format!(
331+
"invalid hostname: `{hostname_lossy}`"
332+
)))
334333
}
335334
}
336335

quickwit/quickwit-directories/src/bundle_directory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ impl BundleDirectory {
113113
pub fn open_split(split_file: FileSlice) -> io::Result<BundleDirectory> {
114114
// First we remove the hotcache from our file slice.
115115
let (body_and_bundle_metadata, _hot_cache) = split_footer(split_file)?;
116-
BundleDirectory::open_bundle(body_and_bundle_metadata)
117-
.map_err(|anyhow_err| io::Error::new(io::ErrorKind::Other, anyhow_err))
116+
BundleDirectory::open_bundle(body_and_bundle_metadata).map_err(io::Error::other)
118117
}
119118

120119
/// Opens a BundleDirectory, given a file containing the bundle data.

quickwit/quickwit-directories/src/storage_directory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ impl StorageDirectory {
111111
}
112112

113113
fn unsupported_operation(path: &Path) -> io::Error {
114-
let msg = "Unsupported operation. StorageDirectory only supports async reads";
115-
error!(path=?path, msg);
116-
io::Error::new(io::ErrorKind::Other, format!("{msg}: {path:?}"))
114+
let error = "unsupported operation: `StorageDirectory` only supports async reads";
115+
error!(error, ?path);
116+
io::Error::other(format!("{error}: {}", path.display()))
117117
}
118118

119119
impl Directory for StorageDirectory {

quickwit/quickwit-indexing/src/source/file_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::source::{Source, SourceContext, SourceRuntime, TypedSourceFactory};
3030

3131
enum FileSourceState {
3232
#[cfg(feature = "queue-sources")]
33-
Notification(QueueCoordinator),
33+
Notification(Box<QueueCoordinator>),
3434
Filepath {
3535
batch_reader: ObjectUriBatchReader,
3636
num_bytes_processed: u64,
@@ -180,7 +180,7 @@ impl TypedSourceFactory for FileSourceFactory {
180180
)) => {
181181
let coordinator =
182182
QueueCoordinator::try_from_sqs_config(sqs_config, source_runtime).await?;
183-
FileSourceState::Notification(coordinator)
183+
FileSourceState::Notification(Box::new(coordinator))
184184
}
185185
#[cfg(not(feature = "sqs"))]
186186
FileSourceParams::Notifications(quickwit_config::FileSourceNotification::Sqs(_)) => {

quickwit/quickwit-indexing/src/source/kafka_source.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,10 @@ mod kafka_broker_tests {
785785
}
786786

787787
fn create_admin_client() -> AdminClient<DefaultClientContext> {
788-
let admin_client = ClientConfig::new()
788+
ClientConfig::new()
789789
.set("bootstrap.servers", "localhost:9092")
790790
.create()
791-
.unwrap();
792-
admin_client
791+
.unwrap()
793792
}
794793

795794
async fn create_topic(

quickwit/quickwit-ingest/src/mrecordlog_async.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ impl MultiRecordLogAsync {
5959
.await
6060
.map_err(|join_err| {
6161
error!(error=?join_err, "failed to load WAL");
62-
ReadRecordError::IoError(io::Error::new(
63-
io::ErrorKind::Other,
64-
"loading wal from directory failed",
65-
))
62+
ReadRecordError::IoError(io::Error::other("loading wal from directory failed"))
6663
})??;
6764
Ok(Self {
6865
mrecordlog_opt: Some(mrecordlog),

quickwit/quickwit-jaeger/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ fn build_aggregations_query(num_traces: usize) -> String {
756756
query
757757
}
758758

759+
#[allow(clippy::result_large_err)]
759760
fn qw_span_to_jaeger_span(qw_span_json: &str) -> Result<JaegerSpan, Status> {
760761
let mut qw_span: QwSpan = json_deserialize(qw_span_json, "span")?;
761762

@@ -1027,6 +1028,7 @@ fn otlp_attributes_to_jaeger_tags_inner(
10271028

10281029
/// Converts OpenTelemetry links to Jaeger span references.
10291030
/// <https://opentelemetry.io/docs/specs/otel/trace/sdk_exporters/jaeger/#links>
1031+
#[allow(clippy::result_large_err)]
10301032
fn otlp_links_to_jaeger_references(
10311033
trace_id: &TraceId,
10321034
parent_span_id_opt: Option<SpanId>,
@@ -1058,6 +1060,7 @@ fn otlp_links_to_jaeger_references(
10581060
Ok(references)
10591061
}
10601062

1063+
#[allow(clippy::result_large_err)]
10611064
fn qw_event_to_jaeger_log(event: QwEvent) -> Result<JaegerLog, Status> {
10621065
let timestamp = to_well_known_timestamp(event.event_timestamp_nanos);
10631066
// "OpenTelemetry Event’s name field should be added to Jaeger Log’s fields map as follows: name
@@ -1087,6 +1090,7 @@ fn qw_event_to_jaeger_log(event: QwEvent) -> Result<JaegerLog, Status> {
10871090
Ok(log)
10881091
}
10891092

1093+
#[allow(clippy::result_large_err)]
10901094
fn collect_trace_ids(
10911095
trace_ids_postcard: &[u8],
10921096
) -> Result<(Vec<TraceId>, TimeIntervalSecs), Status> {
@@ -1107,6 +1111,7 @@ fn collect_trace_ids(
11071111
Ok((trace_ids, start..=end))
11081112
}
11091113

1114+
#[allow(clippy::result_large_err)]
11101115
fn json_deserialize<'a, T>(json: &'a str, label: &'static str) -> Result<T, Status>
11111116
where T: Deserialize<'a> {
11121117
match serde_json::from_str(json) {
@@ -1120,6 +1125,7 @@ where T: Deserialize<'a> {
11201125
}
11211126
}
11221127

1128+
#[allow(clippy::result_large_err)]
11231129
fn postcard_deserialize<'a, T>(json: &'a [u8], label: &'static str) -> Result<T, Status>
11241130
where T: Deserialize<'a> {
11251131
match postcard::from_bytes(json) {

0 commit comments

Comments
 (0)