Skip to content

refactor: fix cargo lint checks for collapsible ifs and mismatched_lifetime_syntaxes #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ pub fn print_about(
current_version,
); // " " " "

if let Some(latest_release) = latest_release {
if latest_release.version > current_version {
print_latest_release(latest_release);
}
if let Some(latest_release) = latest_release
&& latest_release.version > current_version
{
print_latest_release(latest_release);
}

eprintln!(
Expand Down
9 changes: 4 additions & 5 deletions src/catalog/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,12 @@ pub fn create_from_parquet_file(
let columns = column_statistics(row_groups);
manifest_file.columns = columns.into_values().collect();
let mut sort_orders = sort_order(row_groups);
if let Some(last_sort_order) = sort_orders.pop() {
if sort_orders
if let Some(last_sort_order) = sort_orders.pop()
&& sort_orders
.into_iter()
.all(|sort_order| sort_order == last_sort_order)
{
manifest_file.sort_order_id = last_sort_order;
}
{
manifest_file.sort_order_id = last_sort_order;
}

Ok(manifest_file)
Expand Down
44 changes: 22 additions & 22 deletions src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,27 +268,27 @@ async fn create_manifest(
..Manifest::default()
};
let mut first_event_at = PARSEABLE.get_stream(stream_name)?.get_first_event();
if first_event_at.is_none() {
if let Some(first_event) = manifest.files.first() {
let time_partition = &meta.time_partition;
let lower_bound = match time_partition {
Some(time_partition) => {
let (lower_bound, _) = get_file_bounds(first_event, time_partition.to_string());
lower_bound
}
None => {
let (lower_bound, _) =
get_file_bounds(first_event, DEFAULT_TIMESTAMP_KEY.to_string());
lower_bound
}
};
first_event_at = Some(lower_bound.with_timezone(&Local).to_rfc3339());
match PARSEABLE.get_stream(stream_name) {
Ok(stream) => stream.set_first_event_at(first_event_at.as_ref().unwrap()),
Err(err) => error!(
"Failed to update first_event_at in streaminfo for stream {stream_name:?}, error = {err:?}"
),
if first_event_at.is_none()
&& let Some(first_event) = manifest.files.first()
{
let time_partition = &meta.time_partition;
let lower_bound = match time_partition {
Some(time_partition) => {
let (lower_bound, _) = get_file_bounds(first_event, time_partition.to_string());
lower_bound
}
None => {
let (lower_bound, _) =
get_file_bounds(first_event, DEFAULT_TIMESTAMP_KEY.to_string());
lower_bound
}
};
first_event_at = Some(lower_bound.with_timezone(&Local).to_rfc3339());
match PARSEABLE.get_stream(stream_name) {
Ok(stream) => stream.set_first_event_at(first_event_at.as_ref().unwrap()),
Err(err) => error!(
"Failed to update first_event_at in streaminfo for stream {stream_name:?}, error = {err:?}"
),
}
}

Expand Down Expand Up @@ -366,8 +366,8 @@ pub async fn get_first_event(
Mode::All | Mode::Ingest => {
// get current snapshot
let stream_first_event = PARSEABLE.get_stream(stream_name)?.get_first_event();
if stream_first_event.is_some() {
first_event_at = stream_first_event.unwrap();
if let Some(first_event) = stream_first_event {
first_event_at = first_event;
} else {
let mut meta = storage.get_object_store_format(stream_name).await?;
let meta_clone = meta.clone();
Expand Down
6 changes: 2 additions & 4 deletions src/event/format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ fn valid_type(

fn validate_int(value: &Value, static_schema_flag: bool) -> bool {
// allow casting string to int for static schema
if static_schema_flag {
if let Value::String(s) = value {
return s.trim().parse::<i64>().is_ok();
}
if static_schema_flag && let Value::String(s) = value {
return s.trim().parse::<i64>().is_ok();
}
value.is_i64()
}
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/http/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ pub async fn audit_log_middleware(
log_builder = log_builder.with_stream(message.common_attributes.x_p_stream);
} else if let Some(stream) = req.match_info().get("logstream") {
log_builder = log_builder.with_stream(stream);
} else if let Some(value) = req.headers().get(STREAM_NAME_HEADER_KEY) {
if let Ok(stream) = value.to_str() {
log_builder = log_builder.with_stream(stream);
}
} else if let Some(value) = req.headers().get(STREAM_NAME_HEADER_KEY)
&& let Ok(stream) = value.to_str()
{
log_builder = log_builder.with_stream(stream);
}

// Get username and authorization method
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ pub async fn delete(stream_name: Path<String>) -> Result<impl Responder, StreamE
)
}

if let Some(hot_tier_manager) = HotTierManager::global() {
if hot_tier_manager.check_stream_hot_tier_exists(&stream_name) {
hot_tier_manager.delete_hot_tier(&stream_name).await?;
}
if let Some(hot_tier_manager) = HotTierManager::global()
&& hot_tier_manager.check_stream_hot_tier_exists(&stream_name)
{
hot_tier_manager.delete_hot_tier(&stream_name).await?;
}

// Delete from memory
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/http/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub async fn get_counts(
let body = counts_request.into_inner();

// does user have access to table?
user_auth_for_datasets(&permissions, &[body.stream.clone()]).await?;
user_auth_for_datasets(&permissions, std::slice::from_ref(&body.stream)).await?;

// if the user has given a sql query (counts call with filters applied), then use this flow
// this could include filters or group by
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/livetail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn extract_basic_auth(header: &MetadataMap) -> Option<Credentials> {
.and_then(|value| Credentials::from_header(value.to_string()).ok())
}

fn extract_cookie(header: &MetadataMap) -> Option<Cookie> {
fn extract_cookie(header: &MetadataMap) -> Option<Cookie<'_>> {
// extract the cookie from the request
let cookies = header.get_all("cookie");
let cookies: Vec<_> = cookies
Expand Down
8 changes: 4 additions & 4 deletions src/livetail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ impl Stream for ReceiverPipe {
// drop sender on map when going out of scope
impl Drop for ReceiverPipe {
fn drop(&mut self) {
if let Some(map) = self._ref.upgrade() {
if let Some(pipes) = map.write().unwrap().get_mut(&self.stream) {
pipes.retain(|x| x.id != self.id)
}
if let Some(map) = self._ref.upgrade()
&& let Some(pipes) = map.write().unwrap().get_mut(&self.stream)
{
pipes.retain(|x| x.id != self.id)
}
}
}
Loading