Contributing: improving language and style

This commit is contained in:
Dr Maxim Orlovsky 2022-01-10 12:25:08 +01:00
parent 45dbaa7e26
commit e1c8e13cb8
1 changed files with 26 additions and 30 deletions

View File

@ -77,20 +77,18 @@ To contribute a patch, the workflow is a as follows:
2. Create topic branch 2. Create topic branch
3. Commit patches 3. Commit patches
In general commits should be atomic and diffs should be easy to read. For this Please keep commits should atomic and diffs easy to read. For this reason
reason do not mix any formatting fixes or code moves with actual code changes. do not mix any formatting fixes or code moves with actual code changes.
Further, each commit, individually, should compile and pass tests, in order to Further, each commit, individually, should compile and pass tests, in order to
ensure git bisect and other automated tools function properly. ensure git bisect and other automated tools function properly.
When adding a new feature thought must be given to the long term technical debt. Please cover every new feature with unit tests.
Every new features should be covered by unit tests.
When refactoring, structure your PR to make it easy to review and don't hesitate When refactoring, structure your PR to make it easy to review and don't hesitate
to split it into multiple small, focused PRs. to split it into multiple small, focused PRs.
Commits should cover both the issue fixed and the solution's rationale. Commits should cover both the issue fixed and the solution's rationale.
These [guidelines](https://chris.beams.io/posts/git-commit/) should be kept in Please keep these [guidelines](https://chris.beams.io/posts/git-commit/) in mind.
mind.
To facilitate communication with other contributors, the project is making use To facilitate communication with other contributors, the project is making use
of GitHub's "assignee" field. First check that no one is assigned and then of GitHub's "assignee" field. First check that no one is assigned and then
@ -104,12 +102,11 @@ The main library development happens in the `master` branch. This branch must
always compile without errors (using GitHub CI). All external contributions are always compile without errors (using GitHub CI). All external contributions are
made within PRs into this branch. made within PRs into this branch.
Prerequisites that a PR must satisfy in order to be considered for merging into Prerequisites that a PR must satisfy for merging into the `master` branch:
the `master` branch:
* each commit within a PR must compile and pass unit tests with no errors, with * each commit within a PR must compile and pass unit tests with no errors, with
every feature combination (including compiling the fuzztests) on some every feature combination (including compiling the fuzztests) on some
reasonably recent compiler (this is partially automated with CI, so the rule reasonably recent compiler (this is partially automated with CI, so the rule
is that if GitHub CI is not passing, the commit can't be accepted); is that we will not accept commits which do not pass GitHub CI);
* the tip of any PR branch must also compile and pass tests with no errors on * the tip of any PR branch must also compile and pass tests with no errors on
MSRV (check [README.md] on current MSRV requirements) and pass fuzz tests on MSRV (check [README.md] on current MSRV requirements) and pass fuzz tests on
nightly rust; nightly rust;
@ -131,8 +128,8 @@ above, before submitting the PR to review:
```shell script ```shell script
BITCOIN_MSRV=1.29.0 ./contrib/ci.sh BITCOIN_MSRV=1.29.0 ./contrib/ci.sh
``` ```
Where value in `BITCOIN_MSRV=1.29.0` should be replaced with the current MSRV Please replace the value in `BITCOIN_MSRV=1.29.0` with the current MSRV from
from [README.md]. [README.md].
NB: Please keep in mind that the script above replaces `Cargo.lock` file, which NB: Please keep in mind that the script above replaces `Cargo.lock` file, which
is necessary to support current MSRV, incompatible with `stable` and newer cargo is necessary to support current MSRV, incompatible with `stable` and newer cargo
@ -142,15 +139,16 @@ versions.
Anyone may participate in peer review which is expressed by comments in the pull Anyone may participate in peer review which is expressed by comments in the pull
request. Typically, reviewers will review the code for obvious errors, as well as request. Typically, reviewers will review the code for obvious errors, as well as
test out the patch set and opine on the technical merits of the patch. PR should test out the patch set and opine on the technical merits of the patch. Please,
be reviewed first on the conceptual level before focusing on code style or first review PR on the conceptual level before focusing on code style or
grammar fixes. grammar fixes.
### Repository maintainers ### Repository maintainers
For the pull request to be merged we require (a) that all CI test should pass Pull request merge requirements:
and (2) at least two "accepts"/ACKs from the repository maintainers and no - all CI test should pass,
main reasonable "rejects"/NACKs from anybody who reviewed the code. - at least two "accepts"/ACKs from the repository maintainers
- no reasonable "rejects"/NACKs from anybody who reviewed the code.
Current list of the project maintainers: Current list of the project maintainers:
@ -165,10 +163,7 @@ Current list of the project maintainers:
## Coding conventions ## Coding conventions
Overall, this library must reflect Bitcoin Core approach whenever possible. Library reflects Bitcoin Core approach whenever possible.
However, since many of the things in Bitcoin Core are maintained due to
historical reasons and may represent poor design, Rust-idiomatic style is
preferred to "how it looks in Core" if everyone agrees.
### Formatting ### Formatting
@ -176,8 +171,8 @@ The repository currently does not use `rustfmt`.
New changes may format the code with `rustfmt`, but they should not re-format New changes may format the code with `rustfmt`, but they should not re-format
any existing code for maintaining diff size small, keeping `git blame` intact and any existing code for maintaining diff size small, keeping `git blame` intact and
reduce review time. All PRs introducing large blocks of re-formatted code will reduce review time. Repository maintainers may not review PRs introducing large
not be reviewed. blocks of re-formatted code.
You may check the [discussion on the formatting](https://github.com/rust-bitcoin/rust-bitcoin/issues/172) You may check the [discussion on the formatting](https://github.com/rust-bitcoin/rust-bitcoin/issues/172)
and [how it is planned to coordinate it with crate refactoring](https://github.com/rust-bitcoin/rust-bitcoin/pull/525) and [how it is planned to coordinate it with crate refactoring](https://github.com/rust-bitcoin/rust-bitcoin/pull/525)
@ -194,14 +189,14 @@ the [tracking issue](https://github.com/rust-bitcoin/rust-bitcoin/issues/510).
### Naming conventions ### Naming conventions
Naming of data structures/enums and their fields/variants must follow names used Naming of data structures/enums and their fields/variants must follow names used
in Bitcoin Core, with except to: in Bitcoin Core, with the following exceptions:
- case, which should follow Rust standards (i.e. PascalCase for types and - the case should follow Rust standards (i.e. PascalCase for types and
snake_case for fields and variants) snake_case for fields and variants);
- `C`-prefix, which should be omitted - omit `C`-prefixes.
### Unsafe code ### Unsafe code
Use of `unsafe` code is prohibited unless there is a unanonymous decision among Use of `unsafe` code is prohibited unless there is a unanimous decision among
library maintainers on the exclusion from this rule. In such cases there is a library maintainers on the exclusion from this rule. In such cases there is a
requirement to test unsafe code with sanitizers including Miri. requirement to test unsafe code with sanitizers including Miri.
@ -213,8 +208,8 @@ vulnerabilities helps prevent user loss of funds. If you believe a vulnerability
may affect other implementations, please disclose this information according to may affect other implementations, please disclose this information according to
the [security guidelines](./SECURITY.md), work on which is currently in progress. the [security guidelines](./SECURITY.md), work on which is currently in progress.
Before it is completed, feel free to send disclosure to Andrew Poelstra, Before it is completed, feel free to send disclosure to Andrew Poelstra,
apoelstra@wpsoftware.net, encrypted with his public key, which may be found apoelstra@wpsoftware.net, encrypted with his public key from
at <https://www.wpsoftware.net/andrew/andrew.gpg>. <https://www.wpsoftware.net/andrew/andrew.gpg>.
## Testing ## Testing
@ -226,7 +221,8 @@ the project to enable fine-grained unit testing is also an ongoing effort.
Fuzzing is heavily encouraged: feel free to add related material under `fuzz/` Fuzzing is heavily encouraged: feel free to add related material under `fuzz/`
Mutation testing is planned; any contribution there would be warmly welcomed. Mutation testing is planned; any contributions helping with that are highly
welcome!
## Going further ## Going further