-
Notifications
You must be signed in to change notification settings - Fork 173
bitcoind_test: Fix clippy #686
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
Conversation
Remove build error: error: casting integer literal to `u8` is unnecessary
|
|
||
| for i in 0..n { | ||
| let keypair = bitcoin::secp256k1::Keypair::from_secret_key(&secp_sign, &sks[i]); | ||
| for sk in sks.iter().take(n) { |
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.
In b328736:
iter and take continue to be unnecessary
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.
Its like I didn't even read your review the first time :(
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.
Will fix, and lol "continue to be unnecessary" - love it.
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 don't know what was the original intention of the code but as it reads the take(n) is required because n is a function parameter so we can't just iterate over all of sk.
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.
In the iteration above we construct sk by looping n times and pushing stuff onto sk.
We could add a debug_assert that sk.len() equals n if it makes you nervous.
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.
My bad, I did not read the code properly. Used for sk in sks { as suggested.
|
Should we squash all these commits down? |
|
@storopoli I see no particular reason to. They are all independent and compile and pass all tests (I assume -- I have not tested them because the second one needs to be changed). |
|
I go to painful lengths to put all these changes separately so that its quick and easy for reviewers to review them [0]. Also its easy to drop any particular patch if a reviewer doesn't like it. Even the commit messages should be so uniform that they are easy to read quickly (and mechanical for me to write). [0] Definitely pull me up if there are changes in the wrong place. |
Clear clippy warning: the loop variable `i` is only used to index `sks`
Clippy emits: warning: redundant field names in struct initialization As suggested, remove redundant field names.
Clippy emits: warning: single-character string constant used as pattern As suggested, use single quotes.
Clippy emits: warning: manual implementation of an assign operation As suggested, use += operator.
Clippy emits: warning: unneeded `return` statement As suggested, remove unneeded return statement.
Clippy emits: warning: field assignment outside of initializer for an instance created with Default::default() As suggested use `..Default::default()` instead of mutating.
Clippy emits: warning: this expression creates a reference which is immediately dereferenced by the compiler As suggested, remove explicit reference.
Clippy emits: warning: useless conversion to the same type: `setup::miniscript::bitcoin::absolute::LockTime` As suggested, remove useless conversion.
Found with clippy, just use `Copy`.
Clippy emits: warning: use of `expect` followed by a function call As suggested, use `unwrap_or_else` with `panic!`.
Clippy emits: warning: redundant pattern matching, consider using `is_err()` As suggested, use `is_err()`.
|
Neat, TIL:
|
apoelstra
left a comment
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.
utACK b9a207b
|
Oops, that utACk should have been a full ACK. I did test every commit, it just took some manual prodding to avoid opening too many files at once. |
|
Is there anything we can do about bot accounts triggering notifications like this @ErnestoLara idiot above? (Mentioning him incase he is a real person :) |
b9a207bfd58b8f961c44976e6ff72b8940bf9f21 Use is_err instead of redundant pattern matching (Tobin C. Harding)
ef868cc7b5f9a652494fc808ea90ac29a91b7f0f Use unwrap_or_else instead of expect (Tobin C. Harding)
a1a5467175dade2243c248c6e54d8522d1273f9c Remove clone call from Copy type (Tobin C. Harding)
f939367b244f5603835590b9829f55f698c35ebb Remove useless conversion (Tobin C. Harding)
c20be39458273e9410bbe64c892c014423c4460d Remove explicit reference (Tobin C. Harding)
7ed6680fb84ff1056a3dcbc06b9e9f8e2e29da07 Do not mutate local variable (Tobin C. Harding)
e361cfc396585c8260bf61806343a9cdb6cdb88d Remove unneeded return statement (Tobin C. Harding)
f9907b038c1b874fb4da608c9ebcbfe2f5512a49 Use += operator (Tobin C. Harding)
5e0df214089a74182d714f79201f2ecca551202c Use single quotes (Tobin C. Harding)
7218e5eba8c60378f713f94b9ff5242af944efd1 Remove redundant field names (Tobin C. Harding)
6a2577f0eef445b5d9f4f4ca1fb150d43d48b4d1 Remove useless let binding (Tobin C. Harding)
ccc808ae6a0c9f7d3d7ae0b38c78decd8d7d1b66 Use iterator instead of array access (Tobin C. Harding)
badeb44c8386ff9c37516700082ce98c34a22a54 Remove unnecessary cast (Tobin C. Harding)
Pull request description:
All the clippy patches rom #682, only touches `bitcoind_test`.
ACKs for top commit:
apoelstra:
utACK b9a207bfd58b8f961c44976e6ff72b8940bf9f21
Tree-SHA512: ae9451601bc5232f0ce194be1b7c6c1c31c8118ea87951f3eac9c6c4349c7ff963516c8cc34c2a63c9f1b99f03c781e687c74b46dc24624bbfa81a0decb513ef
All the clippy patches rom #682, only touches
bitcoind_test.