Skip to content

Commit 6d068c6

Browse files
Mateusz Machalicalehecka
Mateusz Machalica
authored andcommitted
Clang-format config, script and initial re-formatting. (#27)
1 parent 69935e2 commit 6d068c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+122
-79
lines changed

Diff for: .clang-format

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 80
39+
CommentPragmas: '^ IWYU pragma:'
40+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
41+
ConstructorInitializerIndentWidth: 4
42+
ContinuationIndentWidth: 4
43+
Cpp11BracedListStyle: true
44+
DerivePointerAlignment: false
45+
DisableFormat: false
46+
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
47+
IncludeCategories:
48+
- Regex: '^<.*\.h(pp)?>'
49+
Priority: 1
50+
- Regex: '^<.*'
51+
Priority: 2
52+
- Regex: '.*'
53+
Priority: 3
54+
IndentCaseLabels: true
55+
IndentWidth: 2
56+
IndentWrappedFunctionNames: false
57+
KeepEmptyLinesAtTheStartOfBlocks: false
58+
MacroBlockBegin: ''
59+
MacroBlockEnd: ''
60+
MaxEmptyLinesToKeep: 1
61+
NamespaceIndentation: None
62+
ObjCBlockIndentWidth: 2
63+
ObjCSpaceAfterProperty: false
64+
ObjCSpaceBeforeProtocolList: false
65+
PenaltyBreakBeforeFirstCallParameter: 1
66+
PenaltyBreakComment: 300
67+
PenaltyBreakFirstLessLess: 120
68+
PenaltyBreakString: 1000
69+
PenaltyExcessCharacter: 1000000
70+
PenaltyReturnTypeOnItsOwnLine: 200
71+
PointerAlignment: Left
72+
ReflowComments: true
73+
SortIncludes: true
74+
SpaceAfterCStyleCast: false
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 1
79+
SpacesInAngles: false
80+
SpacesInContainerLiterals: true
81+
SpacesInCStyleCastParentheses: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Cpp11
85+
TabWidth: 8
86+
UseTab: Never
87+
...

Diff for: CONTRIBUTING

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ We actively welcome your pull requests.
1313
3. If you've changed APIs, update the documentation.
1414
4. Ensure the test suite passes.
1515
5. Make sure your code lints.
16-
6. If you haven't already, complete the Contributor License Agreement ("CLA").
16+
6. Make sure your code is properly formatted by running `devtools/format_all.sh`.
17+
7. If you haven't already, complete the Contributor License Agreement ("CLA").
1718

1819
## Contributor License Agreement ("CLA")
1920
In order to accept your pull request, we need you to submit a CLA. You only need
@@ -29,10 +30,10 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
2930
disclosure of security bugs. In those cases, please go through the process
3031
outlined on that page and do not file a public issue.
3132

32-
## Coding Style
33-
* 2 spaces for indentation rather than tabs
34-
* 80 character line length
35-
* ...
33+
## Coding Style
34+
Most of the code formatting will be handled for you by marvellous `clang-format`, which, at least on OSX, you can obtain from Homebrew via `brew install clang-format`. To ensure proper formatting, simply run `devtools/format_all.sh` before submitting a patch.
35+
36+
As far as naming conventions are concerned, please try matching existing code as much as possible.
3637

3738
## License
3839
By contributing to reactivesocket-cpp, you agree that your contributions will be licensed

Diff for: devtools/format_all.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -xue
3+
4+
cd "$(dirname "$0")/.."
5+
find \
6+
reactive-streams-cpp \
7+
reactivesocket-cpp \
8+
-type f \( -name "*.cpp" -o -name "*.h" \) \
9+
-exec clang-format -i {} \;
10+
11+
# EOF

Diff for: reactive-streams-cpp/Mocks.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cassert>

Diff for: reactive-streams-cpp/Publisher.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <exception>
@@ -19,9 +18,10 @@ class Subscriber;
1918
///
2019
/// Life cycle considerations:
2120
/// 1. The Publisher is not owned by Subscriber or Subscription.
22-
/// 2. The Publisher can be a temporary object, as it is only used to capture the
23-
/// indirection in creation of the Subscription instance. Publisher's lifetime
24-
/// does not need to extend beyond a lifetime of any of the Subscribers.
21+
/// 2. The Publisher can be a temporary object, as it is only used to capture
22+
/// the indirection in creation of the Subscription instance. Publisher's
23+
/// lifetime does not need to extend beyond a lifetime of any of the
24+
/// Subscribers.
2525
template <typename T, typename E = std::exception_ptr>
2626
class Publisher {
2727
public:

Diff for: reactive-streams-cpp/Subscriber.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <exception>
@@ -64,16 +63,16 @@ class Subscriber {
6463
/// Called by or on behalf of Publisher when it wishes to terminate the
6564
/// abstract subscription gracefully.
6665
///
67-
/// Subscriber pointer passed to the Publisher::subscribe may become invalid as
68-
/// a result of this call. No other method of the Subscriber can be called
66+
/// Subscriber pointer passed to the Publisher::subscribe may become invalid
67+
/// as a result of this call. No other method of the Subscriber can be called
6968
/// after or during an invocation of ::onComplete.
7069
virtual void onComplete() = 0;
7170

7271
/// Called by or on behalf of Publisher when it wishes to terminate the
7372
/// abstract subscription with an error.
7473
///
75-
/// Subscriber pointer passed to the Publisher::subscribe may become invalid as
76-
/// a result of this call. No other method of the Subscriber can be called
74+
/// Subscriber pointer passed to the Publisher::subscribe may become invalid
75+
/// as a result of this call. No other method of the Subscriber can be called
7776
/// after or during an invocation of ::onError.
7877
virtual void onError(E ex) = 0;
7978
};

Diff for: reactive-streams-cpp/Subscription.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cstddef>

Diff for: reactive-streams-cpp/examples/Examples.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "reactive-streams-cpp/Mocks.h"
54

65
#include <gmock/gmock.h>

Diff for: reactive-streams-cpp/test/AllowanceSemaphoreTest.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
4-
53
#include <limits>
64

75
#include <gmock/gmock.h>

Diff for: reactive-streams-cpp/test/OwnershipTest.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
4-
53
#include <memory>
64

75
#include <gtest/gtest.h>

Diff for: reactive-streams-cpp/test/SmartPointersTest.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
4-
53
#include <cstddef>
64
#include <exception>
75
#include <limits>

Diff for: reactive-streams-cpp/utilities/AllowanceSemaphore.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cassert>

Diff for: reactive-streams-cpp/utilities/Ownership.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cassert>

Diff for: reactive-streams-cpp/utilities/SmartPointers.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cassert>

Diff for: reactivesocket-cpp/src/AbstractStreamAutomaton.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "AbstractStreamAutomaton.h"
54

65
#include <ostream>

Diff for: reactivesocket-cpp/src/AbstractStreamAutomaton.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cstddef>

Diff for: reactivesocket-cpp/src/ConnectionAutomaton.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "reactivesocket-cpp/src/ConnectionAutomaton.h"
54

65
#include <limits>

Diff for: reactivesocket-cpp/src/ConnectionAutomaton.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <deque>

Diff for: reactivesocket-cpp/src/DuplexConnection.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include "reactivesocket-cpp/src/Payload.h"

Diff for: reactivesocket-cpp/src/Frame.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "reactivesocket-cpp/src/Frame.h"
54

65
#include <bitset>

Diff for: reactivesocket-cpp/src/Frame.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <iosfwd>

Diff for: reactivesocket-cpp/src/Payload.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <memory>

Diff for: reactivesocket-cpp/src/ReactiveSocket.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "reactivesocket-cpp/src/ReactiveSocket.h"
54

65
#include <cassert>

Diff for: reactivesocket-cpp/src/ReactiveSocket.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <atomic>

Diff for: reactivesocket-cpp/src/ReactiveStreamsCompat.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include "reactive-streams-cpp/Publisher.h"

Diff for: reactivesocket-cpp/src/RequestHandler.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include "reactivesocket-cpp/src/Payload.h"

Diff for: reactivesocket-cpp/src/automata/ChannelRequester.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "ChannelRequester.h"
54

65
#include <algorithm>

Diff for: reactivesocket-cpp/src/automata/ChannelRequester.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <iosfwd>

Diff for: reactivesocket-cpp/src/automata/ChannelResponder.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "ChannelResponder.h"
54

65
#include <folly/ExceptionWrapper.h>

Diff for: reactivesocket-cpp/src/automata/ChannelResponder.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <iosfwd>

Diff for: reactivesocket-cpp/src/automata/SubscriptionRequester.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "SubscriptionRequester.h"
54

65
#include <algorithm>

Diff for: reactivesocket-cpp/src/automata/SubscriptionRequester.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <iosfwd>

Diff for: reactivesocket-cpp/src/automata/SubscriptionResponder.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#include "SubscriptionResponder.h"
54

65
#include <folly/ExceptionWrapper.h>

Diff for: reactivesocket-cpp/src/automata/SubscriptionResponder.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <iosfwd>

Diff for: reactivesocket-cpp/src/mixins/ConsumerMixin-inl.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54
#include "ConsumerMixin.h"
65

Diff for: reactivesocket-cpp/src/mixins/ConsumerMixin.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

3-
43
#pragma once
54

65
#include <cstddef>

0 commit comments

Comments
 (0)