Skip to content

Fix clippy warnings #603

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 1 commit into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lambda-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod test_adapter {

fn call(&mut self, event: LambdaEvent<LambdaRequest>) -> Self::Future {
// Log the request
println!("Lambda event: {:#?}", event);
println!("Lambda event: {event:#?}");

self.inner.call(event)
}
Expand Down
72 changes: 20 additions & 52 deletions lambda-http/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ mod tests {
// https://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-api-gateway-request
// note: file paths are relative to the directory of the crate at runtime
let result = from_reader(File::open("tests/data/apigw_proxy_request.json").expect("expected file"));
assert!(result.is_ok(), "event was not parsed as expected {:?}", result);
assert!(result.is_ok(), "event was not parsed as expected {result:?}");
}

#[test]
Expand All @@ -467,9 +467,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -479,8 +477,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::ApiGatewayV2(_)),
"expected ApiGatewayV2 context, got {:?}",
req_context
"expected ApiGatewayV2 context, got {req_context:?}"
);
}

Expand All @@ -492,9 +489,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
let cookie_header = req
Expand All @@ -511,8 +506,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::ApiGatewayV2(_)),
"expected ApiGatewayV2 context, got {:?}",
req_context
"expected ApiGatewayV2 context, got {req_context:?}"
);
}

Expand All @@ -525,9 +519,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -540,8 +532,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::ApiGatewayV1(_)),
"expected ApiGateway context, got {:?}",
req_context
"expected ApiGateway context, got {req_context:?}"
);
}

Expand All @@ -553,9 +544,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
let cookie_header = req
Expand All @@ -576,8 +565,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::ApiGatewayV2(_)),
"expected ApiGatewayV2 context, got {:?}",
req_context
"expected ApiGatewayV2 context, got {req_context:?}"
);
}

Expand All @@ -589,9 +577,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -604,8 +590,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::Alb(_)),
"expected Alb context, got {:?}",
req_context
"expected Alb context, got {req_context:?}"
);
}

Expand All @@ -617,9 +602,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -632,8 +615,7 @@ mod tests {
let req_context = req.request_context();
assert!(
matches!(req_context, RequestContext::Alb(_)),
"expected Alb context, got {:?}",
req_context
"expected Alb context, got {req_context:?}"
);
}

Expand All @@ -645,9 +627,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event is was not parsed as expected {:?} given {}",
result,
input
"event is was not parsed as expected {result:?} given {input}"
);
let request = result.expect("failed to parse request");

Expand All @@ -668,9 +648,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event is was not parsed as expected {:?} given {}",
result,
input
"event is was not parsed as expected {result:?} given {input}"
);
let request = result.expect("failed to parse request");
assert!(!request.query_string_parameters().is_empty());
Expand All @@ -690,9 +668,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event is was not parsed as expected {:?} given {}",
result,
input
"event is was not parsed as expected {result:?} given {input}"
);
let request = result.expect("failed to parse request");
assert!(!request.query_string_parameters().is_empty());
Expand All @@ -718,9 +694,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -734,9 +708,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -750,9 +722,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.method(), "GET");
Expand All @@ -766,9 +736,7 @@ mod tests {
let result = from_str(input);
assert!(
result.is_ok(),
"event was not parsed as expected {:?} given {}",
result,
input
"event was not parsed as expected {result:?} given {input}"
);
let req = result.expect("failed to parse request");
assert_eq!(req.uri(), "https://id.execute-api.us-east-1.amazonaws.com/my/path-with%20space?parameter1=value1&parameter1=value2&parameter2=value");
Expand Down
2 changes: 1 addition & 1 deletion lambda-runtime-api-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(clippy::all, clippy::cargo)]
#![warn(missing_docs, nonstandard_style, rust_2018_idioms)]
#![warn(clippy::multiple_crate_versions)]
#![allow(clippy::multiple_crate_versions)]

//! This crate includes a base HTTP client to interact with
//! the AWS Lambda Runtime API.
Expand Down
4 changes: 2 additions & 2 deletions lambda-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ mod endpoint_tests {
.body(Body::empty())
.expect("Unable to construct response");

let expected = format!("/2018-06-01/runtime/invocation/{}/response", id);
let expected = format!("/2018-06-01/runtime/invocation/{id}/response");
assert_eq!(expected, req.uri().path());

Ok(rsp)
}

#[cfg(test)]
async fn event_err(req: &Request<Body>, id: &str) -> Result<Response<Body>, Error> {
let expected = format!("/2018-06-01/runtime/invocation/{}/error", id);
let expected = format!("/2018-06-01/runtime/invocation/{id}/error");
assert_eq!(expected, req.uri().path());

assert_eq!(req.method(), Method::POST);
Expand Down
2 changes: 1 addition & 1 deletion lambda-runtime/src/simulated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl hyper::service::Service<Uri> for Connector {
fn call(&mut self, uri: Uri) -> Self::Future {
let res = match self.inner.lock() {
Ok(mut map) if map.contains_key(&uri) => Ok(map.remove(&uri).unwrap()),
Ok(_) => Err(format!("Uri {} is not in map", uri).into()),
Ok(_) => Err(format!("Uri {uri} is not in map").into()),
Err(_) => Err("mutex was poisoned".into()),
};
Box::pin(async move { res })
Expand Down