Skip to content

Commit

Permalink
Clang-format config, script and initial re-formatting. (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Machalica authored and lehecka committed May 16, 2016
1 parent 69935e2 commit 6d068c6
Show file tree
Hide file tree
Showing 53 changed files with 122 additions and 79 deletions.
87 changes: 87 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
11 changes: 6 additions & 5 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ We actively welcome your pull requests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. If you haven't already, complete the Contributor License Agreement ("CLA").
6. Make sure your code is properly formatted by running `devtools/format_all.sh`.
7. If you haven't already, complete the Contributor License Agreement ("CLA").

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

## Coding Style
* 2 spaces for indentation rather than tabs
* 80 character line length
* ...
## Coding Style
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.

As far as naming conventions are concerned, please try matching existing code as much as possible.

## License
By contributing to reactivesocket-cpp, you agree that your contributions will be licensed
Expand Down
11 changes: 11 additions & 0 deletions devtools/format_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -xue

cd "$(dirname "$0")/.."
find \
reactive-streams-cpp \
reactivesocket-cpp \
-type f \( -name "*.cpp" -o -name "*.h" \) \
-exec clang-format -i {} \;

# EOF
1 change: 0 additions & 1 deletion reactive-streams-cpp/Mocks.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cassert>
Expand Down
8 changes: 4 additions & 4 deletions reactive-streams-cpp/Publisher.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <exception>
Expand All @@ -19,9 +18,10 @@ class Subscriber;
///
/// Life cycle considerations:
/// 1. The Publisher is not owned by Subscriber or Subscription.
/// 2. The Publisher can be a temporary object, as it is only used to capture the
/// indirection in creation of the Subscription instance. Publisher's lifetime
/// does not need to extend beyond a lifetime of any of the Subscribers.
/// 2. The Publisher can be a temporary object, as it is only used to capture
/// the indirection in creation of the Subscription instance. Publisher's
/// lifetime does not need to extend beyond a lifetime of any of the
/// Subscribers.
template <typename T, typename E = std::exception_ptr>
class Publisher {
public:
Expand Down
9 changes: 4 additions & 5 deletions reactive-streams-cpp/Subscriber.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

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

/// Called by or on behalf of Publisher when it wishes to terminate the
/// abstract subscription with an error.
///
/// Subscriber pointer passed to the Publisher::subscribe may become invalid as
/// a result of this call. No other method of the Subscriber can be called
/// Subscriber pointer passed to the Publisher::subscribe may become invalid
/// as a result of this call. No other method of the Subscriber can be called
/// after or during an invocation of ::onError.
virtual void onError(E ex) = 0;
};
Expand Down
1 change: 0 additions & 1 deletion reactive-streams-cpp/Subscription.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cstddef>
Expand Down
1 change: 0 additions & 1 deletion reactive-streams-cpp/examples/Examples.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "reactive-streams-cpp/Mocks.h"

#include <gmock/gmock.h>
Expand Down
2 changes: 0 additions & 2 deletions reactive-streams-cpp/test/AllowanceSemaphoreTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.



#include <limits>

#include <gmock/gmock.h>
Expand Down
2 changes: 0 additions & 2 deletions reactive-streams-cpp/test/OwnershipTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.



#include <memory>

#include <gtest/gtest.h>
Expand Down
2 changes: 0 additions & 2 deletions reactive-streams-cpp/test/SmartPointersTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.



#include <cstddef>
#include <exception>
#include <limits>
Expand Down
1 change: 0 additions & 1 deletion reactive-streams-cpp/utilities/AllowanceSemaphore.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cassert>
Expand Down
1 change: 0 additions & 1 deletion reactive-streams-cpp/utilities/Ownership.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cassert>
Expand Down
1 change: 0 additions & 1 deletion reactive-streams-cpp/utilities/SmartPointers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cassert>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/AbstractStreamAutomaton.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "AbstractStreamAutomaton.h"

#include <ostream>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/AbstractStreamAutomaton.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cstddef>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/ConnectionAutomaton.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "reactivesocket-cpp/src/ConnectionAutomaton.h"

#include <limits>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/ConnectionAutomaton.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <deque>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/DuplexConnection.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include "reactivesocket-cpp/src/Payload.h"
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "reactivesocket-cpp/src/Frame.h"

#include <bitset>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/Frame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <iosfwd>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/Payload.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <memory>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/ReactiveSocket.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "reactivesocket-cpp/src/ReactiveSocket.h"

#include <cassert>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/ReactiveSocket.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <atomic>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/ReactiveStreamsCompat.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include "reactive-streams-cpp/Publisher.h"
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/RequestHandler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include "reactivesocket-cpp/src/Payload.h"
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/ChannelRequester.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "ChannelRequester.h"

#include <algorithm>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/ChannelRequester.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <iosfwd>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/ChannelResponder.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "ChannelResponder.h"

#include <folly/ExceptionWrapper.h>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/ChannelResponder.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <iosfwd>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/SubscriptionRequester.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "SubscriptionRequester.h"

#include <algorithm>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/SubscriptionRequester.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <iosfwd>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/SubscriptionResponder.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#include "SubscriptionResponder.h"

#include <folly/ExceptionWrapper.h>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/automata/SubscriptionResponder.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <iosfwd>
Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/mixins/ConsumerMixin-inl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once
#include "ConsumerMixin.h"

Expand Down
1 change: 0 additions & 1 deletion reactivesocket-cpp/src/mixins/ConsumerMixin.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2004-present Facebook. All Rights Reserved.


#pragma once

#include <cstddef>
Expand Down
Loading

0 comments on commit 6d068c6

Please sign in to comment.