Skip to content

Commit 848d4bb

Browse files
authored
Update clang format to match rippled/xrpld (#17)
* As of rippled/xrpld 3.0.0
1 parent 313c813 commit 848d4bb

File tree

10 files changed

+73
-45
lines changed

10 files changed

+73
-45
lines changed

.clang-format

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
---
2-
Language: Cpp
2+
BreakBeforeBraces: Custom
3+
BraceWrapping:
4+
AfterClass: true
5+
AfterControlStatement: true
6+
AfterEnum: false
7+
AfterFunction: true
8+
AfterNamespace: false
9+
AfterObjCDeclaration: true
10+
AfterStruct: true
11+
AfterUnion: true
12+
BeforeCatch: true
13+
BeforeElse: true
14+
IndentBraces: false
15+
KeepEmptyLinesAtTheStartOfBlocks: false
16+
MaxEmptyLinesToKeep: 1
17+
---
18+
Language: Cpp
319
AccessModifierOffset: -4
420
AlignAfterOpenBracket: AlwaysBreak
521
AlignConsecutiveAssignments: false
@@ -18,48 +34,43 @@ AlwaysBreakBeforeMultilineStrings: true
1834
AlwaysBreakTemplateDeclarations: true
1935
BinPackArguments: false
2036
BinPackParameters: false
21-
BraceWrapping:
22-
AfterClass: true
23-
AfterControlStatement: true
24-
AfterEnum: false
25-
AfterFunction: true
26-
AfterNamespace: false
27-
AfterObjCDeclaration: true
28-
AfterStruct: true
29-
AfterUnion: true
30-
BeforeCatch: true
31-
BeforeElse: true
32-
IndentBraces: false
3337
BreakBeforeBinaryOperators: false
34-
BreakBeforeBraces: Custom
3538
BreakBeforeTernaryOperators: true
3639
BreakConstructorInitializersBeforeComma: true
37-
ColumnLimit: 80
38-
CommentPragmas: '^ IWYU pragma:'
40+
ColumnLimit: 80
41+
CommentPragmas: "^ IWYU pragma:"
3942
ConstructorInitializerAllOnOneLineOrOnePerLine: true
4043
ConstructorInitializerIndentWidth: 4
4144
ContinuationIndentWidth: 4
4245
Cpp11BracedListStyle: true
4346
DerivePointerAlignment: false
44-
DisableFormat: false
47+
DisableFormat: false
4548
ExperimentalAutoDetectBinPacking: false
46-
ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ]
49+
ForEachMacros: [Q_FOREACH, BOOST_FOREACH]
50+
IncludeBlocks: Regroup
4751
IncludeCategories:
48-
- Regex: '^<(BeastConfig)'
49-
Priority: 0
50-
- Regex: '^<(ripple)/'
51-
Priority: 2
52-
- Regex: '^<(boost)/'
53-
Priority: 3
54-
- Regex: '.*'
55-
Priority: 4
56-
IncludeIsMainRegex: '$'
52+
- Regex: "^<(test)/"
53+
Priority: 0
54+
- Regex: '^[^/]*\.h'
55+
Priority: 1
56+
- Regex: "^<(xrpld)/"
57+
Priority: 2
58+
- Regex: "^<(xrpl|ripple)/"
59+
Priority: 3
60+
- Regex: "^<(boost)/"
61+
Priority: 4
62+
- Regex: "^.*/"
63+
Priority: 5
64+
- Regex: '^.*\.h'
65+
Priority: 6
66+
- Regex: ".*"
67+
Priority: 7
68+
IncludeIsMainRegex: "$"
5769
IndentCaseLabels: true
5870
IndentFunctionDeclarationAfterType: false
59-
IndentWidth: 4
71+
IndentRequiresClause: true
72+
IndentWidth: 4
6073
IndentWrappedFunctionNames: false
61-
KeepEmptyLinesAtTheStartOfBlocks: false
62-
MaxEmptyLinesToKeep: 1
6374
NamespaceIndentation: None
6475
ObjCSpaceAfterProperty: false
6576
ObjCSpaceBeforeProtocolList: false
@@ -70,18 +81,25 @@ PenaltyBreakString: 1000
7081
PenaltyExcessCharacter: 1000000
7182
PenaltyReturnTypeOnItsOwnLine: 200
7283
PointerAlignment: Left
73-
ReflowComments: true
74-
SortIncludes: true
84+
ReflowComments: true
85+
RequiresClausePosition: OwnLine
86+
SortIncludes: true
7587
SpaceAfterCStyleCast: false
7688
SpaceBeforeAssignmentOperators: true
7789
SpaceBeforeParens: ControlStatements
7890
SpaceInEmptyParentheses: false
7991
SpacesBeforeTrailingComments: 2
80-
SpacesInAngles: false
92+
SpacesInAngles: false
8193
SpacesInContainerLiterals: true
8294
SpacesInCStyleCastParentheses: false
8395
SpacesInParentheses: false
8496
SpacesInSquareBrackets: false
85-
Standard: Cpp11
86-
TabWidth: 8
87-
UseTab: Never
97+
Standard: Cpp11
98+
TabWidth: 8
99+
UseTab: Never
100+
QualifierAlignment: Right
101+
---
102+
Language: Proto
103+
BasedOnStyle: Google
104+
ColumnLimit: 0
105+
IndentWidth: 2

