Skip to content

Commit df8892d

Browse files
author
MarcoFalke
committed
Merge #20986: docs: update developer notes to discourage very long lines
aa929ab [docs] Update developer notes to discourage very long lines (John Newbery) Pull request description: Mandatory rules on line lengths are bad - there will always be cases where a longer line is more readable than the alternative. However, very long lines for no good reason _do_ hurt readability. For example, this declaration in validation.h is 274 chars: ```c++ bool ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool.cs); ``` That won't fit on one line without wrapping on my 27" monitor with a comfortable font size. Much easier to read is something like: ```c++ bool ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool.cs); ``` Therefore, _discourage_ (don't forbid) line lengths greater than 100 characters in our developer style guide. 100 chars is somewhat arbitrary. The old standard was 80, but that seems very limiting with modern displays. ACKs for top commit: fanquake: ACK aa929ab - this is basically just something to point too when a PR has unreasonably long lines for no particularly reason. practicalswift: ACK aa929ab amitiuttarwar: ACK aa929ab theStack: ACK aa929ab glozow: ACK bitcoin/bitcoin@aa929ab Tree-SHA512: 17f1b11f811137497ede8851ede93fa612dc622922b5ad7ac8f065ea026d9a718db5b92325754b74d24012b4d45c4e2cd5cd439a6a8d34bbabf5da927d783970
2 parents e4f0c4c + aa929ab commit df8892d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/developer-notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ tool to clean up patches automatically before submission.
7575
on the same line as the `if`, without braces. In every other case,
7676
braces are required, and the `then` and `else` clauses must appear
7777
correctly indented on a new line.
78+
- There's no hard limit on line width, but prefer to keep lines to <100
79+
characters if doing so does not decrease readability. Break up long
80+
function declarations over multiple lines using the Clang Format
81+
[AlignAfterOpenBracket](https://clang.llvm.org/docs/ClangFormatStyleOptions.html)
82+
style option.
7883

7984
- **Symbol naming conventions**. These are preferred in new code, but are not
8085
required when doing so would need changes to significant pieces of existing

0 commit comments

Comments
 (0)