ufetch icon indicating copy to clipboard operation
ufetch copied to clipboard

fix : cargo clippy warning and error

Open rtczza opened this issue 9 months ago • 0 comments

clippy tips:

warning: unneeded `return` statement
  --> src/modules/kernel.rs:14:17
   |
14 |                 return Ok(kernel_version);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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`
   |
14 -                 return Ok(kernel_version);
14 +                 Ok(kernel_version)
   |

and:

warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used
  --> src/modules/cpu.rs:9:5
   |
9  |       for line in io::BufReader::new(file).lines() {
   |       ^           -------------------------------- help: try: `io::BufReader::new(file).lines().flatten()`
   |  _____|
   | |
10 | |         if let Ok(line) = line {
11 | |             // Check for the "model name" line
12 | |             if line.starts_with("model name") {
...  |
17 | |         }
18 | |     }
   | |_____^
   |
help: ...and remove the `if let` statement in the for loop
  --> src/modules/cpu.rs:10:9
   |
10 | /         if let Ok(line) = line {
11 | |             // Check for the "model name" line
12 | |             if line.starts_with("model name") {
13 | |                 // Extract the model name
...  |
16 | |             }
17 | |         }
   | |_________^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
   = note: `#[warn(clippy::manual_flatten)]` on by default

rtczza avatar May 14 '24 02:05 rtczza