Skip to content
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

Clippy suggestions #5895

Merged
merged 5 commits into from
Jan 28, 2024
Merged

Clippy suggestions #5895

merged 5 commits into from
Jan 28, 2024

Conversation

kralo
Copy link
Sponsor Contributor

@kralo kralo commented Jan 27, 2024

ran clippy with clippy::range-plus-one, clippy::redundant-closure-for-method-calls and fix those where I was confident this is

a) improvement to the reader
b) does not make lines longer, no additional imports

@sylvestre
Copy link
Sponsor Contributor

could you please update the CI to run these too ?
https://github.com/uutils/coreutils/blob/main/.github/workflows/code-quality.yml#L124

@kralo
Copy link
Sponsor Contributor Author

kralo commented Jan 28, 2024

I left open what should happen with extremely long redundant closures.

Cases like these,

warning: redundant closure
   --> src/uu/tail/src/args.rs:197:22
    |
197 |                 .map(|s| s.as_str()),
    |                      ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::String::as_str`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
    = note: requested on the command line with `-W clippy::redundant-closure-for-method-calls`

To my eyes, std::string::String::as_str is neither more readable, nor shorter.

@kralo
Copy link
Sponsor Contributor Author

kralo commented Jan 28, 2024

could you please update the CI to run these too ? https://github.com/uutils/coreutils/blob/main/.github/workflows/code-quality.yml#L124

done for the trivial ones currently passing

This adresses only those where the fix has less letters than the
original and is "trivial" (There are possibly a lot of std::string::ToString::to_string
and those may only be shortened with additional imports).

Found with clippy::redundant-closure-for-method-calls
as suggested by clippy::range-plus-one
as suggested by clippy::range-plus-one
@sylvestre sylvestre merged commit 3362d8a into uutils:main Jan 28, 2024
61 checks passed
@sylvestre
Copy link
Sponsor Contributor

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants