Skip to content

Commit

Permalink
Fix Needless Return
Browse files Browse the repository at this point in the history
  • Loading branch information
djnovin committed Oct 10, 2024
1 parent 1db0bfe commit bdd04ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
cognitive-complexity-threshold = 1337

# Allow needless return globally
allow = ["clippy::needless_return"]
10 changes: 5 additions & 5 deletions src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ pub async fn verify_key(
Ok(res)
} else {
log::info!("Rate limit exceeded. Resets at: {:?}", rate_limit_result.reset);
return Err(actix_web::error::ErrorTooManyRequests("Rate limit exceeded"));
Err(actix_web::error::ErrorTooManyRequests("Rate limit exceeded"))
}
} else {
log::error!("Rate limit response missing 'remaining' field");
return Err(actix_web::error::ErrorInternalServerError(
Err(actix_web::error::ErrorInternalServerError(
"Invalid rate limit response",
));
))
}
} else {
// Parse the error response
Expand All @@ -111,10 +111,10 @@ pub async fn verify_key(
error_response.error.request_id
);

return Err(actix_web::error::ErrorBadRequest(format!(
Err(actix_web::error::ErrorBadRequest(format!(
"Rate limit request failed: {} (Request ID: {})",
error_response.error.message, error_response.error.request_id
)));
)))
}
}
Ok(res) => {
Expand Down

0 comments on commit bdd04ff

Please sign in to comment.