8000 Fixed a bunch of clippy lints, added clippy.toml by Kixunil · Pull Request #686 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed a bunch of clippy lints, added clippy.toml #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

Merged
merged 1 commit into from
Dec 24, 2021

Conversation

Kixunil
Copy link
Collaborator
@Kixunil Kixunil commented Nov 3, 2021

This is the initial step towards using and maybe enforcing clippy.
It does not fix all lints as some are not applicable. They may be
explicitly ignored later.

Some discussion about clippy was in #685

sanket1729
sanket1729 previously approved these changes Nov 3, 2021
Copy link
Member
@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK fea88aea33a9ac2d03a77cf08eade0ebdad2da01

Copy link
Member
@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

Nice one, thanks.

@tcharding
Copy link
Member

This is the initial step towards using and maybe enforcing clippy.

Of possible relevance to this work is: #688 (further configures clippy).

DON-MAC-256
DON-MAC-256 previously approved these changes Nov 8, 2021
Copy link
@DON-MAC-256 DON-MAC-256 left a comment

Choose a reason for hiding this comment

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

Nice changes, including some that should help prevent the introduction of bugs later on.

ACK

dr-orlovsky
dr-orlovsky previously approved these changes Nov 11, 2021
Copy link
Collaborator
@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

LGTM mod two nits

/// Error returned when parsing `SigHashType` fails.
///
/// This is currently returned for unrecognized sighash strings.
#[derive(Debug, Clone)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

#[derive(ParialEq, Eq, PartialOrd, Ord)], according to our new contributing guidelines :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBH, I'm not really convinced errors should commit to Ord/PartialOrd. Maybe Eq is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about Hash?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If there's Eq there should be Hash, I believe.

In this specific case I'm not even sure about Eq. Are two errors carrying information saying "can't recognize sighash string" (by their existence) that were caused by different input (which they write for ease of debugging) equal or not?

/// Error returned when a command string is invalid.
///
/// This is currently returned for command strings longer than 12.
#[derive(Clone, Debug)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ibid

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here I still think #[derive(PartialEq, Eq)] will be nice to have

@dr-orlovsky
Copy link
Collaborator

@Kixunil needs rebase :(

@Kixunil
Copy link
Collaborator Author
Kixunil commented Nov 23, 2021

Rebased

dr-orlovsky
dr-orlovsky previously approved these changes Nov 23, 2021
Copy link
Collaborator
@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

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

ACK 693f6666da64bf3140d50ca9983f3968c4c69802 with one small nit

/// Error returned when a command string is invalid.
///
/// This is currently returned for command strings longer than 12.
#[derive(Clone, Debug)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here I still think #[derive(PartialEq, Eq)] will be nice to have

@Kixunil
Copy link
Collaborator Author
Kixunil commented Nov 23, 2021

Will wait a bit if others have an opinion on this. Basically the question is "Do we want to commit to always carry error information that can be meaningfully compared?"

@Kixunil Kixunil added code quality Makes code easier to understand and less likely to lead to problems help wanted labels Nov 23, 2021
@RCasatta
Copy link
Collaborator

If I remember correctly @apoelstra doesn't like struct initialization shorthand

@Kixunil
Copy link
Collaborator Author
Kixunil commented Nov 23, 2021

Shame, I do like it but willing to allow it instead.

@tcharding
Copy link
Member
tcharding commented Nov 24, 2021

Adding allows everywhere will be messy as hell, structs get initialized all over the place. Probably best to let @apoelstra comment before starting a fight in his name though :)

@Kixunil
Copy link
Collaborator Author
Kixunil commented Nov 24, 2021

@tcharding I think they could be allowed globally in clippy.toml

@tcharding
Copy link
Member

yeah, I realised this last night when I was going to sleep :)

@Kixunil Kixunil added the one ack PRs that have one ACK, so one more can progress them label Dec 2, 2021
@apoelstra
Copy link
Member

Sorry for being absent.

I don't like the compact struct initialization format but I won't hold things up about it. I'm used to it by now :).

Regarding errors satisfying PartialEq, Eq etc ... I tend to agree that they shouldn't be comparable. If you need to nest them in structs then you can wrap them or something.

Needs rebase.

This is the initial step towards using and maybe enforcing clippy.
It does not fix all lints as some are not applicable. They may be
explicitly ignored later.
@Kixunil
Copy link
Collaborator Author
Kixunil commented Dec 21, 2021

Rebased

@Kixunil Kixunil removed the one ack PRs that have one ACK, so one more can progress them label Dec 21, 2021
Copy link
Member
@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 779d411

The only thing that raised my eyebrows was the initialization thing, but I'll choose some other hill to die on.

@Kixunil Kixunil added the one ack PRs that have one ACK, so one more can progress them label Dec 23, 2021
Copy link
Collaborator
@RCasatta RCasatta left a comment

Choose a reason for hiding this comment

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

ACK 779d411

@RCasatta RCasatta merged commit f9b3fc9 into rust-bitcoin:master Dec 24, 2021
@Kixunil Kixunil deleted the clippy branch December 24, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Makes code easier to understand and less likely to lead to problems help wanted one ack PRs that have one ACK, so one more can progress them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0