Bitcoin full node and query server

Dec 23, 2018

View in context in the libbitcoin Slack #general mirror.

jungly12:11
You are totally right on watching out for the style. Consistency is important. It's just hard for a newcomer like me who is used to let the machine watch out for my inconsistencies. I am curious to find something that works on my setup (Emacs) and visual studio without too many external dependencies. I like the promise of clang-format, but as you said, it's hard to find something that makes sense for every setup. I'll keep you posted on what I find useful.
4 replies · neillm, jungly · last Dec 24, 2018
neillm21:53
I also use emacs and had chatted about clang-format at one point with @evoskuil. Workflow-wise, it would be nice for me, but we'd have to codify the style for it. Not sure about VS support. Good luck and keep us posted! :-)
jungly14:40
Messed around with clang-format a bit. It won’t conform 100% with the style in libbitcoin. Some rules that we just configure it for are 1. can’t force breaks before inheritance lists, unless they hit 80 col limit 2. it will put a break before the first parameter if call or function declaration exceeds 80 col limit 3. can’t config it to put a new line before lambda expressions Am sure there are some other rules it breaks too. As pros, it has excellent support for VS and emacs. For VS you can format a file explicitly or automatically on save. There is a ClangFormat extension for VS Code since last year.
(edited)
jungly14:45
In short, I don’t think we can use it to “enforce” a standard. But I might use it to sanity check my commits before creating PRs. To take some load of reviewers. I’ll ask it to format things for me and then massage away its non-conformant changes. The file I am going to use (and not add to a repo) is coming next
jungly14:52
I used the LLVM initial config and formatted it to - order include files as per the styles page - make brace wrapping as true to style as possible. (It still breaks for lambda expressions) - used bin packaging for args and params, but it creates another issue with putting all args/params on a new line - expression/statement alignment - breaks at binary operator - small misc other changes Would love any recommended changes/improvements to meet the style. Just hoping it’ll ease load on reviews, aka Eric! 😉
.clang-format Plain Text · 3.3 KB
---
Language:        Cpp
# BasedOnStyle:  WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands:   false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:   
  AfterClass:      true
  AfterControlStatement: true
  AfterEnum:       true
  AfterFunction:   true
  AfterNamespace:  false
  AfterObjCDeclaration: false
  AfterStruct:     true
  AfterUnion:      true
  AfterExternBlock: false
  BeforeCatch:     false
  BeforeElse:      true
  IndentBraces:    false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
full file