Skip to content

Fixed a bunch of clippy lints, added clippy.toml#686

Merged
RCasatta merged 1 commit intorust-bitcoin:masterfrom
Kixunil:clippy
Dec 24, 2021
Merged

Fixed a bunch of clippy lints, added clippy.toml#686
RCasatta merged 1 commit intorust-bitcoin:masterfrom
Kixunil:clippy

Conversation

@Kixunil
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

@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
Copy Markdown
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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ibid

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

@Kixunil needs rebase :(

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Nov 23, 2021

Rebased

dr-orlovsky
dr-orlovsky previously approved these changes Nov 23, 2021
Copy link
Copy Markdown
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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

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

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Nov 23, 2021

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

@tcharding
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Kixunil commented Nov 24, 2021

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

@tcharding
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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