nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

Fix clippy warnings #42

Closed mati865 closed 7 years ago

mati865 commented 7 years ago

Fixed:

warning: this argument is passed by value, but not consumed in the function body
   --> src/ops/mod.rs:280:38
    |
280 | pub fn intersect_packages(installed: Vec<MainRepoPackage>, to_update: &[(String, Option<Semver>)], allow_installs: bool) -> Vec<MainRepoPackage> {
    |                                      ^^^^^^^^^^^^^^^^^^^^ help: consider changing the type to `&[MainRepoPackage]`
    |
    = note: #[warn(needless_pass_by_value)] on by default
    = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_pass_by_value

warning: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
   --> src/ops/mod.rs:282:21
    |
282 |         .filter(|p| to_update.iter().find(|u| p.name == u.0).is_some())
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(search_is_some)] on by default
    = note: replace `find(|u| p.name == u.0).is_some()` with `any(|u| p.name == u.0)`
    = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#search_is_some

warning: use of `or` followed by a function call
   --> src/main.rs:138:32
    |
138 |                         (s, e, r.or(Some(pr)))
    |                                ^^^^^^^^^^^^^^ help: try this `r.or_else(|| Some(pr))`
    |
    = note: #[warn(or_fun_call)] on by default
    = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call

Not fixed, I'm not sure about it ("trait std::ops::Fn<(std::string::String,)> is required"):

warning: this argument is passed by value, but not consumed in the function body
   --> src/options.rs:179:27
    |
179 | fn cargo_dir_validator(s: String) -> Result<(), String> {
    |                           ^^^^^^ help: consider changing the type to `&str`
    |
    = note: #[warn(needless_pass_by_value)] on by default
    = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_pass_by_value

Tests are passed:

   Running target/debug/deps/lib-7f01fd7d82c1259e
...
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests cargo-update
...
test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
nabijaczleweli commented 7 years ago

cargo_dir_validator() needs to take the String by value for clap's API so v0v The rest's good, cheers.

mati865 commented 7 years ago

Thanks.