[ISSUE #241]Optimize the init command code (#242) #597
clippy
53 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 0 |
Warning | 53 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
- cargo 1.75.0-nightly (8eb8acbb1 2023-10-17)
- clippy 0.1.75 (1c05d50 2023-10-21)
Annotations
Check warning on line 454 in volo-grpc/src/status.rs
github-actions / clippy
use of `unwrap_or_else` to construct default value
warning: use of `unwrap_or_else` to construct default value
--> volo-grpc/src/status.rs:454:18
|
454 | .unwrap_or_else(Bytes::new);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
= note: `#[warn(clippy::unwrap_or_default)]` on by default
Check warning on line 159 in volo-thrift/src/codec/default/mod.rs
github-actions / clippy
try not to call a closure in the expression where it is declared
warning: try not to call a closure in the expression where it is declared
--> volo-thrift/src/codec/default/mod.rs:136:28
|
136 | let write_result = (|| async {
| ____________________________^
137 | | self.linked_bytes.reset();
138 | | // then we reserve the size of the message in the linked bytes
139 | | self.linked_bytes.reserve(malloc_size);
... |
158 | | Ok::<(), crate::Error>(())
159 | | })()
| |____________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call
= note: `#[warn(clippy::redundant_closure_call)]` on by default
help: try doing something like
|
136 ~ let write_result = async async {
137 + self.linked_bytes.reset();
138 + // then we reserve the size of the message in the linked bytes
139 + self.linked_bytes.reserve(malloc_size);
140 + // after that, we encode the message into the linked bytes
141 + self.encoder
142 + .encode(cx, &mut self.linked_bytes, msg)
143 + .map_err(|e| {
144 + // record the error time
145 + cx.stats_mut().record_encode_end_at();
146 + e
147 + })?;
148 +
149 + cx.stats_mut().record_encode_end_at();
150 + cx.stats_mut().record_write_start_at(); // encode end is also write start
151 +
152 + self.linked_bytes
153 + .write_all_vectored(&mut self.writer)
154 + .await
155 + .map_err(TransportError::from)?;
156 + self.writer.flush().await.map_err(TransportError::from)?;
157 +
158 + Ok::<(), crate::Error>(())
159 + }
|
Check warning on line 136 in volo-thrift/src/codec/default/ttheader.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo-thrift/src/codec/default/ttheader.rs:136:13
|
136 | return self.inner.decode_async(cx, reader).await;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
136 - return self.inner.decode_async(cx, reader).await;
136 + self.inner.decode_async(cx, reader).await
|
Check warning on line 140 in volo-thrift/src/codec/default/framed.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo-thrift/src/codec/default/framed.rs:140:13
|
140 | return self.inner.decode_async(cx, reader).await;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
140 - return self.inner.decode_async(cx, reader).await;
140 + self.inner.decode_async(cx, reader).await
|
Check warning on line 635 in volo-thrift/src/client/mod.rs
github-actions / clippy
using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> volo-thrift/src/client/mod.rs:602:13
|
602 | / cache
603 | | .pop()
604 | | .and_then(|mut cx| {
605 | | // The generated code only push the cx to the cache, we need to reset
... |
634 | | Some(cx)
635 | | })
| |__________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
= note: `#[warn(clippy::bind_instead_of_map)]` on by default
help: try
|
604 ~ .map(|mut cx| {
605 | // The generated code only push the cx to the cache, we need to reset
...
633 | cx.rpc_info_mut().method = Some(FastStr::from_static_str(method));
634 ~ cx
|
Check warning on line 540 in volo-thrift/src/transport/pool/mod.rs
github-actions / clippy
use of `or_insert_with` to construct default value
warning: use of `or_insert_with` to construct default value
--> volo-thrift/src/transport/pool/mod.rs:540:45
|
540 | let idle = self.idle.entry(key).or_insert_with(Vec::new);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
= note: `#[warn(clippy::unwrap_or_default)]` on by default
Check warning on line 37 in volo-thrift/src/transport/pingpong/server.rs
github-actions / clippy
this function has too many arguments (8/7)
warning: this function has too many arguments (8/7)
--> volo-thrift/src/transport/pingpong/server.rs:21:1
|
21 | / pub async fn serve<Svc, Req, Resp, E, D, SP>(
22 | | mut encoder: E,
23 | | mut decoder: D,
24 | | notified: Notified<'_>,
... |
36 | | D: Decoder,
37 | | SP: SpanProvider,
| |_____________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
= note: `#[warn(clippy::too_many_arguments)]` on by default
Check warning on line 163 in volo-build/src/thrift_backend.rs
github-actions / clippy
useless conversion to the same type: `volo::FastStr`
warning: useless conversion to the same type: `volo::FastStr`
--> volo-build/src/thrift_backend.rs:163:66
|
163 | let decode_item = helper.codegen_item_decode(args_name.clone().into());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `args_name.clone()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Check warning on line 62 in volo-build/src/thrift_backend.rs
github-actions / clippy
useless conversion to the same type: `volo::FastStr`
warning: useless conversion to the same type: `volo::FastStr`
--> volo-build/src/thrift_backend.rs:62:70
|
62 | let decode_variants = helper.codegen_item_decode(args_name.clone().into());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `args_name.clone()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
= note: `#[warn(clippy::useless_conversion)]` on by default
Check warning on line 53 in volo/src/client.rs
github-actions / clippy
this function can be simplified using the `async fn` syntax
warning: this function can be simplified using the `async fn` syntax
--> volo/src/client.rs:49:5
|
49 | / fn call<'cx>(
50 | | self,
51 | | cx: &'cx mut Cx,
52 | | req: Req,
53 | | ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
| |_________________________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
= note: `#[warn(clippy::manual_async_fn)]` on by default
help: make the function `async` and return the output of the future directly
|
49 ~ async fn call<'cx>(
50 + self,
51 + cx: &'cx mut Cx,
52 + req: Req,
53 ~ ) -> Result<Self::Response, Self::Error> {
|
help: move the body of the async block to the enclosing function
|
53 ~ ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
54 + self.opt.apply(cx)?;
55 + self.inner.call(cx, req).await
56 + }
|
Check warning on line 49 in volo/src/client.rs
github-actions / clippy
the following explicit lifetimes could be elided: 'cx
warning: the following explicit lifetimes could be elided: 'cx
--> volo/src/client.rs:49:13
|
49 | fn call<'cx>(
| ^^^
50 | self,
51 | cx: &'cx mut Cx,
| ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
|
49 ~ fn call'_>(
50 | self,
51 ~ cx: &mut Cx,
|
Check warning on line 30 in volo/src/client.rs
github-actions / clippy
the following explicit lifetimes could be elided: 'cx
warning: the following explicit lifetimes could be elided: 'cx
--> volo/src/client.rs:30:13
|
30 | fn call<'cx>(
| ^^^
31 | self,
32 | cx: &'cx mut Cx,
| ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
30 ~ fn call'_>(
31 | self,
32 ~ cx: &mut Cx,
|
Check warning on line 415 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:415:17
|
415 | return Err(e);
| ^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
415 - return Err(e);
415 + Err(e)
|
Check warning on line 412 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:409:17
|
409 | / return Err(io::Error::new(
410 | | io::ErrorKind::InvalidData,
411 | | "Not PassFdResponse",
412 | | ));
| |__________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
409 ~ Err(io::Error::new(
410 + io::ErrorKind::InvalidData,
411 + "Not PassFdResponse",
412 ~ ))
|
Check warning on line 406 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:406:17
|
406 | return Ok(Some(fd));
| ^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
406 - return Ok(Some(fd));
406 + Ok(Some(fd))
|
Check warning on line 279 in volo/src/hotrestart/mod.rs
github-actions / clippy
useless conversion to the same type: `std::io::Error`
warning: useless conversion to the same type: `std::io::Error`
--> volo/src/hotrestart/mod.rs:279:28
|
279 | return Err(e.into());
| ^^^^^^^^ help: consider removing `.into()`: `e`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
= note: `#[warn(clippy::useless_conversion)]` on by default
Check warning on line 279 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:279:17
|
279 | return Err(e.into());
| ^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
279 - return Err(e.into());
279 + Err(e.into())
|
Check warning on line 274 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:274:25
|
274 | return Err(io::Error::new(io::ErrorKind::InvalidData, e.message));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
274 - return Err(io::Error::new(io::ErrorKind::InvalidData, e.message));
274 + Err(io::Error::new(io::ErrorKind::InvalidData, e.message))
|
Check warning on line 270 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:270:29
|
270 | ... return Ok(HotRestartMessage::TerminateParentRequest);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
270 - return Ok(HotRestartMessage::TerminateParentRequest);
270 + Ok(HotRestartMessage::TerminateParentRequest)
|
Check warning on line 266 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:263:33
|
263 | / ... return Err(io::Error::new(
264 | | ... io::ErrorKind::InvalidData,
265 | | ... "PassFdResponse without fd",
266 | | ... ));
| |________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
263 ~ Err(io::Error::new(
264 + io::ErrorKind::InvalidData,
265 + "PassFdResponse without fd",
266 ~ ))
|
Check warning on line 261 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:261:33
|
261 | ... return Ok(HotRestartMessage::PassFdResponse(fd));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
261 - return Ok(HotRestartMessage::PassFdResponse(fd));
261 + Ok(HotRestartMessage::PassFdResponse(fd))
|
Check warning on line 250 in volo/src/hotrestart/mod.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> volo/src/hotrestart/mod.rs:250:29
|
250 | ... return Ok(HotRestartMessage::PassFdRequest(addr));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
250 - return Ok(HotRestartMessage::PassFdRequest(addr));
250 + Ok(HotRestartMessage::PassFdRequest(addr))
|
Check warning on line 117 in volo/src/hotrestart/mod.rs
github-actions / clippy
you should consider adding a `Default` implementation for `HotRestart`
warning: you should consider adding a `Default` implementation for `HotRestart`
--> volo/src/hotrestart/mod.rs:107:5
|
107 | / pub fn new() -> Self {
108 | | HotRestart {
109 | | state: Arc::new(Mutex::new(HotRestartState::Uninitalized)),
110 | | listener_fds: Arc::new(StdMutex::new(HashMap::new())),
... |
116 | | }
117 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
= note: `#[warn(clippy::new_without_default)]` on by default
help: try adding this
|
106 + impl Default for HotRestart {
107 + fn default() -> Self {
108 + Self::new()
109 + }
110 + }
|
Check warning on line 297 in volo/src/net/incoming.rs
github-actions / clippy
the borrowed expression implements the required traits
warning: the borrowed expression implements the required traits
--> volo/src/net/incoming.rs:297:34
|
297 | std::fs::remove_file(&path)?;
| ^^^^^ help: change this to: `path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
= note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default
Check warning on line 238 in volo/src/net/incoming.rs
github-actions / clippy
casting to the same type is unnecessary (`i32` -> `i32`)
warning: casting to the same type is unnecessary (`i32` -> `i32`)
--> volo/src/net/incoming.rs:238:13
|
238 | libc::SOMAXCONN as i32
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `libc::SOMAXCONN`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast