Skip to content

Commit 766ed24

Browse files
ismoilovdevmlclaude
andcommitted
πŸ”§ Fix CI/CD: Resolve All Clippy Warnings for GitHub Actions
## 🎯 Fixed Issues ### Clippy Errors Fixed (15 total): 1. **double_ended_iterator_last** (src/acme.rs:141) - Changed `.last()` β†’ `.next_back()` for better performance - Avoids needless iteration through entire iterator 2. **needless_borrow** (3 occurrences) - src/algorithms/least_connection.rs:60 - src/algorithms/sticky_cookie.rs:77 - src/middleware/mod.rs:128 (2x) - Removed unnecessary `&` references 3. **io_other_error** (src/configuration.rs:269) - Changed `io::Error::new(Other, e)` β†’ `io::Error::other(e)` - Uses newer Rust idiom 4. **bool_assert_comparison** (2 occurrences) - src/backend_pool_matcher.rs:407-408 - Changed `assert_eq!(x, true)` β†’ `assert!(x)` 5. **upper_case_acronyms** (4 occurrences) - src/configuration.rs:541 - `ACME` enum variant - src/middleware/compression.rs:73-75 - `BROTLI`, `DEFLATE`, `GZIP` - Added `#[allow(clippy::upper_case_acronyms)]` annotations 6. **option_filter_map** (src/middleware/custom_error_pages.rs:44) - Changed `.filter(is_some).map(unwrap)` β†’ `.filter_map()` - More idiomatic and efficient 7. **map_flatten** (src/middleware/custom_error_pages.rs:43) - Changed `.map(as_integer).flatten()` β†’ `.filter_map(as_integer)` - Single-pass iteration 8. **result_large_err** (src/middleware/https_redirector.rs:52) - Added `#[allow(clippy::result_large_err)]` for Response<Body> - Error type is 160 bytes but necessary for API ## βœ… Verification Results All CI checks now pass: - βœ… `cargo fmt --check` - Clean - βœ… `cargo clippy -D warnings` - 0 errors - βœ… `cargo build --release` - Success (10MB binary) - βœ… `cargo test` - 24/24 passing ## πŸ“¦ Files Changed (9 files) - src/acme.rs - Iterator optimization - src/algorithms/least_connection.rs - Remove needless borrow - src/algorithms/sticky_cookie.rs - Remove needless borrow - src/backend_pool_matcher.rs - Simplify bool assertions - src/configuration.rs - io::Error idiom + ACME annotation - src/middleware/compression.rs - Enum annotations + needless borrow - src/middleware/custom_error_pages.rs - filter_map optimization - src/middleware/https_redirector.rs - Allow large error type - src/middleware/mod.rs - Remove needless borrows ## πŸš€ Impact - **Code Quality:** Follows latest Rust idioms and best practices - **Performance:** Iterator optimizations reduce unnecessary allocations - **CI/CD:** GitHub Actions will now pass all checks - **Maintainability:** Cleaner, more idiomatic Rust code πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9ba84c6 commit 766ed24

File tree

9 files changed

+12
-11
lines changed

9 files changed

+12
-11
lines changed

β€Žsrc/acme.rsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl AcmeHandler {
138138
if !self.is_challenge(request) {
139139
None
140140
} else {
141-
Some(request.uri().path().split('/').last().map_or_else(
141+
Some(request.uri().path().split('/').next_back().map_or_else(
142142
|| bad_request("Unable to extract token from last path param!"),
143143
|token| {
144144
self.get_proof_for_challenge(token)

β€Žsrc/algorithms/least_connection.rsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl LoadBalancingStrategy for LeastConnection {
5757
// Fall back to random if there's a tie.
5858
let mut rng = thread_rng();
5959
let index = rng.gen_range(0..context.backend_addresses.len());
60-
RequestForwarder::new(&context.backend_addresses[index])
60+
RequestForwarder::new(context.backend_addresses[index])
6161
}
6262
}
6363
}

β€Žsrc/algorithms/sticky_cookie.rsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl LoadBalancingStrategy for StickyCookie {
7474
request: &Request<Body>,
7575
context: &'l Context<'l>,
7676
) -> RequestForwarder<'l> {
77-
let backend_address = self.try_parse_sticky_cookie(&request).and_then(|cookie| {
77+
let backend_address = self.try_parse_sticky_cookie(request).and_then(|cookie| {
7878
context
7979
.backend_addresses
8080
.iter()

β€Žsrc/backend_pool_matcher.rsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ mod tests {
404404
Box::new(BackendPoolMatcher::Query("admin".into(), "true".into())),
405405
);
406406

407-
assert_eq!(matcher.matches(&request_1), true);
408-
assert_eq!(matcher.matches(&request_2), true);
407+
assert!(matcher.matches(&request_1));
408+
assert!(matcher.matches(&request_2));
409409
}
410410
}

β€Žsrc/configuration.rsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn other<E>(error: E) -> io::Error
266266
where
267267
E: Into<Box<dyn Error + Send + Sync>>,
268268
{
269-
io::Error::new(io::ErrorKind::Other, error)
269+
io::Error::other(error)
270270
}
271271

272272
pub struct RuntimeConfig {
@@ -538,6 +538,7 @@ pub enum CertificateConfig {
538538
certificate_path: String,
539539
private_key_path: String,
540540
},
541+
#[allow(clippy::upper_case_acronyms)]
541542
ACME {
542543
staging: bool,
543544
email: String,

β€Žsrc/middleware/compression.rsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl Compression {
6969
}
7070

7171
#[derive(Debug, PartialEq)]
72+
#[allow(clippy::upper_case_acronyms)]
7273
enum Encoding {
7374
BROTLI,
7475
DEFLATE,
@@ -127,7 +128,7 @@ fn get_preferred_encoding(headers: &HeaderMap) -> Option<Encoding> {
127128

128129
fn parse_encoding_and_qvalue(encoding_and_qvalue: &str) -> Option<(Encoding, u32)> {
129130
let (encoding, qvalue) =
130-
split_once(encoding_and_qvalue, ';').unwrap_or((encoding_and_qvalue, &"q=1"));
131+
split_once(encoding_and_qvalue, ';').unwrap_or((encoding_and_qvalue, "q=1"));
131132
let encoding = Encoding::from_str(encoding)?;
132133
let qvalue = parse_qvalue(qvalue)?;
133134
Some((encoding, qvalue))

β€Žsrc/middleware/custom_error_pages.rsβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ impl TryFrom<Table> for CustomErrorPages {
4040
.as_array()
4141
.ok_or(())?
4242
.iter()
43-
.map(|x| x.as_integer())
44-
.filter(|x| x.is_some())
45-
.map(|x| x.unwrap())
43+
.filter_map(|x| x.as_integer())
4644
.map(|x| x as u16)
4745
.collect::<Vec<_>>();
4846

β€Žsrc/middleware/https_redirector.rsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl Middleware for HttpsRedirector {
4949
}
5050
}
5151

52+
#[allow(clippy::result_large_err)]
5253
fn parse_host_header(request: &Request<Body>) -> Result<Authority, Response<Body>> {
5354
request
5455
.headers()

β€Žsrc/middleware/mod.rsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl MiddlewareChain {
125125
) -> Response<Body> {
126126
match self {
127127
MiddlewareChain::Entry { middleware, chain } => {
128-
middleware.forward_request(request, &chain, &context).await
128+
middleware.forward_request(request, chain, context).await
129129
}
130130
MiddlewareChain::Empty => {
131131
let backend_request = backend_request(request, context);

0 commit comments

Comments
Β (0)