Skip to content

Commit 9bd45c1

Browse files
authored
Fix clippy errors (#286)
Fix all clippy errors currently present. Additionally add clippy check to actions.
1 parent 5556ab2 commit 9bd45c1

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Rust
22

3-
on: [push, pull_request]
3+
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
build:
@@ -68,6 +68,17 @@ jobs:
6868
override: true
6969
- name: Run fmt check
7070
run: cargo fmt --all -- --check
71+
clippy:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v1
75+
- uses: actions-rs/toolchain@v1
76+
with:
77+
toolchain: nightly
78+
components: clippy
79+
override: true
80+
- name: Run clippy check
81+
run: cargo clippy
7182

7283
# publish rustdoc to a gh-pages branch on pushes to master
7384
# this can be helpful to those depending on the mainline branch

lambda-http/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "Apache-2.0"
99
homepage = "https://github.com/awslabs/aws-lambda-rust-runtime"
1010
repository = "https://github.com/awslabs/aws-lambda-rust-runtime"
1111
documentation = "https://docs.rs/lambda_runtime"
12+
categories = ["web-programming::http-server"]
1213
readme = "../README.md"
1314

1415
[badges]

lambda/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ description = "AWS Lambda Runtime"
66
edition = "2018"
77
license = "Apache License 2.0"
88
repository = "https://github.com/awslabs/aws-lambda-rust-runtime"
9+
categories = ["web-programming::http-server"]
10+
keywords = ["AWS", "Lambda", "API"]
911
readme = "../README.md"
1012

1113
[features]
@@ -16,20 +18,19 @@ simulated = []
1618
tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] }
1719
hyper = { version = "0.14", features = ["http1", "client", "server", "stream", "runtime"] }
1820
serde = { version = "1", features = ["derive"] }
19-
serde_json = "1.0.39"
21+
serde_json = "^1"
2022
bytes = "1.0"
2123
http = "0.2"
2224
async-stream = "0.3"
2325
futures = "0.3"
2426
tracing-error = "0.1.2"
2527
tracing = { version = "0.1", features = ["log"] }
26-
tracing-futures = "0.2"
2728
tower-service = "0.3"
2829
tokio-stream = "0.1.2"
2930

3031
[dev-dependencies]
3132
tracing-subscriber = "0.2"
3233
once_cell = "1.4.0"
3334
simple_logger = "1.6.0"
34-
log = "0.4"
35+
log = "^0.4"
3536
simple-error = "0.2"

lambda/src/client.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ where
3131
.scheme(scheme.clone())
3232
.authority(authority.clone())
3333
.path_and_query(path.clone())
34-
.build()
35-
.expect("Unable to build URI");
34+
.build();
3635

37-
parts.uri = uri;
38-
Ok(Request::from_parts(parts, body))
36+
match uri {
37+
Ok(u) => {
38+
parts.uri = u;
39+
Ok(Request::from_parts(parts, body))
40+
}
41+
Err(e) => Err(Box::new(e)),
42+
}
3943
}
4044

4145
pub(crate) async fn call(&self, req: Request<Body>) -> Result<Response<Body>, Error> {
@@ -178,7 +182,7 @@ mod endpoint_tests {
178182
tx.send(()).expect("Receiver has been dropped");
179183
match server.await {
180184
Ok(_) => Ok(()),
181-
Err(e) if e.is_panic() => return Err::<(), Error>(e.into()),
185+
Err(e) if e.is_panic() => Err::<(), Error>(e.into()),
182186
Err(_) => unreachable!("This branch shouldn't be reachable"),
183187
}
184188
}
@@ -209,7 +213,7 @@ mod endpoint_tests {
209213
tx.send(()).expect("Receiver has been dropped");
210214
match server.await {
211215
Ok(_) => Ok(()),
212-
Err(e) if e.is_panic() => return Err::<(), Error>(e.into()),
216+
Err(e) if e.is_panic() => Err::<(), Error>(e.into()),
213217
Err(_) => unreachable!("This branch shouldn't be reachable"),
214218
}
215219
}
@@ -242,7 +246,7 @@ mod endpoint_tests {
242246
tx.send(()).expect("Receiver has been dropped");
243247
match server.await {
244248
Ok(_) => Ok(()),
245-
Err(e) if e.is_panic() => return Err::<(), Error>(e.into()),
249+
Err(e) if e.is_panic() => Err::<(), Error>(e.into()),
246250
Err(_) => unreachable!("This branch shouldn't be reachable"),
247251
}
248252
}
@@ -277,7 +281,7 @@ mod endpoint_tests {
277281
tx.send(()).expect("Receiver has been dropped");
278282
match server.await {
279283
Ok(_) => Ok(()),
280-
Err(e) if e.is_panic() => return Err::<(), Error>(e.into()),
284+
Err(e) if e.is_panic() => Err::<(), Error>(e.into()),
281285
Err(_) => unreachable!("This branch shouldn't be reachable"),
282286
}
283287
}

lambda/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ where
156156

157157
let handler = Arc::clone(&handler);
158158
let request_id = &ctx.request_id.clone();
159+
#[allow(clippy::async_yields_async)]
159160
let task = tokio::spawn(async move { handler.call(body, ctx) });
160161

161162
let req = match task.await {

0 commit comments

Comments
 (0)