-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Apply some clippy lints #11154
Apply some clippy lints #11154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not yet review all changes.
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
# Conflicts: # client/service/src/client/wasm_override.rs # primitives/state-machine/src/trie_backend_essence.rs # utils/fork-tree/src/lib.rs # utils/frame/benchmarking-cli/src/pallet/command.rs # utils/frame/remote-externalities/src/lib.rs
I'll try to keep this PR in sync with master, but I suspect it to conflict frequently due to it's sheer size. |
@bkchr any concerns or is all good? |
I hope to finish the review tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay @hirschenberger
Looks good and ty for your work :)
/tip small |
1 similar comment
/tip small |
Please fix the following problems before calling the tip bot again:
Make sure the pull request description has: "{network} address: {address}". |
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
# Conflicts: # client/network/src/protocol/notifications/behaviour.rs # client/network/src/service.rs
@hirschenberger if you would like a treasury tip, please include your address information above |
Ok, thanks |
/tip small |
bot merge |
@bkchr The tip-bot seems to be sleeping... |
/tip small |
A small tip was successfully submitted for hirschenberger (1ZApdbwrNnT1Hey4xeTAH6SZPDgbA9ZVftNuu9jTRbkc2Bg on polkadot). https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips |
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <[email protected]> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Giles Cope <[email protected]>
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <[email protected]> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Giles Cope <[email protected]>
This PR changed See: #6754 This is how we had a consensus problem on Kusama. cc @gilescope can you make sure that such linting in the future does not do this? |
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <[email protected]> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Giles Cope <[email protected]>
fixes #11054
Summary
The intention of this PR is not to enable/enforce a set of clippy rules to CI. It is making it easier to do so by fixing a lot of clippy remarks so that maybe @gilescope can integrate more clippy lints step by step without giant changesets.
This PR involved a huge amount of yak-shaving activity (TBH. I underestimated the amount and I would not do it again). I tried to evaluate each change (or kind of change) and hope I found a good compromise. I know that others would have drawn the line somewhere else.
Unfortunately it was not feasable to create an extra commit for all different lints, as it would have increased the amount of work drastically. So I hope you can live with it and review the PR as a whole. Sorry for the reviewers. I'll sure change your suggestions and remarks.
I tried to keep an eye on API-compatibility. The only thing I changed on function signatures is removing lifetime-annotations that can be elided.
I created a list of lints that fall into three categories:
You can lookup these lints and what they do here: Clippy Lints
Nearly always applied
Applied sometimes depending on the code-context
if map.is_empty() {
not in the not empty case:if !map.is_empty() {
for readability. In my opinionif map.len() > 0 {
is easier to grasp.return
makes the code more clearZero::zero()
and should be inlined neverthelessNever applied
polkadot address: 1ZApdbwrNnT1Hey4xeTAH6SZPDgbA9ZVftNuu9jTRbkc2Bg