feat:完善配置中心客户端逻辑 #3
clippy
2 errors, 269 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 2 |
Warning | 269 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.82.0 (f6e511eec 2024-10-15)
- cargo 1.82.0 (8f40fc59f 2024-08-21)
- clippy 0.1.82 (f6e511e 2024-10-15)
Annotations
Check warning on line 16 in src/plugins/location/remotehttp/mod.rs
github-actions / clippy
module has the same name as its containing module
warning: module has the same name as its containing module
--> src/plugins/location/remotehttp/mod.rs:16:1
|
16 | pub mod remotehttp;
| ^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
Check warning on line 60 in src/plugins/location/local/local.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/plugins/location/local/local.rs:60:9
|
60 | return self.loc_cache.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
60 - return self.loc_cache.clone();
60 + self.loc_cache.clone()
|
Check warning on line 16 in src/plugins/location/local/mod.rs
github-actions / clippy
module has the same name as its containing module
warning: module has the same name as its containing module
--> src/plugins/location/local/mod.rs:16:1
|
16 | pub mod local;
| ^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
Check warning on line 158 in src/plugins/loadbalance/roundrobin/roundrobin.rs
github-actions / clippy
returning the result of a `let` binding from a block
warning: returning the result of a `let` binding from a block
--> src/plugins/loadbalance/roundrobin/roundrobin.rs:158:9
|
154 | / let cur_weight = self.cur_weight.fetch_add(
155 | | self.weight.load(std::sync::atomic::Ordering::Relaxed),
156 | | std::sync::atomic::Ordering::Relaxed,
157 | | );
| |__________- unnecessary `let` binding
158 | cur_weight
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
help: return the expression directly
|
154 ~
155 ~ self.cur_weight.fetch_add(
156 + self.weight.load(std::sync::atomic::Ordering::Relaxed),
157 + std::sync::atomic::Ordering::Relaxed,
158 + )
|
Check warning on line 96 in src/plugins/loadbalance/roundrobin/roundrobin.rs
github-actions / clippy
you seem to use `.enumerate()` and immediately discard the index
warning: you seem to use `.enumerate()` and immediately discard the index
--> src/plugins/loadbalance/roundrobin/roundrobin.rs:96:25
|
96 | for (_, ins) in instances.instances.iter().enumerate() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
|
96 | for ins in instances.instances.iter() {
| ~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Check warning on line 73 in src/plugins/loadbalance/roundrobin/roundrobin.rs
github-actions / clippy
casting to the same type is unnecessary (`u32` -> `u32`)
warning: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/plugins/loadbalance/roundrobin/roundrobin.rs:73:72
|
73 | ... .or_insert_with(|| WeightedRoundRobin::new(instance.weight as u32));
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `instance.weight`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `#[warn(clippy::unnecessary_cast)]` on by default
Check warning on line 16 in src/plugins/loadbalance/roundrobin/mod.rs
github-actions / clippy
module has the same name as its containing module
warning: module has the same name as its containing module
--> src/plugins/loadbalance/roundrobin/mod.rs:16:1
|
16 | pub mod roundrobin;
| ^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
Check warning on line 16 in src/plugins/loadbalance/ringhash/mod.rs
github-actions / clippy
module has the same name as its containing module
warning: module has the same name as its containing module
--> src/plugins/loadbalance/ringhash/mod.rs:16:1
|
16 | pub mod ringhash;
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
Check warning on line 16 in src/plugins/loadbalance/random/mod.rs
github-actions / clippy
module has the same name as its containing module
warning: module has the same name as its containing module
--> src/plugins/loadbalance/random/mod.rs:16:1
|
16 | pub mod random;
| ^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
Check warning on line 166 in src/plugins/filter/configcrypto/crypto.rs
github-actions / clippy
unneeded late initialization
warning: unneeded late initialization
--> src/plugins/filter/configcrypto/crypto.rs:166:9
|
166 | let data_key: String;
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
= note: `#[warn(clippy::needless_late_init)]` on by default
help: move the declaration `data_key` here and remove the assignments from the `match` arms
|
166 ~
167 ~ let data_key: String = match encrypt_data_key {
168 | Ok(key) => {
169 ~ key
170 | }
...
178 | .unwrap();
179 ~ String::from_utf8(u8_slice).unwrap()
180 | }
181 ~ };
|
Check warning on line 111 in src/plugins/filter/configcrypto/crypto.rs
github-actions / clippy
very complex type used. Consider factoring parts into `type` definitions
warning: very complex type used. Consider factoring parts into `type` definitions
--> src/plugins/filter/configcrypto/crypto.rs:108:25
|
108 | pub fn builder() -> (
| _________________________^
109 | | fn(serde_yaml::Value) -> Result<Box<dyn DiscoverFilter>, PolarisError>,
110 | | String,
111 | | ) {
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
Check warning on line 70 in src/plugins/filter/configcrypto/crypto.rs
github-actions / clippy
you seem to use `.enumerate()` and immediately discard the index
warning: you seem to use `.enumerate()` and immediately discard the index
--> src/plugins/filter/configcrypto/crypto.rs:70:20
|
70 | for (_k, v) in conf.entries.iter().enumerate() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
|
70 | for v in conf.entries.iter() {
| ~ ~~~~~~~~~~~~~~~~~~~
Check warning on line 465 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
returning the result of a `let` binding from a block
warning: returning the result of a `let` binding from a block
--> src/plugins/connector/grpc/manager.rs:465:9
|
464 | let addr = self.endpoint.format_address();
| ------------------------------------------ unnecessary `let` binding
465 | addr
| ^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
help: return the expression directly
|
464 ~
465 ~ self.endpoint.format_address()
|
Check warning on line 411 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/plugins/connector/grpc/manager.rs:411:9
|
411 | return true;
| ^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
411 - return true;
411 + true
|
Check warning on line 391 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/plugins/connector/grpc/manager.rs:373:9
|
373 | / match self.sender.as_ref() {
374 | | Some(sender) => {
375 | | futures::executor::block_on(async {
376 | | let ret = sender
... |
390 | | None => {}
391 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
|
373 ~ if let Some(sender) = self.sender.as_ref() {
374 + futures::executor::block_on(async {
375 + let ret = sender
376 + .send(Change::Remove(self.conn_id.format_address()))
377 + .await;
378 + match ret {
379 + Ok(_) => {}
380 + Err(err) => {
381 + error!(
382 + "notify tonic insert polaris-server node address fail: {}",
383 + err
384 + )
385 + }
386 + }
387 + });
388 + }
|
Check failure on line 366 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> src/plugins/connector/grpc/manager.rs:366:26
|
366 | let need_close = self.ref_cnt.load(SeqCst) <= 0 && !self.closed.load(SeqCst);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `self.ref_cnt.load(SeqCst) == 0` instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
Check failure on line 359 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> src/plugins/connector/grpc/manager.rs:359:12
|
359 | if cur_ref <= 0 {
| ^^^^^^^^^^^^
|
= help: because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `cur_ref == 0` instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
= note: `#[deny(clippy::absurd_extreme_comparisons)]` on by default
Check warning on line 268 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
using `clone` on type `ClusterType` which implements the `Copy` trait
warning: using `clone` on type `ClusterType` which implements the `Copy` trait
--> src/plugins/connector/grpc/manager.rs:268:28
|
268 | .with_cluster_type(conn_mgr.cluster.clone())
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `conn_mgr.cluster`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
Check warning on line 263 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/plugins/connector/grpc/manager.rs:257:5
|
257 | / match conn_mgr.service_info.as_ref() {
258 | | Some(svc_info) => {
259 | | ns = svc_info.namespace.clone().unwrap();
260 | | svc = svc_info.service.clone().unwrap();
261 | | }
262 | | None => {}
263 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
|
257 ~ if let Some(svc_info) = conn_mgr.service_info.as_ref() {
258 + ns = svc_info.namespace.clone().unwrap();
259 + svc = svc_info.service.clone().unwrap();
260 + }
|
Check warning on line 236 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/plugins/connector/grpc/manager.rs:233:17
|
233 | / match cur_conn {
234 | | Some(conn) => conn.lazy_destroy(),
235 | | None => {}
236 | | }
| |_________________^ help: try: `if let Some(conn) = cur_conn { conn.lazy_destroy() }`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
Check warning on line 215 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/plugins/connector/grpc/manager.rs:207:9
|
207 | / match cur_conn_opt {
208 | | Some(cur_conn) => {
209 | | if !cur_conn.conn_id.eq(last_conn_id) {
210 | | return;
... |
214 | | None => {}
215 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
= note: `#[warn(clippy::single_match)]` on by default
help: try
|
207 ~ if let Some(cur_conn) = cur_conn_opt {
208 + if !cur_conn.conn_id.eq(last_conn_id) {
209 + return;
210 + }
211 + self.do_switch_client(Some(&cur_conn))
212 + }
|
Check warning on line 191 in src/plugins/connector/grpc/manager.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/plugins/connector/grpc/manager.rs:191:9
|
191 | return Ok(self.active_conn.clone());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
191 - return Ok(self.active_conn.clone());
191 + Ok(self.active_conn.clone())
|
Check warning on line 799 in src/plugins/connector/grpc/connector.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/plugins/connector/grpc/connector.rs:799:9
|
799 | return Ok(());
| ^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
799 - return Ok(());
799 + Ok(())
|
Check warning on line 741 in src/plugins/connector/grpc/connector.rs
github-actions / clippy
unneeded `return` statement
warning: unneeded `return` statement
--> src/plugins/connector/grpc/connector.rs:741:9
|
741 | return Ok(());
| ^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
741 - return Ok(());
741 + Ok(())
|
Check warning on line 360 in src/plugins/connector/grpc/connector.rs
github-actions / clippy
you seem to use `.enumerate()` and immediately discard the index
warning: you seem to use `.enumerate()` and immediately discard the index
--> src/plugins/connector/grpc/connector.rs:360:29
|
360 | for (_i, filter) in filters.iter().enumerate() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
|
360 | for filter in filters.iter() {
| ~~~~~~ ~~~~~~~~~~~~~~