Skip to content

Audit error types#132

Merged
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:10-04-audit-errors
Oct 4, 2023
Merged

Audit error types#132
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:10-04-audit-errors

Conversation

@tcharding
Copy link
Copy Markdown
Member

Audit all error types and ensure the following holds:

  • All use non_exhaustive
  • All derive Debug, Clone, PartialEq, Eq (unless io::Error is present, in which case only Debug)
  • All error From impls use inline

This is similar to rust-bitcoin/rust-bitcoin#2101, probably should have done this one first.

Audit all error types and ensure the following holds:

- All use `non_exhaustive`
- All derive `Debug, Clone, PartialEq, Eq` (unless `io::Error` is
  present, in which case only `Debug`)
- All error `From` impls use `inline`
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 9b23c9c

@apoelstra apoelstra merged commit ab96bb9 into rust-bitcoin:master Oct 4, 2023
@dpc
Copy link
Copy Markdown

dpc commented Oct 4, 2023

BTW. You could use semgrep to enforce it. Example from Fedimint. We've found it quite useful and capable tool.

@tcharding
Copy link
Copy Markdown
Member Author

Thanks for the link, can semgrep enforce things not being in the code? Looks like it just flags things that exist in the code. Most of the error stuff here is things that we want to enforce existing instead of things to avoid.

@dpc
Copy link
Copy Markdown

dpc commented Oct 4, 2023

Thanks for the link, can semgrep enforce things not being in the code?

As long as you match around something that should always be there, then you can make an exception for the more specific thing that is correct.

Here we match all logs statements, but then let them pass if they have the target: xyz that we require, effectively enforcing that target: xyz is always there.

@tcharding

@tcharding
Copy link
Copy Markdown
Member Author

Thanks for clarifying, we could definitely use this.

@apoelstra apoelstra deleted the 10-04-audit-errors branch October 5, 2023 12:13
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