bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Have more code conventions and guidelines

Open ValuedMammal opened this issue 10 months ago • 4 comments

Using rustfmt means we always agree on code formatting. If rustfmt allows it, then matters of code style can be left to personal preference.

However we could benefit from defining more code conventions in CONTRIBUTING.md for the sake of consistency. Just some ideas:

  • Forbid unsafe (or handle case by case)
  • Use StdExternalCrate style for grouping imports
  • Return as much context as possible with errors
  • Refer liberally to bitcoin BIPs and relevant historical context for a piece of code
  • Follow rust API guidelines for documentation and naming
  • Name tests after the functional unit they're testing
  • If using emoji, use them to their intended effect: code-review-emoji-guide

Approving changes:

  • All comments resolved
  • 2-ACK rule to merge

Use case
Facilitates code review and improves readability of the codebase

Additional context #1221 https://github.com/bitcoindevkit/bdk/pull/1203#discussion_r1510453405

ValuedMammal avatar Mar 30 '24 15:03 ValuedMammal

Great suggestions!

notmandatory avatar Mar 31 '24 19:03 notmandatory

Provide a reason for ignoring tests. See #1460

ValuedMammal avatar Jun 08 '24 16:06 ValuedMammal

Concept ACK, thanks for the suggestions!

oleonardolima avatar Jun 10 '24 13:06 oleonardolima

I really like this, I am totally on-board. Can we discuss this in the next dev meeting? (PS: @ValuedMammal should go first since we almost never go alphabetical descending order) Cc @nondiremanuel

storopoli avatar Jun 10 '24 15:06 storopoli

Adding another comment, I think we should try to enforce such conventions as much as possible on CI + GitHub features so we can set and forget, as by experience on fedimint if it's not enforced by CI it gets hard to maintain such conventions/rules, and on CI I mean even as a simple semgrep if it does the job.

oleonardolima avatar Aug 09 '24 14:08 oleonardolima