Skip to content

Clippy warnings #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Clippy warnings #19

merged 2 commits into from
Feb 29, 2024

Conversation

pmcgleenon
Copy link
Contributor

This change addresses some clippy warnings and adds clippy to the CI

warning: manual implementation of `Option::map`
   --> src/app.rs:154:9
    |
154 | /         match state.selected() {
155 | |             Some(i) => Some(items[i].clone()),
156 | |             None => None,
157 | |         }
    | |_________^ help: try: `state.selected().map(|i| items[i].clone())`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
    = note: `#[warn(clippy::manual_map)]` on by default

warning: this block may be rewritten with the `?` operator
   --> src/main.rs:106:5
    |
106 | /     if res.is_err() {
107 | |         return res;
108 | |     }
    | |_____^ help: replace it with: `res.as_ref()?;`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
    = note: `#[warn(clippy::question_mark)]` on by default

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/main.rs:142:17
    |
142 | /                 match (key.modifiers, key.code) {
143 | |                     (KeyModifiers::CONTROL, KeyCode::Char('c')) => return Ok(()),
144 | |                     _ => {}
145 | |                 }
    | |_________________^ help: try: `if let (KeyModifiers::CONTROL, KeyCode::Char('c')) = (key.modifiers, key.code) { return Ok(()) }`
    |
    = 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

warning: casting to the same type is unnecessary (`f64` -> `f64`)
   --> src/main.rs:213:19
    |
213 |     let max_cpu = moving_max_cpu as f64;
    |                   ^^^^^^^^^^^^^^^^^^^^^ help: try: `moving_max_cpu`
    |
    = 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

warning: match expression looks like `matches!` macro
   --> src/main.rs:420:5
    |
420 | /     match nix::unistd::getuid().as_raw() {
421 | |         0 => true,
422 | |         _ => false,
423 | |     }
    | |_____^ help: try: `matches!(nix::unistd::getuid().as_raw(), 0)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default

warning: `bpftop` (bin "bpftop") generated 5 warnings (run `cargo clippy --fix --bin "bpftop"` to apply 3 suggestions)

@jfernandez jfernandez added the enhancement New feature or request label Feb 28, 2024
@jfernandez jfernandez self-requested a review February 28, 2024 21:11
Copy link
Collaborator

@jfernandez jfernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT. Thank you for setting this up.

@jfernandez jfernandez merged commit ec29ec8 into Netflix:main Feb 29, 2024
@pmcgleenon pmcgleenon deleted the clippy-ci branch February 29, 2024 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants