fix: code #193
clippy
1 error, 44 warnings
Details
Results
Message level | Amount |
---|---|
Internal compiler error | 0 |
Error | 1 |
Warning | 44 |
Note | 0 |
Help | 0 |
Versions
- rustc 1.83.0 (90b35a623 2024-11-26)
- cargo 1.83.0 (5ffbef321 2024-10-29)
- clippy 0.1.83 (90b35a6 2024-11-26)
Annotations
Check warning on line 13 in src/service/tools.rs
github-actions / clippy
binary comparison to literal `Option::None`
warning: binary comparison to literal `Option::None`
--> src/service/tools.rs:13:9
|
13 | self.file_name != None
| ^^^^^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `self.file_name.is_some()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_to_none
= note: `#[warn(clippy::partialeq_to_none)]` on by default
Check warning on line 608 in src/service/routes.rs
github-actions / clippy
accessing first element with `usable_db .clone() .unwrap().get(0)`
warning: accessing first element with `usable_db
.clone()
.unwrap().get(0)`
--> src/service/routes.rs:605:58
|
605 | ... let nc = usable_db
| ________________________________^
606 | | ... .clone()
607 | | ... .unwrap()
608 | | ... .get(0)
| |_________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
help: try
|
605 ~ let nc = usable_db
606 + .clone()
607 + .unwrap().first()
|
Check warning on line 494 in src/service/routes.rs
github-actions / clippy
accessing first element with `commands.get(0)`
warning: accessing first element with `commands.get(0)`
--> src/service/routes.rs:494:50
|
494 | let command_name: &str = commands.get(0).unwrap();
| ^^^^^^^^^^^^^^^ help: try: `commands.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 409 in src/service/routes.rs
github-actions / clippy
unnecessary use of `to_string`
warning: unnecessary use of `to_string`
--> src/service/routes.rs:409:17
|
409 | &String::from_utf8_lossy(&v.1[..]).to_string(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `String::from_utf8_lossy(&v.1[..]).as_ref()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
= note: `#[warn(clippy::unnecessary_to_owned)]` on by default
Check warning on line 220 in src/service/routes.rs
github-actions / clippy
this let-binding has unit value
warning: this let-binding has unit value
--> src/service/routes.rs:215:5
|
215 | / let _ = match client.select(&group).await {
216 | | Ok(_) => {}
217 | | Err(_) => {
218 | | return Api::error(StatusCode::INTERNAL_SERVER_ERROR, "Client execute failed.");
219 | | }
220 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
help: omit the `let` binding
|
215 ~ match client.select(&group).await {
216 + Ok(_) => {}
217 + Err(_) => {
218 + return Api::error(StatusCode::INTERNAL_SERVER_ERROR, "Client execute failed.");
219 + }
220 + };
|
Check warning on line 753 in src/database.rs
github-actions / clippy
unneeded late initialization
warning: unneeded late initialization
--> src/database.rs:753:9
|
753 | let data_file: PathBuf;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
help: move the declaration `data_file` here and remove the assignments from the branches
|
753 ~
754 ~ let data_file: PathBuf = if index_info.file_id == self.get_file_id() {
755 ~ self.root.join("active.db")
756 | } else {
757 ~ self.root.join(format!("archive-{}.db", index_info.file_id))
758 ~ };
|
Check warning on line 708 in src/database.rs
github-actions / clippy
this let-binding has unit value
warning: this let-binding has unit value
--> src/database.rs:708:9
|
708 | let _ = self.check_file().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `self.check_file().unwrap();`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `#[warn(clippy::let_unit_value)]` on by default
Check failure on line 541 in src/database.rs
github-actions / clippy
read amount is not handled
error: read amount is not handled
--> src/database.rs:541:43
|
541 | ... match file.read(&mut read_one) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use `Read::read_exact` instead, or handle partial reads
note: the result is consumed here, but the amount of I/O bytes remains unhandled
--> src/database.rs:542:41
|
542 | ... Ok(_) => {
| ^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
= note: `#[deny(clippy::unused_io_amount)]` on by default
Check warning on line 501 in src/database.rs
github-actions / clippy
unneeded late initialization
warning: unneeded late initialization
--> src/database.rs:501:21
|
501 | let file_id: u32;
| ^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
help: move the declaration `file_id` here and remove the assignments from the branches
|
501 ~
502 |
503 ~ let file_id: u32 = if file_name == "active.db" {
504 ~ self.get_file_id()
505 | } else {
506 ~ info.as_ref().unwrap().1.parse::<u32>().unwrap()
507 ~ };
|
Check warning on line 191 in src/database.rs
github-actions / clippy
casting to the same type is unnecessary (`isize` -> `isize`)
warning: casting to the same type is unnecessary (`isize` -> `isize`)
--> src/database.rs:191:57
|
191 | self.eli_queue.insert(db.to_string(), old + num as isize);
| ^^^^^^^^^^^^ help: try: `num`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
Check warning on line 84 in src/database.rs
github-actions / clippy
direct implementation of `ToString`
warning: direct implementation of `ToString`
--> src/database.rs:75:1
|
75 | / impl ToString for DataBaseState {
76 | | fn to_string(&self) -> String {
77 | | match &self {
78 | | DataBaseState::NORMAL => "Normal".to_string(),
... |
83 | | }
84 | | }
| |_^
|
= help: prefer implementing `Display` instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl
Check warning on line 117 in src/configure.rs
github-actions / clippy
the borrowed expression implements the required traits
warning: the borrowed expression implements the required traits
--> src/configure.rs:117:15
|
117 | fs::write(&service_path.join("service.toml"), rest)?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `service_path.join("service.toml")`
|
= 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 1304 in src/command.rs
github-actions / clippy
accessing first element with `slice.get(0)`
warning: accessing first element with `slice.get(0)`
--> src/command.rs:1304:36
|
1304 | let expression: &str = slice.get(0).unwrap();
| ^^^^^^^^^^^^ help: try: `slice.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 1081 in src/command.rs
github-actions / clippy
accessing first element with `slice.get(0)`
warning: accessing first element with `slice.get(0)`
--> src/command.rs:1081:35
|
1081 | let operation: &str = slice.get(0).unwrap();
| ^^^^^^^^^^^^ help: try: `slice.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 1031 in src/command.rs
github-actions / clippy
accessing first element with `slice.get(0)`
warning: accessing first element with `slice.get(0)`
--> src/command.rs:1031:32
|
1031 | let target: &str = slice.get(0).unwrap();
| ^^^^^^^^^^^^ help: try: `slice.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 827 in src/command.rs
github-actions / clippy
accessing first element with `slice.get(0)`
warning: accessing first element with `slice.get(0)`
--> src/command.rs:827:35
|
827 | let operation: &str = slice.get(0).unwrap();
| ^^^^^^^^^^^^ help: try: `slice.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 801 in src/command.rs
github-actions / clippy
accessing first element with `slice.get(0)`
warning: accessing first element with `slice.get(0)`
--> src/command.rs:801:35
|
801 | let operation: &str = slice.get(0).unwrap();
| ^^^^^^^^^^^^ help: try: `slice.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 750 in src/command.rs
github-actions / clippy
this if-then-else expression assigns a bool literal
warning: this if-then-else expression assigns a bool literal
--> src/command.rs:746:25
|
746 | / if temp.to_uppercase() == "DESC" {
747 | | asc = false;
748 | | } else {
749 | | asc = true;
750 | | }
| |_________________________^ help: you can reduce it to: `asc = temp.to_uppercase() != "DESC";`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool_assign
= note: `#[warn(clippy::needless_bool_assign)]` on by default
Check warning on line 745 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:745:42
|
745 | let temp: &str = sub_arg.get(0).unwrap_or(&"asc");
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 705 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:705:32
|
705 | let data = sub_arg.get(0).unwrap();
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 691 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:691:31
|
691 | let key = sub_arg.get(0).unwrap();
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 662 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:662:38
|
662 | let data: &str = sub_arg.get(0).unwrap();
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 616 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:616:38
|
616 | let data: &str = sub_arg.get(0).unwrap();
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 603 in src/command.rs
github-actions / clippy
accessing first element with `sub_arg.get(0)`
warning: accessing first element with `sub_arg.get(0)`
--> src/command.rs:603:44
|
603 | let number: &str = sub_arg.get(0).unwrap();
| ^^^^^^^^^^^^^^ help: try: `sub_arg.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
Check warning on line 552 in src/command.rs
github-actions / clippy
casting to the same type is unnecessary (`u64` -> `u64`)
warning: casting to the same type is unnecessary (`u64` -> `u64`)
--> src/command.rs:552:36
|
552 | if current_time >= (node_timestamp.0 as u64 + node_timestamp.1) as u64
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(node_timestamp.0 as u64 + node_timestamp.1)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast