Skip to content

Conversation

@tcharding
Copy link
Contributor

@tcharding tcharding commented May 6, 2021

Description

Checking bdk with the nightly toolchain throws a bunch of warnings, all are trivial to fix. Turns out one of them is not, the final patch of this PR may or may not be deemed an improvement, please review and I can drop if required.

Fix warnings emitted by Clippy when using nightly toolchain.

Notes to the reviewers

While bdk does not appear to explicitly rely on nightly features I like to use nightly so I can pass -Zunstable-options to clippy. I do this so that Clippy doesn't hide warnings after the first time showing them, instead throwing warnings every check.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@tcharding tcharding marked this pull request as draft May 6, 2021 04:50
@tcharding tcharding marked this pull request as ready for review May 6, 2021 23:09
src/psbt/mod.rs Outdated
Some(in_tx.output[tx.input[input_index].previous_output.vout as usize].clone())
} else {
None
match self.inputs.get(input_index) {
Copy link
Member

Choose a reason for hiding this comment

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

I do agree this code looks less readable than before, if the specific lint is not usable maybe #[allow(clippy::all)] with a comment for this block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, nice idea, I did not think of that. Will update PR as suggested. Thanks.

tcharding added 6 commits May 11, 2021 10:51
It is redundant to pass true/false to `assert_eq!` since `assert!`
already asserts true/false.

This may, however, be controversial if someone thinks that

```
    assert_eq!(foo, false);
```

is more clear than

```
    assert!(!foo);
```

Use `assert!` directly instead of `assert_eq!` with true/false argument.
Clippy emits:

  warning: using `clone` on type `descriptor::policy::Condition` which
  implements the `Copy` trait

Remove the clone and rely on `Copy`.
Clippy emits:

  warning: called `is_none()` after searching an `Iterator` with `find`

As suggested, use the construct: `!foo.iter().any(...)`
Clippy emits:

  warning: struct constructor field order is inconsistent with struct
  definition field order

As suggested, re-order the fields to be consistent with the struct
definition.
The lint `manual_map` is new so we cannot explicitly allow it and
maintain backwards comparability. Instead, allow all lints for
`get_utxo_for` with a comment explaining why.
Clippy emits:

  warning: unneeded unit expression

As suggested, remove the unneeded unit expression.
@tcharding
Copy link
Contributor Author

Please note, this PR now has an additional commit on the end of it (a new nightly Clippy warning snuck in during rebase on master).

@tcharding tcharding requested a review from RCasatta May 11, 2021 00:53
Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

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

Look like good cleanups and as usual good commit docs. ACK e1066e9

@tcharding
Copy link
Contributor Author

Look like good cleanups and as usual good commit docs. ACK e1066e9

Thanks, appreciate the complement. My commit log habits were formed in the fires of the linux-staging mailing list :)

@notmandatory notmandatory merged commit 9f04a9d into bitcoindevkit:master May 18, 2021
@tcharding tcharding deleted the clippy branch August 17, 2021 06:08
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.

3 participants