src/OfflineTool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ getStdin()
284284

285285
int
286286
runCommand(
287-
const std::string& command,
287+
std::string const& command,
288288
std::vector<std::string> const& args,
289289
boost::filesystem::path const& keyFile,
290290
std::optional<std::string> const& keyType,
@@ -386,7 +386,7 @@ getEnvVar(char const* name)
386386

387387
void
388388
printHelp(
389-
const boost::program_options::options_description& desc,
389+
boost::program_options::options_description const& desc,
390390
boost::filesystem::path const& defaultKeyfile)
391391
{
392392
static std::string const name = "ripple-offline";

src/OfflineTool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ doCreateKeyfile(
5050

5151
int
5252
runCommand(
53-
const std::string& command,
53+
std::string const& command,
5454
std::vector<std::string> const& args,
5555
boost::filesystem::path const& keyFile,
5656
std::optional<std::string> const& keyType,

src/RippleKey.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2525
#include <ripple/json/to_string.h>
2626
#include <ripple/protocol/Sign.h>
2727
#include <ripple/protocol/jss.h>
28+
2829
#include <boost/filesystem.hpp>
30+
2931
#include <fstream>
3032

3133
namespace offline {

src/Serialize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include <ripple/protocol/ErrorCodes.h>
2929
#include <ripple/protocol/HashPrefix.h>
3030
#include <ripple/protocol/Sign.h>
31+
3132
#include <boost/filesystem.hpp>
33+
3234
#include <fstream>
3335

3436
namespace offline {

src/Serialize.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <ripple/protocol/KeyType.h>
2222
#include <ripple/protocol/SecretKey.h>
2323
#include <ripple/protocol/st.h>
24+
2425
#include <optional>
2526

2627
namespace boost {

src/test/KeyFileGuard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
//==============================================================================
2020

2121
#include <ripple/beast/unit_test.h>
22+
2223
#include <boost/filesystem.hpp>
24+
2325
#include <fstream>
2426

2527
namespace offline {

src/test/OfflineTool_test.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
#include <ripple/beast/unit_test.h>
2929
#include <ripple/protocol/SecretKey.h>
30+
3031
#include <boost/format.hpp>
32+
3133
#include <string>
3234

3335
namespace offline {
@@ -552,10 +554,11 @@ class OfflineTool_test : public beast::unit_test::suite
552554
auto const key = RippleKey::make_RippleKey(keyFile);
553555

554556
auto const known = boost::str(
555-
boost::format("New ripple key created in %s\n"
556-
"Key type is %s, and account ID is %s\n"
557-
"\nThis file should be stored securely and "
558-
"not shared\n\n") %
557+
boost::format(
558+
"New ripple key created in %s\n"
559+
"Key type is %s, and account ID is %s\n"
560+
"\nThis file should be stored securely and "
561+
"not shared\n\n") %
559562
keyFile.string() % to_string(key.keyType()) %
560563
toBase58(calcAccountID(key.publicKey())));
561564

src/test/RippleKey_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class RippleKey_test : public beast::unit_test::suite
103103
path const keyFile = subdir / ".ripple" / "secret-key.txt";
104104

105105
// Try some failure cases before writing the file
106-
auto badFile = [&](const char* toWrite,
106+
auto badFile = [&](char const* toWrite,
107107
std::string const& expectedException) {
108108
path const badKeyFile = subdir / "bad-key.txt";
109109
if (toWrite)

src/test/Serialize_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Serialize_test : public beast::unit_test::suite
7676
{
7777
// Need a variable here instead of a literal to make
7878
// some compilers happy
79-
const std::uint64_t mantissa = 5678900000000000LLU;
79+
std::uint64_t const mantissa = 5678900000000000LLU;
8080
BEAST_EXPECT(
8181
obj[sfSendMax] ==
8282
STAmount(

0 commit comments

Comments
 (0)