docs: clean up code contribution guideline syntax

This commit is contained in:
Oliver Gugger 2021-01-17 14:59:40 +01:00
parent 02267565fe
commit 9642012643
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -1,29 +1,27 @@
### Table of Contents # Table of Contents
1. [Overview](#Overview)<br /> 1. [Overview](#overview)
2. [Minimum Recommended Skillset](#MinSkillset)<br /> 2. [Minimum Recommended Skillset](#minimum-recommended-skillset)
3. [Required Reading](#ReqReading)<br /> 3. [Required Reading](#required-reading)
4. [Development Practices](#DevelopmentPractices)<br /> 4. [Development Practices](#development-practices)
4.1. [Share Early, Share Often](#ShareEarly)<br /> 1. [Share Early, Share Often](#share-early-share-often)
4.2. [Testing](#Testing)<br /> 1. [Testing](#testing)
4.3. [Code Documentation and Commenting](#CodeDocumentation)<br /> 1. [Code Documentation and Commenting](#code-documentation-and-commenting)
4.4. [Model Git Commit Messages](#ModelGitCommitMessages)<br /> 1. [Model Git Commit Messages](#model-git-commit-messages)
4.5. [Ideal Git Commit Structure](#IdealGitCommitStructure)<br /> 1. [Ideal Git Commit Structure](#ideal-git-commit-structure)
4.6. [Code Spacing](#CodeSpacing)<br /> 1. [Code Spacing](#code-spacing)
4.7. [Protobuf Compilation](#Protobuf)<br /> 1. [Protobuf Compilation](#protobuf-compilation)
4.8. [Additional Style Constraints On Top of gofmt](ExtraGoFmtStyle)<br /> 1. [Additional Style Constraints On Top of gofmt](#additional-style-constraints-on-top-of-gofmt)
4.9. [Pointing to Remote Dependant Branches in Go Modules](ModulesReplace)<br /> 1. [Pointing to Remote Dependant Branches in Go Modules](#pointing-to-remote-dependant-branches-in-go-modules)
4.10. [Use of Log Levels](#LogLevels)<br /> 1. [Use of Log Levels](#use-of-log-levels)
5. [Code Approval Process](#CodeApproval)<br /> 5. [Code Approval Process](#code-approval-process)
5.1. [Code Review](#CodeReview)<br /> 1. [Code Review](#code-review)
5.2. [Rework Code (if needed)](#CodeRework)<br /> 1. [Rework Code (if needed)](#rework-code-if-needed)
5.3. [Acceptance](#CodeAcceptance)<br /> 1. [Acceptance](#acceptance)
6. [Contribution Standards](#Standards)<br /> 6. [Contribution Standards](#contribution-standards)
6.1. [Contribution Checklist](#Checklist)<br /> 1. [Contribution Checklist](#contribution-checklist)
6.2. [Licensing of Contributions](#Licensing)<br /> 1. [Licensing of Contributions](#licensing-of-contributions)
<a name="Overview" /> # Overview
### 1. Overview
Developing cryptocurrencies is an exciting endeavor that touches a wide variety Developing cryptocurrencies is an exciting endeavor that touches a wide variety
of areas such as wire protocols, peer-to-peer networking, databases, of areas such as wire protocols, peer-to-peer networking, databases,
@ -49,9 +47,7 @@ development process (heavily inspired by
We highly encourage code contributions, however it is imperative that you adhere We highly encourage code contributions, however it is imperative that you adhere
to the guidelines established on this page. to the guidelines established on this page.
<a name="MinSkillset" /> # Minimum Recommended Skillset
### 2. Minimum Recommended Skillset
The following list is a set of core competencies that we recommend you possess The following list is a set of core competencies that we recommend you possess
before you really start attempting to contribute code to the project. These are before you really start attempting to contribute code to the project. These are
@ -63,7 +59,7 @@ of low hanging fruit which can be tackled without having full competency in the
areas mentioned below. areas mentioned below.
- A reasonable understanding of bitcoin at a high level (see the - A reasonable understanding of bitcoin at a high level (see the
[Required Reading](#ReqReading) section for the original white paper) [Required Reading](#required-reading) section for the original white paper)
- A reasonable understanding of the Lightning Network at a high level - A reasonable understanding of the Lightning Network at a high level
- Experience in some type of C-like language - Experience in some type of C-like language
- An understanding of data structures and their performance implications - An understanding of data structures and their performance implications
@ -78,9 +74,7 @@ if you wish to contribute to the cryptography code, you should have a good
understanding of the various aspects involved with cryptography such as the understanding of the various aspects involved with cryptography such as the
security and performance implications. security and performance implications.
<a name="ReqReading" /> # Required Reading
### 3. Required Reading
- [Effective Go](http://golang.org/doc/effective_go.html) - The entire `lnd` - [Effective Go](http://golang.org/doc/effective_go.html) - The entire `lnd`
project follows the guidelines in this document. For your code to be accepted, project follows the guidelines in this document. For your code to be accepted,
@ -103,17 +97,13 @@ Once the specification is finalized, it will be the most up-to-date
comprehensive document explaining the Lightning Network. As a result, it will comprehensive document explaining the Lightning Network. As a result, it will
be recommended for newcomers to read first in order to get up to speed. be recommended for newcomers to read first in order to get up to speed.
<a name="DevelopmentPractices" /> # Development Practices
### 4. Development Practices
Developers are expected to work in their own trees and submit pull requests when Developers are expected to work in their own trees and submit pull requests when
they feel their feature or bug fix is ready for integration into the master they feel their feature or bug fix is ready for integration into the master
branch. branch.
<a name="ShareEarly" /> ## Share Early, Share Often
#### 4.1. Share Early, Share Often
We firmly believe in the share early, share often approach. The basic premise We firmly believe in the share early, share often approach. The basic premise
of the approach is to announce your plans **before** you start work, and once of the approach is to announce your plans **before** you start work, and once
@ -132,9 +122,7 @@ This approach has several benefits:
- The quicker your changes are merged to master, the less time you will need to - The quicker your changes are merged to master, the less time you will need to
spend rebasing and otherwise trying to keep up with the main code base spend rebasing and otherwise trying to keep up with the main code base
<a name="Testing" /> ## Testing
#### 4.2. Testing
One of the major design goals of all of `lnd`'s packages and the daemon itself is One of the major design goals of all of `lnd`'s packages and the daemon itself is
to aim for a high degree of test coverage. This is financial software so bugs to aim for a high degree of test coverage. This is financial software so bugs
@ -168,15 +156,13 @@ A quick summary of test practices follows:
contained within `lnd`. For example integration tests, see contained within `lnd`. For example integration tests, see
[`lnd_test.go`](https://github.com/lightningnetwork/lnd/blob/master/lnd_test.go#L181). [`lnd_test.go`](https://github.com/lightningnetwork/lnd/blob/master/lnd_test.go#L181).
- The itest log files are automatically scanned for `[ERR]` lines. There - The itest log files are automatically scanned for `[ERR]` lines. There
shouldn't be any of those in the logs, see [Use of Log Levels](#LogLevels). shouldn't be any of those in the logs, see [Use of Log Levels](#use-of-log-levels).
Throughout the process of contributing to `lnd`, you'll likely also be Throughout the process of contributing to `lnd`, you'll likely also be
extensively using the commands within our `Makefile`. As a result, we recommend extensively using the commands within our `Makefile`. As a result, we recommend
[perusing the make file documentation](https://github.com/lightningnetwork/lnd/blob/master/docs/MAKEFILE.md). [perusing the make file documentation](https://github.com/lightningnetwork/lnd/blob/master/docs/MAKEFILE.md).
<a name="CodeDocumentation" /> ## Code Documentation and Commenting
#### 4.3. Code Documentation and Commenting
- At a minimum every function must be commented with its intended purpose and - At a minimum every function must be commented with its intended purpose and
any assumptions that it makes any assumptions that it makes
@ -244,9 +230,7 @@ if amt < 546 {
but it was left as a magic number to show how much of a difference a good but it was left as a magic number to show how much of a difference a good
comment can make. comment can make.
<a name="ModelGitCommitMessages" /> ## Model Git Commit Messages
#### 4.4. Model Git Commit Messages
This project prefers to keep a clean commit history with well-formed commit This project prefers to keep a clean commit history with well-formed commit
messages. This section illustrates a model commit message and provides a bit messages. This section illustrates a model commit message and provides a bit
@ -300,9 +284,7 @@ either a '+' or a ','. This prefix seems minor but can be extremely helpful in
determining the scope of a commit at a glance, or when bug hunting to find a determining the scope of a commit at a glance, or when bug hunting to find a
commit which introduced a bug or regression. commit which introduced a bug or regression.
<a name="IdealGitCommitStructure" /> ## Ideal Git Commit Structure
#### 4.5. Ideal Git Commit Structure
Within the project we prefer small, contained commits for a pull request over a Within the project we prefer small, contained commits for a pull request over a
single giant commit that touches several files/packages. Ideal commits build on single giant commit that touches several files/packages. Ideal commits build on
@ -335,9 +317,7 @@ Examples of common patterns w.r.t commit structures within the project:
induvidual commits that begin to intergrate the functionality within the induvidual commits that begin to intergrate the functionality within the
codebase. codebase.
<a name="CodeSpacing" /> ## Code Spacing
#### 4.6. Code Spacing
Blocks of code within `lnd` should be segmented into logical stanzas of Blocks of code within `lnd` should be segmented into logical stanzas of
operation. Such spacing makes the code easier to follow at a skim, and reduces operation. Such spacing makes the code easier to follow at a skim, and reduces
@ -444,9 +424,7 @@ the comment body.
} }
``` ```
<a name="Protobuf" /> ## Protobuf Compilation
#### 4.7. Protobuf Compilation
The `lnd` project uses `protobuf`, and its extension [`gRPC`](www.grpc.io) in The `lnd` project uses `protobuf`, and its extension [`gRPC`](www.grpc.io) in
several areas and as the primary RPC interface. In order to ensure uniformity several areas and as the primary RPC interface. In order to ensure uniformity
@ -464,9 +442,7 @@ otherwise the CI pipeline on Travis will fail:
For detailed instructions on how to compile modifications to `lnd`'s `protobuf` For detailed instructions on how to compile modifications to `lnd`'s `protobuf`
definitions, check out the [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md). definitions, check out the [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md).
<a name="ExtraGoFmtStyle" /> ## Additional Style Constraints On Top of `gofmt`
#### 4.8. Additional Style Constraints On Top of `gofmt`
Before a PR is submitted, the proposer should ensure that the file passes the Before a PR is submitted, the proposer should ensure that the file passes the
set of linting scripts run by `make lint`. These include `gofmt`. In addition set of linting scripts run by `make lint`. These include `gofmt`. In addition
@ -496,9 +472,7 @@ Note that the above guidelines don't apply to log messages. For log messages,
committers should attempt to minimize the of number lines utilized, while still committers should attempt to minimize the of number lines utilized, while still
adhering to the 80-character column limit. adhering to the 80-character column limit.
<a name="ModulesReplace" /> ## Pointing to Remote Dependant Branches in Go Modules
#### 4.9 Pointing to Remote Dependant Branches in Go Modules
It's common that a developer may need to make a change in a dependent project It's common that a developer may need to make a change in a dependent project
of `lnd` such as `btcd`, `neutrino`, `btcwallet`, etc. In order to test changes of `lnd` such as `btcd`, `neutrino`, `btcwallet`, etc. In order to test changes
@ -515,9 +489,7 @@ Here's an example replacing the `lightning-onion` version checked into `lnd` wit
⛰ go mod edit -replace=github.com/lightningnetwork/lightning-onion@v0.0.0-20180605012408-ac4d9da8f1d6=github.com/roasbeef/lightning-onion@2e5ae87696046298365ab43bcd1cf3a7a1d69695 ⛰ go mod edit -replace=github.com/lightningnetwork/lightning-onion@v0.0.0-20180605012408-ac4d9da8f1d6=github.com/roasbeef/lightning-onion@2e5ae87696046298365ab43bcd1cf3a7a1d69695
``` ```
<a name="LogLevels" /> ## Use of Log Levels
#### 4.10 Use of Log Levels
There are six log levels available: `trace`, `debug`, `info`, `warn`, `error` and `critical`. There are six log levels available: `trace`, `debug`, `info`, `warn`, `error` and `critical`.
@ -525,22 +497,18 @@ Only use `error` for internal errors that are never expected to happen during
normal operation. No event triggered by external sources (rpc, chain backend, normal operation. No event triggered by external sources (rpc, chain backend,
etc) should lead to an `error` log. etc) should lead to an `error` log.
<a name="CodeApproval" /> # Code Approval Process
### 5. Code Approval Process
This section describes the code approval process that is used for code This section describes the code approval process that is used for code
contributions. This is how to get your changes into `lnd`. contributions. This is how to get your changes into `lnd`.
<a name="CodeReview" /> ## Code Review
#### 5.1. Code Review
All code which is submitted will need to be reviewed before inclusion into the All code which is submitted will need to be reviewed before inclusion into the
master branch. This process is performed by the project maintainers and usually master branch. This process is performed by the project maintainers and usually
other committers who are interested in the area you are working in as well. other committers who are interested in the area you are working in as well.
##### Code Review Timeframe ### Code Review Timeframe
The timeframe for a code review will vary greatly depending on factors such as The timeframe for a code review will vary greatly depending on factors such as
the number of other pull requests which need to be reviewed, the size and the number of other pull requests which need to be reviewed, the size and
@ -553,14 +521,15 @@ manageable, commits.
Keeping the above in mind, most small changes will be reviewed within a few Keeping the above in mind, most small changes will be reviewed within a few
days, while large or far reaching changes may take weeks. This is a good reason days, while large or far reaching changes may take weeks. This is a good reason
to stick with the [Share Early, Share Often](#ShareEarly) development practice to stick with the [Share Early, Share Often](#share-early-share-often)
outlined above. development practice outlined above.
##### What is the review looking for? ### What is the review looking for?
The review is mainly ensuring the code follows the [Development Practices](#DevelopmentPractices) The review is mainly ensuring the code follows the
and [Code Contribution Standards](#Standards). However, there are a few other [Development Practices](#development-practices) and
checks which are generally performed as follows: [Code Contribution Standards](#contribution-standards). However, there are a few
other checks which are generally performed as follows:
- The code is stable and has no stability or security concerns - The code is stable and has no stability or security concerns
- The code is properly using existing APIs and generally fits well into the - The code is properly using existing APIs and generally fits well into the
@ -568,9 +537,7 @@ checks which are generally performed as follows:
- The change is not something which is deemed inappropriate by community - The change is not something which is deemed inappropriate by community
consensus consensus
<a name="CodeRework" /> ## Rework Code (if needed)
#### 5.2. Rework Code (if needed)
After the code review, the change will be accepted immediately if no issues are After the code review, the change will be accepted immediately if no issues are
found. If there are any concerns or questions, you will be provided with found. If there are any concerns or questions, you will be provided with
@ -588,9 +555,7 @@ can set it to auto squash the fix up commits on rebase.
This process will continue until the code is finally accepted. This process will continue until the code is finally accepted.
<a name="CodeAcceptance" /> ## Acceptance
#### 5.3. Acceptance
Once your code is accepted, it will be integrated with the master branch. After Once your code is accepted, it will be integrated with the master branch. After
2+ (sometimes 1) LGTM's (approvals) are given on a PR, it's eligible to land in 2+ (sometimes 1) LGTM's (approvals) are given on a PR, it's eligible to land in
@ -603,16 +568,13 @@ these signatures intact, we prefer using merge commits. PR proposers can use
Rejoice as you will now be listed as a [contributor](https://github.com/lightningnetwork/lnd/graphs/contributors)! Rejoice as you will now be listed as a [contributor](https://github.com/lightningnetwork/lnd/graphs/contributors)!
<a name="Standards" /> # Contribution Standards
### 6. Contribution Standards ## Contribution Checklist
<a name="Checklist" />
#### 6.1. Contribution Checklist
- [&nbsp;&nbsp;] All changes are Go version 1.12 compliant - [&nbsp;&nbsp;] All changes are Go version 1.12 compliant
- [&nbsp;&nbsp;] The code being submitted is commented according to [Code Documentation and Commenting](#CodeDocumentation) - [&nbsp;&nbsp;] The code being submitted is commented according to
[Code Documentation and Commenting](#code-documentation-and-commenting)
- [&nbsp;&nbsp;] For new code: Code is accompanied by tests which exercise both - [&nbsp;&nbsp;] For new code: Code is accompanied by tests which exercise both
the positive and negative (error paths) conditions (if applicable) the positive and negative (error paths) conditions (if applicable)
- [&nbsp;&nbsp;] For bug fixes: Code is accompanied by new tests which trigger - [&nbsp;&nbsp;] For bug fixes: Code is accompanied by new tests which trigger
@ -630,18 +592,17 @@ Rejoice as you will now be listed as a [contributor](https://github.com/lightnin
- [&nbsp;&nbsp;] All commits build properly and pass tests. Only in exceptional - [&nbsp;&nbsp;] All commits build properly and pass tests. Only in exceptional
cases it can be justifiable to violate this condition. In that case, the cases it can be justifiable to violate this condition. In that case, the
reason should be stated in the commit message. reason should be stated in the commit message.
- [&nbsp;&nbsp;] Commits have a logical structure according to [Ideal Git Commit Structure](#IdealGitCommitStructure). - [&nbsp;&nbsp;] Commits have a logical structure according to
[Ideal Git Commit Structure](#ideal-git-commit-structure).
<a name="Licensing" /> ## Licensing of Contributions
#### 6.2. Licensing of Contributions
**** ****
All contributions must be licensed with the All contributions must be licensed with the
[MIT license](https://github.com/lightningnetwork/lnd/blob/master/LICENSE). This is [MIT license](https://github.com/lightningnetwork/lnd/blob/master/LICENSE). This is
the same license as all of the code found within lnd. the same license as all of the code found within lnd.
## Acknowledgements # Acknowledgements
This document was heavily inspired by a [similar document outlining the code This document was heavily inspired by a [similar document outlining the code
contribution](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md) contribution](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md)
guidelines for btcd. guidelines for btcd.